/* Generated by Cython 0.26.1 */

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

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
    #error Cython requires Python 2.6+ or Python 3.2+.
#else
#define CYTHON_ABI "0_26_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 >= 0x03030000 || (PY_MAJOR_VERSION == 2 && 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
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #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
#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
#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
#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
#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 < 0x030700A0 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject **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 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
#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
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
#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) : PyInstanceMethod_New(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#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
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#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
  #ifdef __cplusplus
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough) || (defined(__GNUC__) && defined(__attribute__))
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #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 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; \
}

#if PY_MAJOR_VERSION >= 3
  #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_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#endif

#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
#include <vector>
#include "ios"
#include "new"
#include "stdexcept"
#include "typeinfo"
#include <utility>
#include <map>
#include <string.h>
#include <stdio.h>
#include "pythread.h"
#include <stdlib.h>
#include "pystate.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_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) && defined (_M_X64)
    #define __Pyx_sst_abs(value) _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_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)
#if PY_MAJOR_VERSION < 3
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);
}
#else
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
#endif
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
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;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;

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


static const char *__pyx_f[] = {
  "cupy/core/core.pyx",
  "cupy/core/elementwise.pxi",
  "cupy/core/carray.pxi",
  "cupy/core/core.pxd",
  "stringsource",
  "cupy/core/reduction.pxi",
  "cupy/cuda/device.pxd",
  "cupy/cuda/memory.pxd",
  "cupy/cuda/function.pxd",
  "type.pxd",
  "bool.pxd",
  "complex.pxd",
  "cupy/cuda/pinned_memory.pxd",
  "cupy/cuda/runtime.pxd",
};
/* MemviewSliceStruct.proto */
struct __pyx_memoryview_obj;
typedef struct {
  struct __pyx_memoryview_obj *memview;
  char *data;
  Py_ssize_t shape[8];
  Py_ssize_t strides[8];
  Py_ssize_t suboffsets[8];
} __Pyx_memviewslice;

/* BufferFormatStructs.proto */
#define IS_UNSIGNED(type) (((type) -1) > 0)
struct __Pyx_StructField_;
#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
typedef struct {
  const char* name;
  struct __Pyx_StructField_* fields;
  size_t size;
  size_t arraysize[8];
  int ndim;
  char typegroup;
  char is_unsigned;
  int flags;
} __Pyx_TypeInfo;
typedef struct __Pyx_StructField_ {
  __Pyx_TypeInfo* type;
  const char* name;
  size_t offset;
} __Pyx_StructField;
typedef struct {
  __Pyx_StructField* field;
  size_t parent_offset;
} __Pyx_BufFmt_StackElem;
typedef struct {
  __Pyx_StructField root;
  __Pyx_BufFmt_StackElem* head;
  size_t fmt_offset;
  size_t new_count, enc_count;
  size_t struct_alignment;
  int is_complex;
  char enc_type;
  char new_packmode;
  char enc_packmode;
  char is_valid_array;
} __Pyx_BufFmt_Context;

/* Atomics.proto */
#include <pythread.h>
#ifndef CYTHON_ATOMICS
    #define CYTHON_ATOMICS 1
#endif
#define __pyx_atomic_int_type int
#if CYTHON_ATOMICS && __GNUC__ >= 4 && (__GNUC_MINOR__ > 1 ||\
                    (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL >= 2)) &&\
                    !defined(__i386__)
    #define __pyx_atomic_incr_aligned(value, lock) __sync_fetch_and_add(value, 1)
    #define __pyx_atomic_decr_aligned(value, lock) __sync_fetch_and_sub(value, 1)
    #ifdef __PYX_DEBUG_ATOMICS
        #warning "Using GNU atomics"
    #endif
#elif CYTHON_ATOMICS && defined(_MSC_VER) && 0
    #include <Windows.h>
    #undef __pyx_atomic_int_type
    #define __pyx_atomic_int_type LONG
    #define __pyx_atomic_incr_aligned(value, lock) InterlockedIncrement(value)
    #define __pyx_atomic_decr_aligned(value, lock) InterlockedDecrement(value)
    #ifdef __PYX_DEBUG_ATOMICS
        #pragma message ("Using MSVC atomics")
    #endif
#elif CYTHON_ATOMICS && (defined(__ICC) || defined(__INTEL_COMPILER)) && 0
    #define __pyx_atomic_incr_aligned(value, lock) _InterlockedIncrement(value)
    #define __pyx_atomic_decr_aligned(value, lock) _InterlockedDecrement(value)
    #ifdef __PYX_DEBUG_ATOMICS
        #warning "Using Intel atomics"
    #endif
#else
    #undef CYTHON_ATOMICS
    #define CYTHON_ATOMICS 0
    #ifdef __PYX_DEBUG_ATOMICS
        #warning "Not using atomics"
    #endif
#endif
typedef volatile __pyx_atomic_int_type __pyx_atomic_int;
#if CYTHON_ATOMICS
    #define __pyx_add_acquisition_count(memview)\
             __pyx_atomic_incr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
    #define __pyx_sub_acquisition_count(memview)\
            __pyx_atomic_decr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
#else
    #define __pyx_add_acquisition_count(memview)\
            __pyx_add_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
    #define __pyx_sub_acquisition_count(memview)\
            __pyx_sub_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
#endif

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

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


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

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

/* "memory.pxd":30
 *                                  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":32
 *     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":34
 *     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":36
 *     cpdef copy_to_host_async(self, mem, size_t size, stream=?)
 *     cpdef memset(self, int value, size_t size)
 *     cpdef memset_async(self, int value, size_t size, stream=?)             # <<<<<<<<<<<<<<
 * 
 * 
 */
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_memset_async {
  int __pyx_n;
  PyObject *stream;
};

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* "cupy/core/core.pxd":49
 * 
 *     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":51
 *     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":53
 *     cpdef ndarray std(self, axis=*, dtype=*, out=*, ddof=*,
 *                       keepdims=*)
 *     cpdef ndarray prod(self, axis=*, dtype=*, out=*, keepdims=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray all(self, axis=*, out=*, keepdims=*)
 *     cpdef ndarray any(self, axis=*, out=*, keepdims=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_prod {
  int __pyx_n;
  PyObject *axis;
  PyObject *dtype;
  PyObject *out;
  PyObject *keepdims;
};

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


/* "memory.pxd":7
 * 
 * 
 * cdef class Chunk:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_6memory_Chunk {
  PyObject_HEAD
  struct __pyx_obj_4cupy_4cuda_6device_Device *device;
  PyObject *mem;
  size_t ptr;
  Py_ssize_t offset;
  Py_ssize_t size;
  PyObject *stream_ptr;
  struct __pyx_obj_4cupy_4cuda_6memory_Chunk *prev;
  struct __pyx_obj_4cupy_4cuda_6memory_Chunk *next;
};


/* "memory.pxd":19
 *         public Chunk next
 * 
 * cdef class MemoryPointer:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *__pyx_vtab;
  struct __pyx_obj_4cupy_4cuda_6device_Device *device;
  PyObject *mem;
  size_t ptr;
};


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


/* "memory.pxd":79
 *     cpdef Chunk _merge(self, Chunk head, Chunk remaining)
 * 
 * cdef class MemoryPool:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPool *__pyx_vtab;
  PyObject *_pools;
};


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


/* "View.MemoryView":103
 * 
 * @cname("__pyx_array")
 * cdef class array:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_array_obj {
  PyObject_HEAD
  struct __pyx_vtabstruct_array *__pyx_vtab;
  char *data;
  Py_ssize_t len;
  char *format;
  int ndim;
  Py_ssize_t *_shape;
  Py_ssize_t *_strides;
  Py_ssize_t itemsize;
  PyObject *mode;
  PyObject *_format;
  void (*callback_free_data)(void *);
  int free_data;
  int dtype_is_object;
};


/* "View.MemoryView":277
 * 
 * @cname('__pyx_MemviewEnum')
 * cdef class Enum(object):             # <<<<<<<<<<<<<<
 *     cdef object name
 *     def __init__(self, name):
 */
struct __pyx_MemviewEnum_obj {
  PyObject_HEAD
  PyObject *name;
};


/* "View.MemoryView":328
 * 
 * @cname('__pyx_memoryview')
 * cdef class memoryview(object):             # <<<<<<<<<<<<<<
 * 
 *     cdef object obj
 */
struct __pyx_memoryview_obj {
  PyObject_HEAD
  struct __pyx_vtabstruct_memoryview *__pyx_vtab;
  PyObject *obj;
  PyObject *_size;
  PyObject *_array_interface;
  PyThread_type_lock lock;
  __pyx_atomic_int acquisition_count[2];
  __pyx_atomic_int *acquisition_count_aligned_p;
  Py_buffer view;
  int flags;
  int dtype_is_object;
  __Pyx_TypeInfo *typeinfo;
};


/* "View.MemoryView":953
 * 
 * @cname('__pyx_memoryviewslice')
 * cdef class _memoryviewslice(memoryview):             # <<<<<<<<<<<<<<
 *     "Internal class for passing memoryview slices to Python"
 * 
 */
struct __pyx_memoryviewslice_obj {
  struct __pyx_memoryview_obj __pyx_base;
  __Pyx_memviewslice from_slice;
  PyObject *from_object;
  PyObject *(*to_object_func)(char *);
  int (*to_dtype_func)(char *, PyObject *);
};



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

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


/* "memory.pxd":19
 *         public Chunk next
 * 
 * cdef class MemoryPointer:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

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


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

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


/* "memory.pxd":79
 *     cpdef Chunk _merge(self, Chunk head, Chunk remaining)
 * 
 * cdef class MemoryPool:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


/* "View.MemoryView":103
 * 
 * @cname("__pyx_array")
 * cdef class array:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_array {
  PyObject *(*get_memview)(struct __pyx_array_obj *);
};
static struct __pyx_vtabstruct_array *__pyx_vtabptr_array;


/* "View.MemoryView":328
 * 
 * @cname('__pyx_memoryview')
 * cdef class memoryview(object):             # <<<<<<<<<<<<<<
 * 
 *     cdef object obj
 */

struct __pyx_vtabstruct_memoryview {
  char *(*get_item_pointer)(struct __pyx_memoryview_obj *, PyObject *);
  PyObject *(*is_slice)(struct __pyx_memoryview_obj *, PyObject *);
  PyObject *(*setitem_slice_assignment)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
  PyObject *(*setitem_slice_assign_scalar)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *);
  PyObject *(*setitem_indexed)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
  PyObject *(*convert_item_to_object)(struct __pyx_memoryview_obj *, char *);
  PyObject *(*assign_item_from_object)(struct __pyx_memoryview_obj *, char *, PyObject *);
};
static struct __pyx_vtabstruct_memoryview *__pyx_vtabptr_memoryview;


/* "View.MemoryView":953
 * 
 * @cname('__pyx_memoryviewslice')
 * cdef class _memoryviewslice(memoryview):             # <<<<<<<<<<<<<<
 *     "Internal class for passing memoryview slices to Python"
 * 
 */

struct __pyx_vtabstruct__memoryviewslice {
  struct __pyx_vtabstruct_memoryview __pyx_base;
};
static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice;

/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          if (acquire_gil) {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
              PyGILState_Release(__pyx_gilstate_save);\
          } else {\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext()\
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    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);
}
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

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

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

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

/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

/* ParseKeywords.proto */
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
    const char* function_name);

/* RaiseArgTupleInvalid.proto */
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

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

/* PyObjectCall.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = PyThreadState_GET();
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#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);
#else
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

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

/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
#endif

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#endif

/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

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

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

/* BytesEquals.proto */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

/* UnicodeEquals.proto */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

/* StrEquals.proto */
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif

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

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

/* ListCompAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len)) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif

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

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

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

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

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

/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
#endif

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

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

/* 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 CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

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

/* 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 CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);

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

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

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

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

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

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

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

/* ArgTypeTest.proto */
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact);

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

/* DictGetItem.proto */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    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;
}
#else
    #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#endif

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

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

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

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

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

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

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

/* pyfrozenset_new.proto */
static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) {
    if (it) {
        PyObject* result;
#if CYTHON_COMPILING_IN_PYPY
        PyObject* args;
        args = PyTuple_Pack(1, it);
        if (unlikely(!args))
            return NULL;
        result = PyObject_Call((PyObject*)&PyFrozenSet_Type, args, NULL);
        Py_DECREF(args);
        return result;
#else
        if (PyFrozenSet_CheckExact(it)) {
            Py_INCREF(it);
            return it;
        }
        result = PyFrozenSet_New(it);
        if (unlikely(!result))
            return NULL;
        if (likely(PySet_GET_SIZE(result)))
            return result;
        Py_DECREF(result);
#endif
    }
#if CYTHON_USE_TYPE_SLOTS
    return PyFrozenSet_Type.tp_new(&PyFrozenSet_Type, __pyx_empty_tuple, NULL);
#else
    return PyObject_Call((PyObject*)&PyFrozenSet_Type, __pyx_empty_tuple, NULL);
#endif
}

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

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

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

/* PyObjectSetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL)
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
    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);
}
#else
#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif

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

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

/* BufferFormatCheck.proto */
static CYTHON_INLINE int  __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
    __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
                              __Pyx_BufFmt_StackElem* stack,
                              __Pyx_TypeInfo* type);

/* MemviewSliceInit.proto */
#define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d
#define __Pyx_MEMVIEW_DIRECT   1
#define __Pyx_MEMVIEW_PTR      2
#define __Pyx_MEMVIEW_FULL     4
#define __Pyx_MEMVIEW_CONTIG   8
#define __Pyx_MEMVIEW_STRIDED  16
#define __Pyx_MEMVIEW_FOLLOW   32
#define __Pyx_IS_C_CONTIG 1
#define __Pyx_IS_F_CONTIG 2
static int __Pyx_init_memviewslice(
                struct __pyx_memoryview_obj *memview,
                int ndim,
                __Pyx_memviewslice *memviewslice,
                int memview_is_new_reference);
static CYTHON_INLINE int __pyx_add_acquisition_count_locked(
    __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
static CYTHON_INLINE int __pyx_sub_acquisition_count_locked(
    __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
#define __pyx_get_slice_count_pointer(memview) (memview->acquisition_count_aligned_p)
#define __pyx_get_slice_count(memview) (*__pyx_get_slice_count_pointer(memview))
#define __PYX_INC_MEMVIEW(slice, have_gil) __Pyx_INC_MEMVIEW(slice, have_gil, __LINE__)
#define __PYX_XDEC_MEMVIEW(slice, have_gil) __Pyx_XDEC_MEMVIEW(slice, have_gil, __LINE__)
static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int);
static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int);

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

/* ListExtend.proto */
static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject* none = _PyList_Extend((PyListObject*)L, v);
    if (unlikely(!none))
        return -1;
    Py_DECREF(none);
    return 0;
#else
    return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
#endif
}

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

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

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

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

static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *); /*proto*/
/* decode_c_string_utf16.proto */
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = 0;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = -1;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = 1;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}

/* decode_c_string.proto */
static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
         const char* cstring, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));

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

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

static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
/* ForceInitThreads.proto */
#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

/* NoFastGil.proto */
#define __Pyx_PyGILState_Ensure PyGILState_Ensure
#define __Pyx_PyGILState_Release PyGILState_Release
#define __Pyx_FastGIL_Remember()
#define __Pyx_FastGIL_Forget()
#define __Pyx_FastGilFuncInit()

/* None.proto */
static CYTHON_INLINE long __Pyx_div_long(long, long);

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

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

/* SetVTable.proto */
static int __Pyx_SetVtable(PyObject *dict, void *vtable);

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

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

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

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

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

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

/* CLineInTraceback.proto */
static int __Pyx_CLineForTraceback(int c_line);

/* CodeObjectCache.proto */
typedef struct {
    PyCodeObject* code_object;
    int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

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

#if PY_MAJOR_VERSION < 3
    static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
    static void __Pyx_ReleaseBuffer(Py_buffer *view);
#else
    #define __Pyx_GetBuffer PyObject_GetBuffer
    #define __Pyx_ReleaseBuffer PyBuffer_Release
#endif


/* BufferStructDeclare.proto */
typedef struct {
  Py_ssize_t shape, strides, suboffsets;
} __Pyx_Buf_DimInfo;
typedef struct {
  size_t refcount;
  Py_buffer pybuffer;
} __Pyx_Buffer;
typedef struct {
  __Pyx_Buffer *rcbuffer;
  char *data;
  __Pyx_Buf_DimInfo diminfo[8];
} __Pyx_LocalBuf_ND;

/* None.proto */
static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0};
static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1};

/* MemviewSliceIsContig.proto */
static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs,
                                        char order, int ndim);

/* OverlappingSlices.proto */
static int __pyx_slices_overlap(__Pyx_memviewslice *slice1,
                                __Pyx_memviewslice *slice2,
                                int ndim, size_t itemsize);

/* Capsule.proto */
static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig);

/* CppExceptionConversion.proto */
#ifndef __Pyx_CppExn2PyErr
#include <new>
#include <typeinfo>
#include <stdexcept>
#include <ios>
static void __Pyx_CppExn2PyErr() {
  try {
    if (PyErr_Occurred())
      ; // let the latest Python exn pass through and ignore the current one
    else
      throw;
  } catch (const std::bad_alloc& exn) {
    PyErr_SetString(PyExc_MemoryError, exn.what());
  } catch (const std::bad_cast& exn) {
    PyErr_SetString(PyExc_TypeError, exn.what());
  } catch (const std::bad_typeid& exn) {
    PyErr_SetString(PyExc_TypeError, exn.what());
  } catch (const std::domain_error& exn) {
    PyErr_SetString(PyExc_ValueError, exn.what());
  } catch (const std::invalid_argument& exn) {
    PyErr_SetString(PyExc_ValueError, exn.what());
  } catch (const std::ios_base::failure& exn) {
    PyErr_SetString(PyExc_IOError, exn.what());
  } catch (const std::out_of_range& exn) {
    PyErr_SetString(PyExc_IndexError, exn.what());
  } catch (const std::overflow_error& exn) {
    PyErr_SetString(PyExc_OverflowError, exn.what());
  } catch (const std::range_error& exn) {
    PyErr_SetString(PyExc_ArithmeticError, exn.what());
  } catch (const std::underflow_error& exn) {
    PyErr_SetString(PyExc_ArithmeticError, exn.what());
  } catch (const std::exception& exn) {
    PyErr_SetString(PyExc_RuntimeError, exn.what());
  }
  catch (...)
  {
    PyErr_SetString(PyExc_RuntimeError, "Unknown exception");
  }
}
#endif

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

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

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

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

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

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

/* MemviewSliceCopyTemplate.proto */
static __Pyx_memviewslice
__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
                                 const char *mode, int ndim,
                                 size_t sizeof_dtype, int contig_flag,
                                 int dtype_is_object);

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

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

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

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

/* CoroutineBase.proto */
typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, 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;
    int resume_label;
    char is_running;
} __pyx_CoroutineObject;
static __pyx_CoroutineObject *__Pyx__Coroutine_New(
    PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *closure,
    PyObject *name, PyObject *qualname, PyObject *module_name);
static int __Pyx_Coroutine_clear(PyObject *self);
#if 1 || PY_VERSION_HEX < 0x030300B0
static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue);
#else
#define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue)
#endif

/* 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, closure, name, qualname, module_name)\
    __Pyx__Coroutine_New(__pyx_GeneratorType, body, closure, name, qualname, module_name)
static PyObject *__Pyx_Generator_Next(PyObject *self);
static int __pyx_Generator_init(void);

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

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

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

/* ObjectToMemviewSlice.proto */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_int(PyObject *);

/* ObjectToMemviewSlice.proto */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_int(PyObject *);

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

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

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

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

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

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

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

static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_tolist(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_tofile(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_fid, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tofile *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_dump(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_file, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_dumps(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_astype(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_copy(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_fill(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray__reshape(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  __pyx_v_shape, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray__transpose(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  __pyx_v_axes, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_swapaxes(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, Py_ssize_t __pyx_v_axis1, Py_ssize_t __pyx_v_axis2, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_flatten(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_ravel(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_squeeze(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_squeeze *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_take(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_indices, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_take *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_repeat(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_repeats, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_repeat *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_choose(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_choices, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_choose *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_diagonal(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_diagonal *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_max(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_max *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_argmax(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmax *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_min(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_min *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_argmin(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmin *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_clip(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_clip *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_trace(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_trace *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_sum(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sum *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_mean(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_mean *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_var(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_var *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_std(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_std *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_prod(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_prod *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_all(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_all *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_any(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_any *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_conj(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_get(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_get *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_set(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_arr, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_reduced_view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_reduced_view *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__update_c_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__update_f_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__update_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__set_shape_and_strides(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  &__pyx_v_shape, std::vector<Py_ssize_t>  &__pyx_v_strides, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4cuda_8function_CPointer *__pyx_f_4cupy_4core_4core_7ndarray_get_pointer(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto*/
static struct __pyx_obj_4cupy_4cuda_8function_CPointer *__pyx_f_4cupy_4core_4core_7Indexer_get_pointer(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self); /* proto*/
static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self); /* proto*/
static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto*/
static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj); /* proto*/
static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src); /* proto*/
static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value); /* proto*/
static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto*/
static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/

/* Module declarations from 'libcpp' */

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

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

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

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

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

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

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

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

/* Module declarations from '__builtin__' */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* Module declarations from '__builtin__' */

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

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

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

/* Module declarations from '__builtin__' */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* Module declarations from 'cpython' */

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

/* Module declarations from 'cython' */

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

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

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

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

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

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

/* Module declarations from 'cupy.core.core' */
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_ndarray = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_Indexer = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_CArray = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_CIndexer = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_ParameterInfo = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_ElementwiseKernel = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_broadcast = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_1_genexpr = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_2___init__ = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_3_genexpr = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_4_genexpr = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_6_genexpr = 0;
static PyTypeObject *__pyx_array_type = 0;
static PyTypeObject *__pyx_MemviewEnum_type = 0;
static PyTypeObject *__pyx_memoryview_type = 0;
static PyTypeObject *__pyx_memoryviewslice_type = 0;
static PyObject *__pyx_v_4cupy_4core_4core_newaxis = 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__cuda_path = 0;
static PyObject *__pyx_v_4cupy_4core_4core__typenames_base = 0;
static PyObject *__pyx_v_4cupy_4core_4core__all_type_chars = 0;
static PyObject *__pyx_v_4cupy_4core_4core__typenames = 0;
static PyObject *__pyx_v_4cupy_4core_4core__python_scalar_type = 0;
static PyObject *__pyx_v_4cupy_4core_4core__numpy_scalar_type = 0;
static PyObject *__pyx_v_4cupy_4core_4core__python_scalar_type_set = 0;
static PyObject *__pyx_v_4cupy_4core_4core__numpy_scalar_type_set = 0;
static PyObject *__pyx_v_4cupy_4core_4core__kind_score = 0;
static PyObject *__pyx_v_4cupy_4core_4core__python_type_to_numpy_type = 0;
static PyObject *__pyx_v_4cupy_4core_4core__id = 0;
static PyObject *__pyx_v_4cupy_4core_4core__divmod_float = 0;
static PyObject *__pyx_v_4cupy_4core_4core__min_max_preamble = 0;
static PyObject *__pyx_v_4cupy_4core_4core__argmin = 0;
static PyObject *__pyx_v_4cupy_4core_4core__argmax = 0;
static Py_ssize_t __pyx_v_4cupy_4core_4core_PY_SSIZE_T_MAX;
static PyObject *__pyx_v_4cupy_4core_4core__concatenate_kernel_one = 0;
static PyObject *__pyx_v_4cupy_4core_4core__concatenate_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__take_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__take_kernel_0axis = 0;
static PyObject *__pyx_v_4cupy_4core_4core__choose_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__choose_clip_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__scatter_update_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__scatter_add_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__scatter_update_mask_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__scatter_add_mask_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__getitem_mask_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__cuda_runtime_version = 0;
static PyObject *__pyx_v_4cupy_4core_4core__tensordot_core_mul_sum = 0;
static PyObject *__pyx_v_4cupy_4core_4core__var_core = 0;
static PyObject *__pyx_v_4cupy_4core_4core__var_core_out = 0;
static PyObject *__pyx_v_4cupy_4core_4core__mean = 0;
static PyObject *generic = 0;
static PyObject *strided = 0;
static PyObject *indirect = 0;
static PyObject *contiguous = 0;
static PyObject *indirect_contiguous = 0;
static int __pyx_memoryview_thread_locks_used;
static PyThread_type_lock __pyx_memoryview_thread_locks[8];
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_ascontiguousarray(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray *__pyx_optional_args); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4cupy_4core_4core__should_use_rop(PyObject *, PyObject *); /*proto*/
static std::vector<Py_ssize_t>  __pyx_f_4cupy_4core_4core__get_strides_for_nocopy_reshape(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t>  &, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_header_dir_path(int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_header_source(int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_cuda_path(int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_f_4cupy_4core_4core_compile_with_cache(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_simple_elementwise_kernel(PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__get_simple_elementwise_kernel *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__python_scalar_to_numpy_scalar(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_typename(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__preprocess_args(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_args_info(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_kernel_params(PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__reduce_dims(PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__broadcast(PyObject *, PyObject *, int); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_out_args(PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_out_args_with_params(PyObject *, PyObject *, PyObject *, PyObject *, struct __pyx_opt_args_4cupy_4core_4core__get_out_args_with_params *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__guess_routine_from_in_types(PyObject *, PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__guess_routine_from_dtype(PyObject *, PyObject *); /*proto*/
static int __pyx_f_4cupy_4core_4core__check_should_use_min_scalar(PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__guess_routine(PyObject *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_create_ufunc(PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_create_ufunc *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_simple_reduction_kernel(PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_axis(PyObject *, Py_ssize_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_out_shape(PyObject *, PyObject *, PyObject *, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_trans_args(PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_inout_args(PyObject *, PyObject *, struct __pyx_obj_4cupy_4core_4core_Indexer *, struct __pyx_obj_4cupy_4core_4core_Indexer *, PyObject *, PyObject *, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_create_reduction_func(PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_create_reduction_func *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_array(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_array *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_asfortranarray(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_asfortranarray *__pyx_optional_args); /*proto*/
static std::vector<Py_ssize_t>  __pyx_f_4cupy_4core_4core_normalize_axis_tuple(PyObject *, Py_ssize_t, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_moveaxis(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_rollaxis(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_rollaxis *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_broadcast_to(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__repeat(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__repeat *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_concatenate_method(PyObject *, int, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_concatenate(PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static Py_ssize_t __pyx_f_4cupy_4core_4core_size(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_size *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__create_bit_op(PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__create_bit_op *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__prepare_mask_indexing_single(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__getitem_mask_single(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, int, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__take(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__take *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__scatter_op_single(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__scatter_op_single *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__scatter_op_mask_single(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, Py_ssize_t, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__scatter_op(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__diagonal(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__diagonal *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__prepare_multiple_array_indexing(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__getitem_multiple(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_dot(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_dot *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__get_all_addresses(size_t, std::vector<size_t>  &, std::vector<size_t>  &, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__mat_ptrs(struct __pyx_obj_4cupy_4core_4core_ndarray *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_matmul(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_matmul *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_tensordot_core(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, Py_ssize_t, Py_ssize_t, std::vector<Py_ssize_t> , int __pyx_skip_dispatch); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4cupy_4core_4core__mat_to_cublas_contiguous(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, int __pyx_skip_dispatch); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4cupy_4core_4core__to_cublas_vector(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_create_comparison(PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_create_comparison *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_create_arithmetic(PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__var(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__var *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__std(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__std *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_scan(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_scan *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core___pyx_unpickle_Indexer__set_state(struct __pyx_obj_4cupy_4core_4core_Indexer *, PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core___pyx_unpickle_ParameterInfo__set_state(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *, PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core___pyx_unpickle_ElementwiseKernel__set_state(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *, PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core___pyx_unpickle_broadcast__set_state(struct __pyx_obj_4cupy_4core_4core_broadcast *, PyObject *); /*proto*/
static std::vector<Py_ssize_t>  __pyx_convert_vector_from_py_Py_ssize_t(PyObject *); /*proto*/
static std::vector<size_t>  __pyx_convert_vector_from_py_size_t(PyObject *); /*proto*/
static PyObject *__pyx_convert_vector_to_py_Py_ssize_t(const std::vector<Py_ssize_t>  &); /*proto*/
static PyObject *__pyx_convert_vector_to_py_size_t(const std::vector<size_t>  &); /*proto*/
static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/
static void *__pyx_align_pointer(void *, size_t); /*proto*/
static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/
static CYTHON_INLINE int __pyx_memoryview_check(PyObject *); /*proto*/
static PyObject *_unellipsify(PyObject *, int); /*proto*/
static PyObject *assert_direct_dimensions(Py_ssize_t *, int); /*proto*/
static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *, PyObject *); /*proto*/
static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int, int); /*proto*/
static char *__pyx_pybuffer_index(Py_buffer *, char *, Py_ssize_t, Py_ssize_t); /*proto*/
static int __pyx_memslice_transpose(__Pyx_memviewslice *); /*proto*/
static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice, int, PyObject *(*)(char *), int (*)(char *, PyObject *), int); /*proto*/
static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *); /*proto*/
static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
static Py_ssize_t abs_py_ssize_t(Py_ssize_t); /*proto*/
static char __pyx_get_best_slice_order(__Pyx_memviewslice *, int); /*proto*/
static void _copy_strided_to_strided(char *, Py_ssize_t *, char *, Py_ssize_t *, Py_ssize_t *, Py_ssize_t *, int, size_t); /*proto*/
static void copy_strided_to_strided(__Pyx_memviewslice *, __Pyx_memviewslice *, int, size_t); /*proto*/
static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *, int); /*proto*/
static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *, Py_ssize_t *, Py_ssize_t, int, char); /*proto*/
static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *, __Pyx_memviewslice *, char, int); /*proto*/
static int __pyx_memoryview_err_extents(int, Py_ssize_t, Py_ssize_t); /*proto*/
static int __pyx_memoryview_err_dim(PyObject *, char *, int); /*proto*/
static int __pyx_memoryview_err(PyObject *, char *); /*proto*/
static int __pyx_memoryview_copy_contents(__Pyx_memviewslice, __Pyx_memviewslice, int, int, int); /*proto*/
static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *, int, int); /*proto*/
static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *, int, int, int); /*proto*/
static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
static void __pyx_memoryview_refcount_objects_in_slice(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size_t, void *, int); /*proto*/
static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/
static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *, PyObject *); /*proto*/
static __Pyx_TypeInfo __Pyx_TypeInfo_Py_ssize_t = { "Py_ssize_t", NULL, sizeof(Py_ssize_t), { 0 }, 0, IS_UNSIGNED(Py_ssize_t) ? 'U' : 'I', IS_UNSIGNED(Py_ssize_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_int = { "int", NULL, sizeof(int), { 0 }, 0, IS_UNSIGNED(int) ? 'U' : 'I', IS_UNSIGNED(int), 0 };
#define __Pyx_MODULE_NAME "cupy.core.core"
int __pyx_module_is_main_cupy__core__core = 0;

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

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

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

  /* "cupy/core/core.pyx":38
 *     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, 38, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 38, __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, 38, __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":35
 * 
 * @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":46
 *     class IndexOrValueError(IndexError, ValueError):
 * 
 *         def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *             super(IndexOrValueError, self).__init__(*args, **kwargs)
 * 
 */

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

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

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

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

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.IndexOrValueError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

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

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

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

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

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

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

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

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

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

  /* "cupy/core/core.pyx":91
 *             if x < 0:
 *                 raise ValueError('Negative dimensions are not allowed')
 *         self.dtype = numpy.dtype(dtype)             # <<<<<<<<<<<<<<
 *         self.size = internal.prod_ssize_t(self._shape)
 * 
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 91, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 91, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_dtype};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_dtype};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 91, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_dtype);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
  }
  __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;

  /* "cupy/core/core.pyx":92
 *                 raise ValueError('Negative dimensions are not allowed')
 *         self.dtype = numpy.dtype(dtype)
 *         self.size = internal.prod_ssize_t(self._shape)             # <<<<<<<<<<<<<<
 * 
 *         if memptr is None:
 */
  __pyx_v_self->size = __pyx_f_4cupy_4core_8internal_prod_ssize_t(__pyx_v_self->_shape, 0, NULL);

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

    /* "cupy/core/core.pyx":95
 * 
 *         if memptr is None:
 *             self.data = memory.alloc(self.size * self.dtype.itemsize)             # <<<<<<<<<<<<<<
 *         else:
 *             self.data = memptr
 */
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 95, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = PyNumber_Multiply(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 95, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 95, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_5, 0)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 95, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_9);
    __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_9);
    __pyx_t_9 = 0;

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

  /* "cupy/core/core.pyx":97
 *             self.data = memory.alloc(self.size * self.dtype.itemsize)
 *         else:
 *             self.data = memptr             # <<<<<<<<<<<<<<
 *         self.base = None
 * 
 */
  /*else*/ {
    if (!(likely(((__pyx_v_memptr) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_memptr, __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer))))) __PYX_ERR(0, 97, __pyx_L1_error)
    __pyx_t_9 = __pyx_v_memptr;
    __Pyx_INCREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_9);
    __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_9);
    __pyx_t_9 = 0;
  }
  __pyx_L6:;

  /* "cupy/core/core.pyx":98
 *         else:
 *             self.data = memptr
 *         self.base = None             # <<<<<<<<<<<<<<
 * 
 *         if order in ('C', None):
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->base);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->base));
  __pyx_v_self->base = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);

  /* "cupy/core/core.pyx":100
 *         self.base = None
 * 
 *         if order in ('C', None):             # <<<<<<<<<<<<<<
 *             self._strides = internal.get_contiguous_strides(
 *                 self._shape, self.itemsize, is_c_contiguous=True)
 */
  __Pyx_INCREF(__pyx_v_order);
  __pyx_t_9 = __pyx_v_order;
  __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_9, __pyx_n_s_C, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 100, __pyx_L1_error)
  if (!__pyx_t_6) {
  } else {
    __pyx_t_10 = __pyx_t_6;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_8 = PyObject_RichCompare(__pyx_t_9, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 100, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 100, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_10 = __pyx_t_6;
  __pyx_L8_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_6 = (__pyx_t_10 != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":102
 *         if order in ('C', None):
 *             self._strides = internal.get_contiguous_strides(
 *                 self._shape, self.itemsize, is_c_contiguous=True)             # <<<<<<<<<<<<<<
 *             self._c_contiguous = True
 *             self._update_f_contiguity()
 */
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 102, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 102, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "cupy/core/core.pyx":101
 * 
 *         if order in ('C', None):
 *             self._strides = internal.get_contiguous_strides(             # <<<<<<<<<<<<<<
 *                 self._shape, self.itemsize, is_c_contiguous=True)
 *             self._c_contiguous = True
 */
    __pyx_t_2 = __pyx_f_4cupy_4core_8internal_get_contiguous_strides(__pyx_v_self->_shape, __pyx_t_5, 1, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 101, __pyx_L1_error)
    __pyx_v_self->_strides = __pyx_t_2;

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

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

    /* "cupy/core/core.pyx":100
 *         self.base = None
 * 
 *         if order in ('C', None):             # <<<<<<<<<<<<<<
 *             self._strides = internal.get_contiguous_strides(
 *                 self._shape, self.itemsize, is_c_contiguous=True)
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":105
 *             self._c_contiguous = True
 *             self._update_f_contiguity()
 *         elif order == 'F':             # <<<<<<<<<<<<<<
 *             self._strides = internal.get_contiguous_strides(
 *                 self._shape, self.itemsize, is_c_contiguous=False)
 */
  __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_v_order, __pyx_n_s_F, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 105, __pyx_L1_error)
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":107
 *         elif order == 'F':
 *             self._strides = internal.get_contiguous_strides(
 *                 self._shape, self.itemsize, is_c_contiguous=False)             # <<<<<<<<<<<<<<
 *             self._f_contiguous = True
 *             self._update_c_contiguity()
 */
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 107, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

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

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

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

    /* "cupy/core/core.pyx":105
 *             self._c_contiguous = True
 *             self._update_f_contiguity()
 *         elif order == 'F':             # <<<<<<<<<<<<<<
 *             self._strides = internal.get_contiguous_strides(
 *                 self._shape, self.itemsize, is_c_contiguous=False)
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":111
 *             self._update_c_contiguity()
 *         else:
 *             raise TypeError('order not understood')             # <<<<<<<<<<<<<<
 * 
 *     # The definition order of attributes and methods are borrowed from the
 */
  /*else*/ {
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 111, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 111, __pyx_L1_error)
  }
  __pyx_L7:;

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

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

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

  /* "cupy/core/core.pyx":132
 *         """
 *         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, 132, __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, 131, __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, 131, __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, 131, __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, 131, __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":121
 *     # -------------------------------------------------------------------------
 *     @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":144
 *         """
 * 
 *         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":145
 * 
 *         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, 145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __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":144
 *         """
 * 
 *         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":147
 *             return tuple(self._shape)
 * 
 *         def __set__(self, newshape):             # <<<<<<<<<<<<<<
 *             cdef vector.vector[Py_ssize_t] shape, strides
 *             if not cpython.PySequence_Check(newshape):
 */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* "cupy/core/core.pyx":160
 * 
 *     @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":166
 * 
 *         """
 *         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, 166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 166, __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":160
 * 
 *     @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":169
 * 
 *     @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":177
 * 
 *         """
 *         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, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

  /* "cupy/core/core.pyx":180
 * 
 *     @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":189
 * 
 *     @property
 *     def nbytes(self):             # <<<<<<<<<<<<<<
 *         """Size of whole elements in bytes.
 * 
 */

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

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

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

  /* "cupy/core/core.pyx":197
 * 
 *         """
 *         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, 197, __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, 197, __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, 197, __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":189
 * 
 *     @property
 *     def nbytes(self):             # <<<<<<<<<<<<<<
 *         """Size of whole elements in bytes.
 * 
 */

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

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

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

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

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

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

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

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

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

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

  /* "cupy/core/core.pyx":233
 * 
 *         """
 *         return CArray(self)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_CArray), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":225
 *     # -------------------------------------------------------------------------
 *     @property
 *     def cstruct(self):             # <<<<<<<<<<<<<<
 *         """C representation 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.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":240
 *     # TODO(okuta): Implement item
 * 
 *     cpdef tolist(self):             # <<<<<<<<<<<<<<
 *         """Converts the array to a (possibly nested) Python list.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_3tolist(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_tolist(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("tolist", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tolist); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_3tolist)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 240, __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, 240, __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":249
 * 
 *         """
 *         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, 249, __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, 249, __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, 249, __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, 249, __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":240
 *     # TODO(okuta): Implement item
 * 
 *     cpdef tolist(self):             # <<<<<<<<<<<<<<
 *         """Converts the array to a (possibly nested) Python list.
 * 
 */

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

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_2tolist(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("tolist", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray_tolist(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __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":255
 *     # TODO(okuta): Implement tobytes
 * 
 *     cpdef tofile(self, fid, sep='', format='%s'):             # <<<<<<<<<<<<<<
 *         """Writes the array to a file.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_5tofile(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_tofile(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_fid, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tofile *__pyx_optional_args) {
  PyObject *__pyx_v_sep = ((PyObject *)__pyx_kp_s__5);
  PyObject *__pyx_v_format = ((PyObject *)__pyx_kp_s_s);
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("tofile", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_sep = __pyx_optional_args->sep;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_format = __pyx_optional_args->format;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tofile); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_5tofile)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_fid, __pyx_v_sep, __pyx_v_format};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 255, __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, 255, __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, 255, __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, 255, __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":261
 * 
 *         """
 *         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, 261, __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, 261, __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, 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[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, 261, __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, 261, __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, 261, __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":255
 *     # TODO(okuta): Implement tobytes
 * 
 *     cpdef tofile(self, fid, sep='', format='%s'):             # <<<<<<<<<<<<<<
 *         """Writes the array to a file.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.tofile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

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

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

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.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":263
 *         self.get().tofile(fid, sep, format)
 * 
 *     cpdef dump(self, file):             # <<<<<<<<<<<<<<
 *         """Dumps a pickle of the array to a file.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_7dump(PyObject *__pyx_v_self, PyObject *__pyx_v_file); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_dump(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_file, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("dump", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dump); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_7dump)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_file); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 263, __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, 263, __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, 263, __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, 263, __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, 263, __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":270
 * 
 *         """
 *         six.moves.cPickle.dump(self, file, -1)             # <<<<<<<<<<<<<<
 * 
 *     cpdef dumps(self):
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_moves); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_cPickle); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dump); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_2, ((PyObject *)__pyx_v_self), __pyx_v_file, __pyx_int_neg_1};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __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, 270, __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, 270, __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, 270, __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":263
 *         self.get().tofile(fid, sep, format)
 * 
 *     cpdef dump(self, file):             # <<<<<<<<<<<<<<
 *         """Dumps a pickle of the array to a file.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.dump", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_6dump(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_file) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("dump", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray_dump(__pyx_v_self, __pyx_v_file, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 263, __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":272
 *         six.moves.cPickle.dump(self, file, -1)
 * 
 *     cpdef dumps(self):             # <<<<<<<<<<<<<<
 *         """Dumps a pickle of the array to a string."""
 *         return six.moves.cPickle.dumps(self, -1)
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_9dumps(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_dumps(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("dumps", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dumps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_9dumps)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __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, 272, __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":274
 *     cpdef dumps(self):
 *         """Dumps a pickle of the array to a string."""
 *         return six.moves.cPickle.dumps(self, -1)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray astype(
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_moves); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_cPickle); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dumps); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, ((PyObject *)__pyx_v_self), __pyx_int_neg_1};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __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, 274, __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, 274, __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, 274, __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":272
 *         six.moves.cPickle.dump(self, file, -1)
 * 
 *     cpdef dumps(self):             # <<<<<<<<<<<<<<
 *         """Dumps a pickle of the array to a string."""
 *         return six.moves.cPickle.dumps(self, -1)
 */

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

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_8dumps(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("dumps", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray_dumps(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __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":276
 *         return six.moves.cPickle.dumps(self, -1)
 * 
 *     cpdef ndarray astype(             # <<<<<<<<<<<<<<
 *             self, dtype, order='K', casting=None, subok=None, copy=True):
 *         """Casts the array to given data type.
 */

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

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

  /* "cupy/core/core.pyx":276
 *         return six.moves.cPickle.dumps(self, -1)
 * 
 *     cpdef ndarray astype(             # <<<<<<<<<<<<<<
 *             self, dtype, order='K', casting=None, subok=None, copy=True):
 *         """Casts the array to given data type.
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_11astype)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_v_dtype, __pyx_v_order, __pyx_v_casting, __pyx_v_subok, __pyx_v_copy};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 276, __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, 276, __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, 276, __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, 276, __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, 276, __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":307
 * 
 *         # 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 (__pyx_t_8) {

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

    /* "cupy/core/core.pyx":307
 * 
 *         # 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":309
 *         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 (__pyx_t_7) {

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

    /* "cupy/core/core.pyx":309
 *         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":312
 *             raise TypeError('subok is not supported yet')
 * 
 *         if order is None:             # <<<<<<<<<<<<<<
 *             order = 'K'
 *         if order not in ['C', 'F', 'A', 'K']:
 */
  __pyx_t_7 = (__pyx_v_order == Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":313
 * 
 *         if order is None:
 *             order = 'K'             # <<<<<<<<<<<<<<
 *         if order not in ['C', 'F', 'A', 'K']:
 *             raise TypeError('order not understood')
 */
    __Pyx_INCREF(__pyx_n_s_K);
    __Pyx_DECREF_SET(__pyx_v_order, __pyx_n_s_K);

    /* "cupy/core/core.pyx":312
 *             raise TypeError('subok is not supported yet')
 * 
 *         if order is None:             # <<<<<<<<<<<<<<
 *             order = 'K'
 *         if order not in ['C', 'F', 'A', 'K']:
 */
  }

  /* "cupy/core/core.pyx":314
 *         if order is None:
 *             order = 'K'
 *         if order not in ['C', 'F', 'A', 'K']:             # <<<<<<<<<<<<<<
 *             raise TypeError('order not understood')
 * 
 */
  __Pyx_INCREF(__pyx_v_order);
  __pyx_t_1 = __pyx_v_order;
  __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_C, Py_NE)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 314, __pyx_L1_error)
  if (__pyx_t_7) {
  } else {
    __pyx_t_8 = __pyx_t_7;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_F, Py_NE)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 314, __pyx_L1_error)
  if (__pyx_t_7) {
  } else {
    __pyx_t_8 = __pyx_t_7;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_A, Py_NE)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 314, __pyx_L1_error)
  if (__pyx_t_7) {
  } else {
    __pyx_t_8 = __pyx_t_7;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_K, Py_NE)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 314, __pyx_L1_error)
  __pyx_t_8 = __pyx_t_7;
  __pyx_L7_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = (__pyx_t_8 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":315
 *             order = 'K'
 *         if order not in ['C', 'F', 'A', 'K']:
 *             raise TypeError('order not understood')             # <<<<<<<<<<<<<<
 * 
 *         dtype = numpy.dtype(dtype)
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 315, __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, 315, __pyx_L1_error)

    /* "cupy/core/core.pyx":314
 *         if order is None:
 *             order = 'K'
 *         if order not in ['C', 'F', 'A', 'K']:             # <<<<<<<<<<<<<<
 *             raise TypeError('order not understood')
 * 
 */
  }

  /* "cupy/core/core.pyx":317
 *             raise TypeError('order not understood')
 * 
 *         dtype = numpy.dtype(dtype)             # <<<<<<<<<<<<<<
 *         if dtype == self.dtype:
 *             if not copy and (
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); 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_dtype); 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 && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_dtype); 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_dtype};
      __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_dtype};
      __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_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 317, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_dtype);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __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_SET(__pyx_v_dtype, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":318
 * 
 *         dtype = numpy.dtype(dtype)
 *         if dtype == self.dtype:             # <<<<<<<<<<<<<<
 *             if not copy and (
 *                     order == '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, 318, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 318, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_7) {

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

    /* "cupy/core/core.pyx":320
 *         if dtype == self.dtype:
 *             if not copy and (
 *                     order == 'K' or             # <<<<<<<<<<<<<<
 *                     order == 'A' and (self._c_contiguous or
 *                                       self._f_contiguous) or
 */
    __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_order, __pyx_n_s_K, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 320, __pyx_L1_error)
    if (!__pyx_t_9) {
    } else {
      __pyx_t_7 = __pyx_t_9;
      goto __pyx_L13_bool_binop_done;
    }

    /* "cupy/core/core.pyx":321
 *             if not copy and (
 *                     order == 'K' or
 *                     order == 'A' and (self._c_contiguous or             # <<<<<<<<<<<<<<
 *                                       self._f_contiguous) or
 *                     order == 'C' and self._c_contiguous or
 */
    __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_order, __pyx_n_s_A, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 321, __pyx_L1_error)
    if (!__pyx_t_9) {
      goto __pyx_L16_next_or;
    } else {
    }
    __pyx_t_9 = (__pyx_v_self->_c_contiguous != 0);
    if (!__pyx_t_9) {
    } else {
      __pyx_t_7 = __pyx_t_9;
      goto __pyx_L13_bool_binop_done;
    }

    /* "cupy/core/core.pyx":322
 *                     order == 'K' or
 *                     order == 'A' and (self._c_contiguous or
 *                                       self._f_contiguous) or             # <<<<<<<<<<<<<<
 *                     order == 'C' and self._c_contiguous or
 *                     order == 'F' and self._f_contiguous):
 */
    __pyx_t_9 = (__pyx_v_self->_f_contiguous != 0);
    if (!__pyx_t_9) {
    } else {
      __pyx_t_7 = __pyx_t_9;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_L16_next_or:;

    /* "cupy/core/core.pyx":323
 *                     order == 'A' and (self._c_contiguous or
 *                                       self._f_contiguous) or
 *                     order == 'C' and self._c_contiguous or             # <<<<<<<<<<<<<<
 *                     order == 'F' and self._f_contiguous):
 *                 return self
 */
    __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_order, __pyx_n_s_C, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 323, __pyx_L1_error)
    if (!__pyx_t_9) {
      goto __pyx_L19_next_or;
    } else {
    }
    __pyx_t_9 = (__pyx_v_self->_c_contiguous != 0);
    if (!__pyx_t_9) {
    } else {
      __pyx_t_7 = __pyx_t_9;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_L19_next_or:;

    /* "cupy/core/core.pyx":324
 *                                       self._f_contiguous) or
 *                     order == 'C' and self._c_contiguous or
 *                     order == 'F' and self._f_contiguous):             # <<<<<<<<<<<<<<
 *                 return self
 * 
 */
    __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_order, __pyx_n_s_F, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 324, __pyx_L1_error)
    if (__pyx_t_9) {
    } else {
      __pyx_t_7 = __pyx_t_9;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_9 = (__pyx_v_self->_f_contiguous != 0);
    __pyx_t_7 = __pyx_t_9;
    __pyx_L13_bool_binop_done:;

    /* "cupy/core/core.pyx":319
 *         dtype = numpy.dtype(dtype)
 *         if dtype == self.dtype:
 *             if not copy and (             # <<<<<<<<<<<<<<
 *                     order == 'K' or
 *                     order == 'A' and (self._c_contiguous or
 */
    if (__pyx_t_7) {

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

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

    /* "cupy/core/core.pyx":318
 * 
 *         dtype = numpy.dtype(dtype)
 *         if dtype == self.dtype:             # <<<<<<<<<<<<<<
 *             if not copy and (
 *                     order == 'K' or
 */
  }

  /* "cupy/core/core.pyx":327
 *                 return self
 * 
 *         if order == 'A':             # <<<<<<<<<<<<<<
 *             if self._f_contiguous:
 *                 order = 'F'
 */
  __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_order, __pyx_n_s_A, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 327, __pyx_L1_error)
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":328
 * 
 *         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":329
 *         if order == 'A':
 *             if self._f_contiguous:
 *                 order = 'F'             # <<<<<<<<<<<<<<
 *             else:
 *                 order = 'C'
 */
      __Pyx_INCREF(__pyx_n_s_F);
      __Pyx_DECREF_SET(__pyx_v_order, __pyx_n_s_F);

      /* "cupy/core/core.pyx":328
 * 
 *         if order == 'A':
 *             if self._f_contiguous:             # <<<<<<<<<<<<<<
 *                 order = 'F'
 *             else:
 */
      goto __pyx_L23;
    }

    /* "cupy/core/core.pyx":331
 *                 order = 'F'
 *             else:
 *                 order = 'C'             # <<<<<<<<<<<<<<
 *         elif order == 'K':
 *             if self._f_contiguous:
 */
    /*else*/ {
      __Pyx_INCREF(__pyx_n_s_C);
      __Pyx_DECREF_SET(__pyx_v_order, __pyx_n_s_C);
    }
    __pyx_L23:;

    /* "cupy/core/core.pyx":327
 *                 return self
 * 
 *         if order == 'A':             # <<<<<<<<<<<<<<
 *             if self._f_contiguous:
 *                 order = 'F'
 */
    goto __pyx_L22;
  }

  /* "cupy/core/core.pyx":332
 *             else:
 *                 order = 'C'
 *         elif order == 'K':             # <<<<<<<<<<<<<<
 *             if self._f_contiguous:
 *                 order = 'F'
 */
  __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_order, __pyx_n_s_K, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 332, __pyx_L1_error)
  if (__pyx_t_7) {

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

      /* "cupy/core/core.pyx":334
 *         elif order == 'K':
 *             if self._f_contiguous:
 *                 order = 'F'             # <<<<<<<<<<<<<<
 *             elif self._c_contiguous:
 *                 order = 'C'
 */
      __Pyx_INCREF(__pyx_n_s_F);
      __Pyx_DECREF_SET(__pyx_v_order, __pyx_n_s_F);

      /* "cupy/core/core.pyx":333
 *                 order = 'C'
 *         elif order == 'K':
 *             if self._f_contiguous:             # <<<<<<<<<<<<<<
 *                 order = 'F'
 *             elif self._c_contiguous:
 */
      goto __pyx_L24;
    }

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

      /* "cupy/core/core.pyx":336
 *                 order = 'F'
 *             elif self._c_contiguous:
 *                 order = 'C'             # <<<<<<<<<<<<<<
 * 
 *         if order == 'K':
 */
      __Pyx_INCREF(__pyx_n_s_C);
      __Pyx_DECREF_SET(__pyx_v_order, __pyx_n_s_C);

      /* "cupy/core/core.pyx":335
 *             if self._f_contiguous:
 *                 order = 'F'
 *             elif self._c_contiguous:             # <<<<<<<<<<<<<<
 *                 order = 'C'
 * 
 */
    }
    __pyx_L24:;

    /* "cupy/core/core.pyx":332
 *             else:
 *                 order = 'C'
 *         elif order == 'K':             # <<<<<<<<<<<<<<
 *             if self._f_contiguous:
 *                 order = 'F'
 */
  }
  __pyx_L22:;

  /* "cupy/core/core.pyx":338
 *                 order = 'C'
 * 
 *         if order == 'K':             # <<<<<<<<<<<<<<
 *             newarray = ndarray(self.shape, dtype=dtype)
 *             stride_and_index = [
 */
  __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_order, __pyx_n_s_K, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 338, __pyx_L1_error)
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":339
 * 
 *         if order == 'K':
 *             newarray = ndarray(self.shape, dtype=dtype)             # <<<<<<<<<<<<<<
 *             stride_and_index = [
 *                 (abs(s), -i) for i, s in enumerate(self._strides)]
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 339, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 339, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 339, __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, 339, __pyx_L1_error)
    __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 339, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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":340
 *         if order == 'K':
 *             newarray = ndarray(self.shape, dtype=dtype)
 *             stride_and_index = [             # <<<<<<<<<<<<<<
 *                 (abs(s), -i) for i, s in enumerate(self._strides)]
 *             stride_and_index.sort()
 */
    __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 340, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_1 = __pyx_int_0;

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

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

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

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

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

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

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

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

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

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

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

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

  /* "cupy/core/core.pyx":350
 *             newarray._set_shape_and_strides(self._shape, strides)
 *         else:
 *             newarray = ndarray(self.shape, dtype=dtype, order=order)             # <<<<<<<<<<<<<<
 *         elementwise_copy(self, newarray)
 *         return newarray
 */
  /*else*/ {
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 350, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 350, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 350, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 350, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 350, __pyx_L1_error)
    __pyx_t_12 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 350, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_12);
    __pyx_t_12 = 0;
  }
  __pyx_L25:;

  /* "cupy/core/core.pyx":351
 *         else:
 *             newarray = ndarray(self.shape, dtype=dtype, order=order)
 *         elementwise_copy(self, newarray)             # <<<<<<<<<<<<<<
 *         return newarray
 * 
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_newarray)};
    __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 351, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_12);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_newarray)};
    __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 351, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_12);
  } else
  #endif
  {
    __pyx_t_2 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 351, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_2, 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_2, 1+__pyx_t_5, ((PyObject *)__pyx_v_newarray));
    __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_2, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 351, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":352
 *             newarray = ndarray(self.shape, dtype=dtype, order=order)
 *         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":276
 *         return six.moves.cPickle.dumps(self, -1)
 * 
 *     cpdef ndarray astype(             # <<<<<<<<<<<<<<
 *             self, dtype, order='K', casting=None, subok=None, copy=True):
 *         """Casts the array to given data type.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core.ndarray.astype", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_newarray);
  __Pyx_XDECREF(__pyx_v_stride_and_index);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_order);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

    /* "cupy/core/core.pyx":277
 * 
 *     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] = PyDict_GetItem(__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 = PyDict_GetItem(__pyx_kwds, __pyx_n_s_order);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_casting);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_subok);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 276, __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, 276, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.astype", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_10astype(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_dtype, __pyx_v_order, __pyx_v_casting, __pyx_v_subok, __pyx_v_copy);

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_10astype(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype, PyObject *__pyx_v_order, PyObject *__pyx_v_casting, PyObject *__pyx_v_subok, PyObject *__pyx_v_copy) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype __pyx_t_2;
  __Pyx_RefNannySetupContext("astype", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.order = __pyx_v_order;
  __pyx_t_2.casting = __pyx_v_casting;
  __pyx_t_2.subok = __pyx_v_subok;
  __pyx_t_2.copy = __pyx_v_copy;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->astype(__pyx_v_self, __pyx_v_dtype, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __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":356
 *     # TODO(okuta): Implement byteswap
 * 
 *     cpdef ndarray copy(self, order='C'):             # <<<<<<<<<<<<<<
 *         """Returns a copy of the array.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_13copy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_copy(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy *__pyx_optional_args) {
  PyObject *__pyx_v_order = ((PyObject *)__pyx_n_s_C);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_newarray = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  Py_ssize_t __pyx_t_15;
  __Pyx_RefNannySetupContext("copy", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_order = __pyx_optional_args->order;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_13copy)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_order); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 356, __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, 356, __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, 356, __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, 356, __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, 356, __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, 356, __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":376
 * 
 *         """
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return self.astype(self.dtype, copy=True, order=order)
 * 
 */
  __pyx_t_6 = ((__pyx_v_self->size == 0) != 0);
  if (__pyx_t_6) {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_newarray);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_12copy(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_order) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy __pyx_t_2;
  __Pyx_RefNannySetupContext("copy", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.order = __pyx_v_order;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->copy(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 356, __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":391
 *             return newarray
 * 
 *     cpdef ndarray view(self, dtype=None):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_15view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view *__pyx_optional_args) {
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_v = 0;
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_strides = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  std::vector<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, 391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_15view)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 391, __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, 391, __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, 391, __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, 391, __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, 391, __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, 391, __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":408
 *         # Use __new__ instead of __init__ to skip recomputation of contiguity
 *         cdef ndarray v
 *         v = ndarray.__new__(ndarray)             # <<<<<<<<<<<<<<
 *         v.dtype = self.dtype if dtype is None else numpy.dtype(dtype)
 * 
 */
  __pyx_t_1 = __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, 408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray)))) __PYX_ERR(0, 408, __pyx_L1_error)
  __pyx_v_v = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":409
 *         cdef ndarray v
 *         v = ndarray.__new__(ndarray)
 *         v.dtype = self.dtype if dtype is None else numpy.dtype(dtype)             # <<<<<<<<<<<<<<
 * 
 *         if dtype is None:
 */
  __pyx_t_6 = (__pyx_v_dtype == Py_None);
  if ((__pyx_t_6 != 0)) {
    __Pyx_INCREF(__pyx_v_self->dtype);
    __pyx_t_1 = __pyx_v_self->dtype;
  } else {
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 409, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_dtype};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 409, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_dtype};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 409, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 409, __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(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_dtype);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 409, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_1 = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_v->dtype);
  __Pyx_DECREF(__pyx_v_v->dtype);
  __pyx_v_v->dtype = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":411
 *         v.dtype = self.dtype if dtype is None else numpy.dtype(dtype)
 * 
 *         if dtype is None:             # <<<<<<<<<<<<<<
 *             v.size = self.size
 *             v._shape = self._shape
 */
  __pyx_t_6 = (__pyx_v_dtype == Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

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

    /* "cupy/core/core.pyx":413
 *         if dtype is None:
 *             v.size = self.size
 *             v._shape = self._shape             # <<<<<<<<<<<<<<
 *             v._strides = self._strides
 *         else:
 */
    __pyx_t_9 = __pyx_v_self->_shape;
    __pyx_v_v->_shape = __pyx_t_9;

    /* "cupy/core/core.pyx":414
 *             v.size = self.size
 *             v._shape = self._shape
 *             v._strides = self._strides             # <<<<<<<<<<<<<<
 *         else:
 *             shape = list(self._shape)
 */
    __pyx_t_9 = __pyx_v_self->_strides;
    __pyx_v_v->_strides = __pyx_t_9;

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

  /* "cupy/core/core.pyx":416
 *             v._strides = self._strides
 *         else:
 *             shape = list(self._shape)             # <<<<<<<<<<<<<<
 *             strides = list(self._strides)
 *             shape[-1] = shape[-1] * self.dtype.itemsize // v.dtype.itemsize
 */
  /*else*/ {
    __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_shape = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

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

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

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

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

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

    /* "cupy/core/core.pyx":422
 *             v._shape = shape
 *             v._strides = strides
 *             v.size = self.size * self.dtype.itemsize // v.dtype.itemsize             # <<<<<<<<<<<<<<
 * 
 *         v._c_contiguous = self._c_contiguous
 */
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __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, 422, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 422, __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 = __Pyx_PyObject_GetAttrStr(__pyx_v_v->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 422, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_FloorDivide(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __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_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 422, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_v->size = __pyx_t_8;
  }
  __pyx_L3:;

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

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

  /* "cupy/core/core.pyx":426
 *         v._c_contiguous = self._c_contiguous
 *         v._f_contiguous = self._f_contiguous
 *         v.data = self.data             # <<<<<<<<<<<<<<
 *         v.base = self.base if self.base is not None else self
 *         return v
 */
  __pyx_t_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":427
 *         v._f_contiguous = self._f_contiguous
 *         v.data = self.data
 *         v.base = self.base if self.base is not None else self             # <<<<<<<<<<<<<<
 *         return v
 * 
 */
  __pyx_t_7 = (((PyObject *)__pyx_v_self->base) != Py_None);
  if ((__pyx_t_7 != 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":428
 *         v.data = self.data
 *         v.base = self.base if self.base is not None else self
 *         return v             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement getfield
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_v));
  __pyx_r = __pyx_v_v;
  goto __pyx_L0;

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

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.view", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_strides);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_14view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view __pyx_t_2;
  __Pyx_RefNannySetupContext("view", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->view(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 391, __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":433
 *     # TODO(okuta): Implement setflags
 * 
 *     cpdef fill(self, value):             # <<<<<<<<<<<<<<
 *         """Fills the array with a scalar value.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_17fill(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_fill(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  size_t __pyx_t_8;
  __Pyx_RefNannySetupContext("fill", 0);
  __Pyx_INCREF(__pyx_v_value);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_fill); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_17fill)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 433, __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, 433, __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, 433, __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, 433, __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, 433, __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":442
 * 
 *         """
 *         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, 442, __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, 442, __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 == -1)) __PYX_ERR(0, 442, __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":443
 *         """
 *         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, 443, __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, 443, __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, 443, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_7) {

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

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

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

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

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

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

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.fill", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_16fill(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("fill", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray_fill(__pyx_v_self, __pyx_v_value, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __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":456
 *     # Shape manipulation
 *     # -------------------------------------------------------------------------
 *     cpdef ndarray _reshape(self, vector.vector[Py_ssize_t] shape):             # <<<<<<<<<<<<<<
 *         cdef vector.vector[Py_ssize_t] strides
 *         cdef ndarray newarray
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_19_reshape(PyObject *__pyx_v_self, PyObject *__pyx_arg_shape); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray__reshape(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  __pyx_v_shape, int __pyx_skip_dispatch) {
  std::vector<Py_ssize_t>  __pyx_v_strides;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_newarray = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  std::vector<Py_ssize_t>  __pyx_t_7;
  int __pyx_t_8;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides __pyx_t_9;
  __Pyx_RefNannySetupContext("_reshape", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reshape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_19_reshape)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 456, __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, 456, __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, 456, __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, 456, __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, 456, __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, 456, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 456, __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":459
 *         cdef vector.vector[Py_ssize_t] strides
 *         cdef ndarray newarray
 *         shape = internal.infer_unknown_dimension(shape, self.size)             # <<<<<<<<<<<<<<
 *         if internal.vector_equal(shape, self._shape):
 *             return self.view()
 */
  __pyx_t_7 = __pyx_f_4cupy_4core_8internal_infer_unknown_dimension(__pyx_v_shape, __pyx_v_self->size, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 459, __pyx_L1_error)
  __pyx_v_shape = __pyx_t_7;

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

    /* "cupy/core/core.pyx":461
 *         shape = internal.infer_unknown_dimension(shape, self.size)
 *         if internal.vector_equal(shape, self._shape):
 *             return self.view()             # <<<<<<<<<<<<<<
 * 
 *         strides = _get_strides_for_nocopy_reshape(self, shape)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->view(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 461, __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":460
 *         cdef ndarray newarray
 *         shape = internal.infer_unknown_dimension(shape, self.size)
 *         if internal.vector_equal(shape, self._shape):             # <<<<<<<<<<<<<<
 *             return self.view()
 * 
 */
  }

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

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

    /* "cupy/core/core.pyx":465
 *         strides = _get_strides_for_nocopy_reshape(self, shape)
 *         if strides.size() == shape.size():
 *             newarray = self.view()             # <<<<<<<<<<<<<<
 *         else:
 *             newarray = self.copy()
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->view(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 465, __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":464
 * 
 *         strides = _get_strides_for_nocopy_reshape(self, shape)
 *         if strides.size() == shape.size():             # <<<<<<<<<<<<<<
 *             newarray = self.view()
 *         else:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":467
 *             newarray = self.view()
 *         else:
 *             newarray = self.copy()             # <<<<<<<<<<<<<<
 *             strides = _get_strides_for_nocopy_reshape(newarray, shape)
 * 
 */
  /*else*/ {
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->copy(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 467, __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":468
 *         else:
 *             newarray = self.copy()
 *             strides = _get_strides_for_nocopy_reshape(newarray, shape)             # <<<<<<<<<<<<<<
 * 
 *         if shape.size() != strides.size():
 */
    __pyx_t_7 = __pyx_f_4cupy_4core_4core__get_strides_for_nocopy_reshape(__pyx_v_newarray, __pyx_v_shape, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 468, __pyx_L1_error)
    __pyx_v_strides = __pyx_t_7;
  }
  __pyx_L4:;

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

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

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

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

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

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

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray._reshape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_newarray);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_23_transpose(PyObject *__pyx_v_self, PyObject *__pyx_arg_axes); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray__transpose(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  __pyx_v_axes, int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = 0;
  std::vector<Py_ssize_t>  __pyx_v_a_axes;
  std::vector<Py_ssize_t>  __pyx_v_rev_axes;
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_axis;
  Py_ssize_t __pyx_v_i;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  std::vector<Py_ssize_t> ::iterator __pyx_t_11;
  __Pyx_RefNannySetupContext("_transpose", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transpose); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 489, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_23_transpose)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_axes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 489, __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, 489, __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, 489, __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, 489, __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, 489, __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, 489, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 489, __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":494
 *         cdef Py_ssize_t ndim, axis
 * 
 *         ndim = self._shape.size()             # <<<<<<<<<<<<<<
 *         ret = self.view()
 *         if axes.size() == 0:
 */
  __pyx_v_ndim = __pyx_v_self->_shape.size();

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

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

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

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

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

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

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

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

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

    /* "cupy/core/core.pyx":504
 * 
 *         if <Py_ssize_t>axes.size() != ndim:
 *             raise ValueError('Invalid axes value: %s' % str(axes))             # <<<<<<<<<<<<<<
 * 
 *         for i in range(ndim):
 */
    __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_axes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 504, __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_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_axes_value_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 504, __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, 504, __pyx_L1_error)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /* "cupy/core/core.pyx":524
 * 
 *         if ndim != len({i for i in axes}):
 *             raise ValueError('Invalid axes value: %s' % str(axes))             # <<<<<<<<<<<<<<
 * 
 *         ret._shape.clear()
 */
    __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_axes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 524, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 524, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 524, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_axes_value_s, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 524, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 524, __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_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 524, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 524, __pyx_L1_error)

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

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

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

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

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

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

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

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

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

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

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray._transpose", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_27swapaxes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_swapaxes(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, Py_ssize_t __pyx_v_axis1, Py_ssize_t __pyx_v_axis2, int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_ndim;
  std::vector<Py_ssize_t>  __pyx_v_axes;
  Py_ssize_t __pyx_v_i;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  __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, 553, __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, 553, __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, 553, __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, 553, __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, 553, __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, 553, __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, 553, __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, 553, __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":561
 * 
 *         """
 *         cdef Py_ssize_t ndim = self.ndim             # <<<<<<<<<<<<<<
 *         cdef vector.vector[Py_ssize_t] axes
 *         if axis1 < -ndim or axis1 >= ndim or axis2 < -ndim or axis2 >= ndim:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 561, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 561, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_9;

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

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

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

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

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

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

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

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

  /* "cupy/core/core.pyx":570
 *             axes.push_back(i)
 *         axes[axis1], axes[axis2] = axes[axis2], axes[axis1]
 *         return self._transpose(axes)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray flatten(self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_transpose(__pyx_v_self, __pyx_v_axes, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 570, __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":553
 *         return self._transpose(axes)
 * 
 *     cpdef ndarray swapaxes(self, Py_ssize_t axis1, Py_ssize_t axis2):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array with two axes swapped.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.core.core.ndarray.swapaxes", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_27swapaxes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_26swapaxes[] = "ndarray.swapaxes(self, Py_ssize_t axis1, Py_ssize_t axis2) -> ndarray\nReturns a view of the array with two axes swapped.\n\n        .. seealso::\n           :func:`cupy.swapaxes` for full documentation,\n           :meth:`numpy.ndarray.swapaxes`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_27swapaxes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  Py_ssize_t __pyx_v_axis1;
  Py_ssize_t __pyx_v_axis2;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("swapaxes (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis1,&__pyx_n_s_axis2,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis1)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("swapaxes", 1, 2, 2, 1); __PYX_ERR(0, 553, __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, 553, __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, 553, __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, 553, __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, 553, __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, 553, __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":572
 *         return self._transpose(axes)
 * 
 *     cpdef ndarray flatten(self):             # <<<<<<<<<<<<<<
 *         """Returns a copy of the array flatten into one dimension.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_29flatten(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_flatten(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_newarray = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("flatten", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_flatten); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 572, __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, 572, __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, 572, __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, 572, __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":584
 *         """
 *         # TODO(beam2d): Support ordering option
 *         newarray = self.copy(order='C')             # <<<<<<<<<<<<<<
 *         newarray._shape.assign(<Py_ssize_t>1, self.size)
 *         newarray._strides.assign(<Py_ssize_t>1,
 */
  __pyx_t_5.__pyx_n = 1;
  __pyx_t_5.order = __pyx_n_s_C;
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->copy(__pyx_v_self, 0, &__pyx_t_5)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 584, __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":585
 *         # TODO(beam2d): Support ordering option
 *         newarray = self.copy(order='C')
 *         newarray._shape.assign(<Py_ssize_t>1, self.size)             # <<<<<<<<<<<<<<
 *         newarray._strides.assign(<Py_ssize_t>1,
 *                                  <Py_ssize_t>self.itemsize)
 */
  try {
    __pyx_v_newarray->_shape.assign(((Py_ssize_t)1), __pyx_v_self->size);
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 585, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":587
 *         newarray._shape.assign(<Py_ssize_t>1, self.size)
 *         newarray._strides.assign(<Py_ssize_t>1,
 *                                  <Py_ssize_t>self.itemsize)             # <<<<<<<<<<<<<<
 *         newarray._c_contiguous = True
 *         newarray._f_contiguous = True
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 587, __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, 587, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

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

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

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

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

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

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

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_28flatten(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("flatten", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_7ndarray_flatten(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 572, __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":592
 *         return newarray
 * 
 *     cpdef ndarray ravel(self):             # <<<<<<<<<<<<<<
 *         """Returns an array flattened into one dimension.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_31ravel(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_ravel(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch) {
  std::vector<Py_ssize_t>  __pyx_v_shape;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("ravel", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ravel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 592, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_31ravel)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 592, __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, 592, __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, 592, __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":602
 *         # TODO(beam2d): Support ordering option
 *         cdef vector.vector[Py_ssize_t] shape
 *         shape.push_back(self.size)             # <<<<<<<<<<<<<<
 *         return self._reshape(shape)
 * 
 */
  try {
    __pyx_v_shape.push_back(__pyx_v_self->size);
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 602, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":603
 *         cdef vector.vector[Py_ssize_t] shape
 *         shape.push_back(self.size)
 *         return self._reshape(shape)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray squeeze(self, axis=None):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_reshape(__pyx_v_self, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 603, __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":592
 *         return newarray
 * 
 *     cpdef ndarray ravel(self):             # <<<<<<<<<<<<<<
 *         """Returns an array flattened into one dimension.
 * 
 */

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

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_30ravel(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("ravel", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_7ndarray_ravel(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 592, __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":605
 *         return self._reshape(shape)
 * 
 *     cpdef ndarray squeeze(self, axis=None):             # <<<<<<<<<<<<<<
 *         """Returns a view with size-one axes removed.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_33squeeze(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_squeeze(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_squeeze *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  std::vector<char>  __pyx_v_axis_flags;
  std::vector<Py_ssize_t>  __pyx_v_newshape;
  std::vector<Py_ssize_t>  __pyx_v_newstrides;
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_naxes;
  Py_ssize_t __pyx_v__axis;
  Py_ssize_t __pyx_v_idim;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_axis_orig;
  long __pyx_v_any_ones;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_v = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  std::vector<char>  __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides __pyx_t_13;
  __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, 605, __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, 605, __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, 605, __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, 605, __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, 605, __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, 605, __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, 605, __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":618
 *         cdef Py_ssize_t ndim, naxes, _axis
 * 
 *         ndim = self._shape.size()             # <<<<<<<<<<<<<<
 *         axis_flags = vector.vector[char](ndim, 0)
 * 
 */
  __pyx_v_ndim = __pyx_v_self->_shape.size();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        /* "cupy/core/core.pyx":652
 *                 if _axis < 0 or _axis >= ndim:
 *                     raise _AxisError(
 *                         "'axis' entry %d is out of bounds [-%d, %d)" %             # <<<<<<<<<<<<<<
 *                         (axis_orig, ndim, ndim))
 *                 axis_flags[_axis] = 1
 */
        __pyx_t_12 = __Pyx_PyString_Format(__pyx_kp_s_axis_entry_d_is_out_of_bounds_d, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 652, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __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_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 651, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_2)) {
            PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_12};
            __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 651, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
            PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_12};
            __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 651, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          } else
          #endif
          {
            __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 651, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
            __Pyx_GIVEREF(__pyx_t_12);
            PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_12);
            __pyx_t_12 = 0;
            __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 651, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __PYX_ERR(0, 651, __pyx_L1_error)

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

      /* "cupy/core/core.pyx":654
 *                         "'axis' entry %d is out of bounds [-%d, %d)" %
 *                         (axis_orig, ndim, ndim))
 *                 axis_flags[_axis] = 1             # <<<<<<<<<<<<<<
 * 
 *         # Verify that the axes requested are all of size one
 */
      (__pyx_v_axis_flags[__pyx_v__axis]) = 1;
    }
    __pyx_L15:;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":657
 * 
 *         # Verify that the axes requested are all of size one
 *         any_ones = 0             # <<<<<<<<<<<<<<
 *         for idim in range(ndim):
 *             if axis_flags[idim] != 0:
 */
  __pyx_v_any_ones = 0;

  /* "cupy/core/core.pyx":658
 *         # Verify that the axes requested are all of size one
 *         any_ones = 0
 *         for idim in range(ndim):             # <<<<<<<<<<<<<<
 *             if axis_flags[idim] != 0:
 *                 if self._shape[idim] == 1:
 */
  __pyx_t_9 = __pyx_v_ndim;
  for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
    __pyx_v_idim = __pyx_t_10;

    /* "cupy/core/core.pyx":659
 *         any_ones = 0
 *         for idim in range(ndim):
 *             if axis_flags[idim] != 0:             # <<<<<<<<<<<<<<
 *                 if self._shape[idim] == 1:
 *                     any_ones = 1
 */
    __pyx_t_7 = (((__pyx_v_axis_flags[__pyx_v_idim]) != 0) != 0);
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":660
 *         for idim in range(ndim):
 *             if axis_flags[idim] != 0:
 *                 if self._shape[idim] == 1:             # <<<<<<<<<<<<<<
 *                     any_ones = 1
 *                 else:
 */
      __pyx_t_7 = (((__pyx_v_self->_shape[__pyx_v_idim]) == 1) != 0);
      if (__pyx_t_7) {

        /* "cupy/core/core.pyx":661
 *             if axis_flags[idim] != 0:
 *                 if self._shape[idim] == 1:
 *                     any_ones = 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise ValueError('cannot select an axis to squeeze out '
 */
        __pyx_v_any_ones = 1;

        /* "cupy/core/core.pyx":660
 *         for idim in range(ndim):
 *             if axis_flags[idim] != 0:
 *                 if self._shape[idim] == 1:             # <<<<<<<<<<<<<<
 *                     any_ones = 1
 *                 else:
 */
        goto __pyx_L24;
      }

      /* "cupy/core/core.pyx":663
 *                     any_ones = 1
 *                 else:
 *                     raise ValueError('cannot select an axis to squeeze out '             # <<<<<<<<<<<<<<
 *                                      'which has size not equal to one')
 * 
 */
      /*else*/ {
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 663, __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, 663, __pyx_L1_error)
      }
      __pyx_L24:;

      /* "cupy/core/core.pyx":659
 *         any_ones = 0
 *         for idim in range(ndim):
 *             if axis_flags[idim] != 0:             # <<<<<<<<<<<<<<
 *                 if self._shape[idim] == 1:
 *                     any_ones = 1
 */
    }
  }

  /* "cupy/core/core.pyx":667
 * 
 *         # If there were no axes to squeeze out, return the same array
 *         if any_ones == 0:             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  __pyx_t_7 = ((__pyx_v_any_ones == 0) != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":668
 *         # If there were no axes to squeeze out, return the same array
 *         if any_ones == 0:
 *             return self             # <<<<<<<<<<<<<<
 * 
 *         for i in range(ndim):
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":667
 * 
 *         # If there were no axes to squeeze out, return the same array
 *         if any_ones == 0:             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  }

  /* "cupy/core/core.pyx":670
 *             return self
 * 
 *         for i in range(ndim):             # <<<<<<<<<<<<<<
 *             if axis_flags[i] == 0:
 *                 newshape.push_back(self._shape[i])
 */
  __pyx_t_9 = __pyx_v_ndim;
  for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
    __pyx_v_i = __pyx_t_10;

    /* "cupy/core/core.pyx":671
 * 
 *         for i in range(ndim):
 *             if axis_flags[i] == 0:             # <<<<<<<<<<<<<<
 *                 newshape.push_back(self._shape[i])
 *                 newstrides.push_back(self._strides[i])
 */
    __pyx_t_7 = (((__pyx_v_axis_flags[__pyx_v_i]) == 0) != 0);
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":672
 *         for i in range(ndim):
 *             if axis_flags[i] == 0:
 *                 newshape.push_back(self._shape[i])             # <<<<<<<<<<<<<<
 *                 newstrides.push_back(self._strides[i])
 * 
 */
      try {
        __pyx_v_newshape.push_back((__pyx_v_self->_shape[__pyx_v_i]));
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 672, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":673
 *             if axis_flags[i] == 0:
 *                 newshape.push_back(self._shape[i])
 *                 newstrides.push_back(self._strides[i])             # <<<<<<<<<<<<<<
 * 
 *         v = self.view()
 */
      try {
        __pyx_v_newstrides.push_back((__pyx_v_self->_strides[__pyx_v_i]));
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 673, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":671
 * 
 *         for i in range(ndim):
 *             if axis_flags[i] == 0:             # <<<<<<<<<<<<<<
 *                 newshape.push_back(self._shape[i])
 *                 newstrides.push_back(self._strides[i])
 */
    }
  }

  /* "cupy/core/core.pyx":675
 *                 newstrides.push_back(self._strides[i])
 * 
 *         v = self.view()             # <<<<<<<<<<<<<<
 *         v._set_shape_and_strides(newshape, newstrides, False)
 *         return v
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->view(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 675, __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":676
 * 
 *         v = self.view()
 *         v._set_shape_and_strides(newshape, newstrides, False)             # <<<<<<<<<<<<<<
 *         return v
 * 
 */
  __pyx_t_13.__pyx_n = 1;
  __pyx_t_13.update_c_contiguity = 0;
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_v->__pyx_vtab)->_set_shape_and_strides(__pyx_v_v, __pyx_v_newshape, __pyx_v_newstrides, 0, &__pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 676, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":677
 *         v = self.view()
 *         v._set_shape_and_strides(newshape, newstrides, False)
 *         return v             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_v));
  __pyx_r = __pyx_v_v;
  goto __pyx_L0;

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

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core.ndarray.squeeze", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_v);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_33squeeze(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_32squeeze[] = "ndarray.squeeze(self, axis=None) -> ndarray\nReturns a view with size-one axes removed.\n\n        .. seealso::\n           :func:`cupy.squeeze` for full documentation,\n           :meth:`numpy.ndarray.squeeze`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_33squeeze(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("squeeze (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 605, __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, 605, __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, 605, __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":682
 *     # Item selection and manipulation
 *     # -------------------------------------------------------------------------
 *     cpdef ndarray take(self, indices, axis=None, out=None):             # <<<<<<<<<<<<<<
 *         """Returns an array of elements at given indices along the axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_35take(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_take(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_indices, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_take *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__take __pyx_t_7;
  __Pyx_RefNannySetupContext("take", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_out = __pyx_optional_args->out;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_take); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 682, __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, 682, __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, 682, __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, 682, __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, 682, __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, 682, __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":690
 * 
 *         """
 *         return _take(self, indices, li=axis, ri=axis, out=out)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement put
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  if (!(likely(((__pyx_v_out) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_out, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 690, __pyx_L1_error)
  __pyx_t_7.__pyx_n = 3;
  __pyx_t_7.li = __pyx_v_axis;
  __pyx_t_7.ri = __pyx_v_axis;
  __pyx_t_7.out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_out);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__take(__pyx_v_self, __pyx_v_indices, 0, &__pyx_t_7)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 690, __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":682
 *     # 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] = PyDict_GetItem(__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 = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 682, __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, 682, __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, 682, __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":694
 *     # TODO(okuta): Implement put
 * 
 *     cpdef repeat(self, repeats, axis=None):             # <<<<<<<<<<<<<<
 *         """Returns an array with repeated arrays along an axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_37repeat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_repeat(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_repeats, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_repeat *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__repeat __pyx_t_7;
  __Pyx_RefNannySetupContext("repeat", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_repeat); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 694, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_37repeat)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_repeats, __pyx_v_axis};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 694, __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, 694, __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, 694, __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, 694, __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":702
 * 
 *         """
 *         return _repeat(self, repeats, axis)             # <<<<<<<<<<<<<<
 * 
 *     cpdef choose(self, choices, out=None, mode='raise'):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7.__pyx_n = 1;
  __pyx_t_7.axis = __pyx_v_axis;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__repeat(__pyx_v_self, __pyx_v_repeats, 0, &__pyx_t_7)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 702, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":694
 *     # TODO(okuta): Implement put
 * 
 *     cpdef repeat(self, repeats, axis=None):             # <<<<<<<<<<<<<<
 *         """Returns an array with repeated arrays along an axis.
 * 
 */

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_37repeat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_36repeat[] = "ndarray.repeat(self, repeats, axis=None)\nReturns an array with repeated arrays along an axis.\n\n        .. seealso::\n            :func:`cupy.repeat` for full documentation,\n            :meth:`numpy.ndarray.repeat`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_37repeat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_repeats = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("repeat (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_repeats,&__pyx_n_s_axis,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__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 = PyDict_GetItem(__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, 694, __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, 694, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.repeat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_36repeat(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_repeats, __pyx_v_axis);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_36repeat(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_repeats, PyObject *__pyx_v_axis) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_repeat __pyx_t_2;
  __Pyx_RefNannySetupContext("repeat", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_1 = __pyx_vtabptr_4cupy_4core_4core_ndarray->repeat(__pyx_v_self, __pyx_v_repeats, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 694, __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":704
 *         return _repeat(self, repeats, axis)
 * 
 *     cpdef choose(self, choices, out=None, mode='raise'):             # <<<<<<<<<<<<<<
 *         a = self
 *         n = choices.shape[0]
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_39choose(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_choose(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_choices, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_choose *__pyx_optional_args) {
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_mode = ((PyObject *)__pyx_n_s_raise);
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_n = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_ba = NULL;
  PyObject *__pyx_v_bcs = NULL;
  PyObject *__pyx_v_n_channel = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("choose", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_out = __pyx_optional_args->out;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_mode = __pyx_optional_args->mode;
      }
    }
  }
  __Pyx_INCREF(__pyx_v_choices);
  __Pyx_INCREF(__pyx_v_out);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_choose); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 704, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_39choose)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_choices, __pyx_v_out, __pyx_v_mode};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 704, __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, 704, __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, 704, __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, 704, __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":705
 * 
 *     cpdef choose(self, choices, out=None, mode='raise'):
 *         a = self             # <<<<<<<<<<<<<<
 *         n = choices.shape[0]
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_v_a = ((PyObject *)__pyx_v_self);

  /* "cupy/core/core.pyx":706
 *     cpdef choose(self, choices, out=None, mode='raise'):
 *         a = self
 *         n = choices.shape[0]             # <<<<<<<<<<<<<<
 * 
 *         # broadcast `a` and `choices[i]` for all i
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_choices, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 706, __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, 706, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":709
 * 
 *         # broadcast `a` and `choices[i]` for all i
 *         if a.ndim < choices.ndim - 1:             # <<<<<<<<<<<<<<
 *             for i in range(choices.ndim - 1 - a.ndim):
 *                 a = a[None, ...]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 709, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_choices, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 709, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_SubtractObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 709, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 709, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 709, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":710
 *         # broadcast `a` and `choices[i]` for all i
 *         if a.ndim < choices.ndim - 1:
 *             for i in range(choices.ndim - 1 - a.ndim):             # <<<<<<<<<<<<<<
 *                 a = a[None, ...]
 *         elif a.ndim > choices.ndim - 1:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_choices, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyInt_SubtractObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 710, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_9 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 710, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_8 >= 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_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 710, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 710, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 710, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 710, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_9(__pyx_t_1);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 710, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":711
 *         if a.ndim < choices.ndim - 1:
 *             for i in range(choices.ndim - 1 - a.ndim):
 *                 a = a[None, ...]             # <<<<<<<<<<<<<<
 *         elif a.ndim > choices.ndim - 1:
 *             for i in range(a.ndim + 1 - choices.ndim):
 */
      __pyx_t_2 = PyObject_GetItem(__pyx_v_a, __pyx_tuple__16); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 711, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF_SET(__pyx_v_a, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":710
 *         # broadcast `a` and `choices[i]` for all i
 *         if a.ndim < choices.ndim - 1:
 *             for i in range(choices.ndim - 1 - a.ndim):             # <<<<<<<<<<<<<<
 *                 a = a[None, ...]
 *         elif a.ndim > choices.ndim - 1:
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":709
 * 
 *         # broadcast `a` and `choices[i]` for all i
 *         if a.ndim < choices.ndim - 1:             # <<<<<<<<<<<<<<
 *             for i in range(choices.ndim - 1 - a.ndim):
 *                 a = a[None, ...]
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":712
 *             for i in range(choices.ndim - 1 - a.ndim):
 *                 a = a[None, ...]
 *         elif a.ndim > choices.ndim - 1:             # <<<<<<<<<<<<<<
 *             for i in range(a.ndim + 1 - choices.ndim):
 *                 choices = choices[:, None, ...]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 712, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_choices, __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 712, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_SubtractObjC(__pyx_t_2, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 712, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 712, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 712, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":713
 *                 a = a[None, ...]
 *         elif a.ndim > choices.ndim - 1:
 *             for i in range(a.ndim + 1 - choices.ndim):             # <<<<<<<<<<<<<<
 *                 choices = choices[:, None, ...]
 *         ba, bcs = broadcast(a, choices).values
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 713, __pyx_L1_error)
    __Pyx_GOTREF(__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, 713, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_choices, __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 713, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_Subtract(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 713, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 713, __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_PyObject_Call(__pyx_builtin_range, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 713, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 713, __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, 713, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 713, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 713, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 713, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 713, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_9(__pyx_t_2);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 713, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":714
 *         elif a.ndim > choices.ndim - 1:
 *             for i in range(a.ndim + 1 - choices.ndim):
 *                 choices = choices[:, None, ...]             # <<<<<<<<<<<<<<
 *         ba, bcs = broadcast(a, choices).values
 * 
 */
      __pyx_t_1 = PyObject_GetItem(__pyx_v_choices, __pyx_tuple__18); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 714, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_choices, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":713
 *                 a = a[None, ...]
 *         elif a.ndim > choices.ndim - 1:
 *             for i in range(a.ndim + 1 - choices.ndim):             # <<<<<<<<<<<<<<
 *                 choices = choices[:, None, ...]
 *         ba, bcs = broadcast(a, choices).values
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":712
 *             for i in range(choices.ndim - 1 - a.ndim):
 *                 a = a[None, ...]
 *         elif a.ndim > choices.ndim - 1:             # <<<<<<<<<<<<<<
 *             for i in range(a.ndim + 1 - choices.ndim):
 *                 choices = choices[:, None, ...]
 */
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":715
 *             for i in range(a.ndim + 1 - choices.ndim):
 *                 choices = choices[:, None, ...]
 *         ba, bcs = broadcast(a, choices).values             # <<<<<<<<<<<<<<
 * 
 *         if out is None:
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_a);
  __Pyx_GIVEREF(__pyx_v_a);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_a);
  __Pyx_INCREF(__pyx_v_choices);
  __Pyx_GIVEREF(__pyx_v_choices);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_choices);
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_broadcast), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = ((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_t_1)->values;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_2 != Py_None)) {
    PyObject* sequence = __pyx_t_2;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 715, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 715, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 715, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 715, __pyx_L1_error)
  }
  __pyx_v_ba = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_bcs = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":717
 *         ba, bcs = broadcast(a, choices).values
 * 
 *         if out is None:             # <<<<<<<<<<<<<<
 *             out = ndarray(ba.shape[1:], choices.dtype)
 * 
 */
  __pyx_t_7 = (__pyx_v_out == Py_None);
  __pyx_t_10 = (__pyx_t_7 != 0);
  if (__pyx_t_10) {

    /* "cupy/core/core.pyx":718
 * 
 *         if out is None:
 *             out = ndarray(ba.shape[1:], choices.dtype)             # <<<<<<<<<<<<<<
 * 
 *         n_channel = numpy.prod(bcs[0].shape)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ba, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 718, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_t_2, 1, 0, NULL, NULL, &__pyx_slice__19, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 718, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_choices, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 718, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 718, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_3 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 718, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_out, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":717
 *         ba, bcs = broadcast(a, choices).values
 * 
 *         if out is None:             # <<<<<<<<<<<<<<
 *             out = ndarray(ba.shape[1:], choices.dtype)
 * 
 */
  }

  /* "cupy/core/core.pyx":720
 *             out = ndarray(ba.shape[1:], choices.dtype)
 * 
 *         n_channel = numpy.prod(bcs[0].shape)             # <<<<<<<<<<<<<<
 *         if mode == 'raise':
 *             if not ((a < n).all() and (0 <= a).all()):
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_prod); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_bcs, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 720, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_6};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 720, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_6};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 720, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 720, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL;
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 720, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_n_channel = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":721
 * 
 *         n_channel = numpy.prod(bcs[0].shape)
 *         if mode == 'raise':             # <<<<<<<<<<<<<<
 *             if not ((a < n).all() and (0 <= a).all()):
 *                 raise ValueError('invalid entry in choice array')
 */
  __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_raise, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 721, __pyx_L1_error)
  if (__pyx_t_10) {

    /* "cupy/core/core.pyx":722
 *         n_channel = numpy.prod(bcs[0].shape)
 *         if mode == 'raise':
 *             if not ((a < n).all() and (0 <= a).all()):             # <<<<<<<<<<<<<<
 *                 raise ValueError('invalid entry in choice array')
 *             _choose_kernel(ba[0], bcs, n_channel, out)
 */
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_a, __pyx_v_n, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 722, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_all); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 722, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 722, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 722, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_7) {
    } else {
      __pyx_t_10 = __pyx_t_7;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_t_4 = PyObject_RichCompare(__pyx_int_0, __pyx_v_a, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 722, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_all); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 722, __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, 722, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 722, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_10 = __pyx_t_7;
    __pyx_L11_bool_binop_done:;
    __pyx_t_7 = ((!__pyx_t_10) != 0);
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":723
 *         if mode == 'raise':
 *             if not ((a < n).all() and (0 <= a).all()):
 *                 raise ValueError('invalid entry in choice array')             # <<<<<<<<<<<<<<
 *             _choose_kernel(ba[0], bcs, n_channel, out)
 *         elif mode == 'wrap':
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 723, __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, 723, __pyx_L1_error)

      /* "cupy/core/core.pyx":722
 *         n_channel = numpy.prod(bcs[0].shape)
 *         if mode == 'raise':
 *             if not ((a < n).all() and (0 <= a).all()):             # <<<<<<<<<<<<<<
 *                 raise ValueError('invalid entry in choice array')
 *             _choose_kernel(ba[0], bcs, n_channel, out)
 */
    }

    /* "cupy/core/core.pyx":724
 *             if not ((a < n).all() and (0 <= a).all()):
 *                 raise ValueError('invalid entry in choice array')
 *             _choose_kernel(ba[0], bcs, n_channel, out)             # <<<<<<<<<<<<<<
 *         elif mode == 'wrap':
 *             ba = ba[0] % n
 */
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_ba, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__choose_kernel);
    __pyx_t_4 = __pyx_v_4cupy_4core_4core__choose_kernel; __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_t_3, __pyx_v_bcs, __pyx_v_n_channel, __pyx_v_out};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 724, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_t_3, __pyx_v_bcs, __pyx_v_n_channel, __pyx_v_out};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 724, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 724, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_5, __pyx_t_3);
      __Pyx_INCREF(__pyx_v_bcs);
      __Pyx_GIVEREF(__pyx_v_bcs);
      PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_5, __pyx_v_bcs);
      __Pyx_INCREF(__pyx_v_n_channel);
      __Pyx_GIVEREF(__pyx_v_n_channel);
      PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_5, __pyx_v_n_channel);
      __Pyx_INCREF(__pyx_v_out);
      __Pyx_GIVEREF(__pyx_v_out);
      PyTuple_SET_ITEM(__pyx_t_1, 3+__pyx_t_5, __pyx_v_out);
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 724, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":721
 * 
 *         n_channel = numpy.prod(bcs[0].shape)
 *         if mode == 'raise':             # <<<<<<<<<<<<<<
 *             if not ((a < n).all() and (0 <= a).all()):
 *                 raise ValueError('invalid entry in choice array')
 */
    goto __pyx_L9;
  }

  /* "cupy/core/core.pyx":725
 *                 raise ValueError('invalid entry in choice array')
 *             _choose_kernel(ba[0], bcs, n_channel, out)
 *         elif mode == 'wrap':             # <<<<<<<<<<<<<<
 *             ba = ba[0] % n
 *             _choose_kernel(ba, bcs, n_channel, out)
 */
  __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_wrap, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 725, __pyx_L1_error)
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":726
 *             _choose_kernel(ba[0], bcs, n_channel, out)
 *         elif mode == 'wrap':
 *             ba = ba[0] % n             # <<<<<<<<<<<<<<
 *             _choose_kernel(ba, bcs, n_channel, out)
 *         elif mode == 'clip':
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_ba, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 726, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyNumber_Remainder(__pyx_t_2, __pyx_v_n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 726, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_ba, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":727
 *         elif mode == 'wrap':
 *             ba = ba[0] % n
 *             _choose_kernel(ba, bcs, n_channel, out)             # <<<<<<<<<<<<<<
 *         elif mode == 'clip':
 *             _choose_clip_kernel(ba[0], bcs, n_channel, n, out)
 */
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__choose_kernel);
    __pyx_t_2 = __pyx_v_4cupy_4core_4core__choose_kernel; __pyx_t_1 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[5] = {__pyx_t_1, __pyx_v_ba, __pyx_v_bcs, __pyx_v_n_channel, __pyx_v_out};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 727, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[5] = {__pyx_t_1, __pyx_v_ba, __pyx_v_bcs, __pyx_v_n_channel, __pyx_v_out};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 727, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 727, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_INCREF(__pyx_v_ba);
      __Pyx_GIVEREF(__pyx_v_ba);
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_5, __pyx_v_ba);
      __Pyx_INCREF(__pyx_v_bcs);
      __Pyx_GIVEREF(__pyx_v_bcs);
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_5, __pyx_v_bcs);
      __Pyx_INCREF(__pyx_v_n_channel);
      __Pyx_GIVEREF(__pyx_v_n_channel);
      PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_5, __pyx_v_n_channel);
      __Pyx_INCREF(__pyx_v_out);
      __Pyx_GIVEREF(__pyx_v_out);
      PyTuple_SET_ITEM(__pyx_t_3, 3+__pyx_t_5, __pyx_v_out);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 727, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":725
 *                 raise ValueError('invalid entry in choice array')
 *             _choose_kernel(ba[0], bcs, n_channel, out)
 *         elif mode == 'wrap':             # <<<<<<<<<<<<<<
 *             ba = ba[0] % n
 *             _choose_kernel(ba, bcs, n_channel, out)
 */
    goto __pyx_L9;
  }

  /* "cupy/core/core.pyx":728
 *             ba = ba[0] % n
 *             _choose_kernel(ba, bcs, n_channel, out)
 *         elif mode == 'clip':             # <<<<<<<<<<<<<<
 *             _choose_clip_kernel(ba[0], bcs, n_channel, n, out)
 *         else:
 */
  __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_clip, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 728, __pyx_L1_error)
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":729
 *             _choose_kernel(ba, bcs, n_channel, out)
 *         elif mode == 'clip':
 *             _choose_clip_kernel(ba[0], bcs, n_channel, n, out)             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError('clipmode not understood')
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_ba, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 729, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__choose_clip_kernel);
    __pyx_t_3 = __pyx_v_4cupy_4core_4core__choose_clip_kernel; __pyx_t_1 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[6] = {__pyx_t_1, __pyx_t_2, __pyx_v_bcs, __pyx_v_n_channel, __pyx_v_n, __pyx_v_out};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 729, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[6] = {__pyx_t_1, __pyx_t_2, __pyx_v_bcs, __pyx_v_n_channel, __pyx_v_n, __pyx_v_out};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 729, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 729, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_2);
      __Pyx_INCREF(__pyx_v_bcs);
      __Pyx_GIVEREF(__pyx_v_bcs);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_bcs);
      __Pyx_INCREF(__pyx_v_n_channel);
      __Pyx_GIVEREF(__pyx_v_n_channel);
      PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_n_channel);
      __Pyx_INCREF(__pyx_v_n);
      __Pyx_GIVEREF(__pyx_v_n);
      PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_n);
      __Pyx_INCREF(__pyx_v_out);
      __Pyx_GIVEREF(__pyx_v_out);
      PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_5, __pyx_v_out);
      __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 729, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":728
 *             ba = ba[0] % n
 *             _choose_kernel(ba, bcs, n_channel, out)
 *         elif mode == 'clip':             # <<<<<<<<<<<<<<
 *             _choose_clip_kernel(ba[0], bcs, n_channel, n, out)
 *         else:
 */
    goto __pyx_L9;
  }

  /* "cupy/core/core.pyx":731
 *             _choose_clip_kernel(ba[0], bcs, n_channel, n, out)
 *         else:
 *             raise TypeError('clipmode not understood')             # <<<<<<<<<<<<<<
 * 
 *         return out
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 731, __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, 731, __pyx_L1_error)
  }
  __pyx_L9:;

  /* "cupy/core/core.pyx":733
 *             raise TypeError('clipmode not understood')
 * 
 *         return out             # <<<<<<<<<<<<<<
 * 
 *     def sort(self, axis=-1):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_out);
  __pyx_r = __pyx_v_out;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":704
 *         return _repeat(self, repeats, axis)
 * 
 *     cpdef choose(self, choices, out=None, mode='raise'):             # <<<<<<<<<<<<<<
 *         a = self
 *         n = choices.shape[0]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.choose", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_n);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_ba);
  __Pyx_XDECREF(__pyx_v_bcs);
  __Pyx_XDECREF(__pyx_v_n_channel);
  __Pyx_XDECREF(__pyx_v_choices);
  __Pyx_XDECREF(__pyx_v_out);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_39choose(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_38choose[] = "ndarray.choose(self, choices, out=None, mode='raise')";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_39choose(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_choices = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_mode = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("choose (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_choices,&__pyx_n_s_out,&__pyx_n_s_mode,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_n_s_raise);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__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 = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 704, __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, 704, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.choose", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_38choose(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_choices, __pyx_v_out, __pyx_v_mode);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_38choose(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_choices, PyObject *__pyx_v_out, PyObject *__pyx_v_mode) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_choose __pyx_t_2;
  __Pyx_RefNannySetupContext("choose", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.mode = __pyx_v_mode;
  __pyx_t_1 = __pyx_vtabptr_4cupy_4core_4core_ndarray->choose(__pyx_v_self, __pyx_v_choices, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 704, __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":735
 *         return out
 * 
 *     def sort(self, axis=-1):             # <<<<<<<<<<<<<<
 *         """Sort an array, in-place with a stable sorting algorithm.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_41sort(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_40sort[] = "ndarray.sort(self, axis=-1)\nSort an array, in-place with a stable sorting algorithm.\n\n        Args:\n            axis (int): Axis along which to sort. Default is -1, which means\n                sort along the last axis.\n\n        .. note::\n           For its implementation reason, ``ndarray.sort`` currently supports\n           only arrays with their own data, and does not support ``kind`` and\n           ``order`` parameters that ``numpy.ndarray.sort`` does support.\n\n        .. seealso::\n            :func:`cupy.sort` for full documentation,\n            :meth:`numpy.ndarray.sort`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_41sort(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sort (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_neg_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 735, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_axis = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sort", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 735, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.sort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_40sort(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_40sort(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis) {
  Py_ssize_t __pyx_v_ndim;
  PyObject *__pyx_v_data = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_keys_array = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("sort", 0);
  __Pyx_INCREF(__pyx_v_axis);

  /* "cupy/core/core.pyx":755
 *         # TODO(takagi): Support kind argument.
 * 
 *         cdef Py_ssize_t ndim = self.ndim             # <<<<<<<<<<<<<<
 * 
 *         if not cupy.cuda.thrust_enabled:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 755, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_2;

  /* "cupy/core/core.pyx":757
 *         cdef Py_ssize_t ndim = self.ndim
 * 
 *         if not cupy.cuda.thrust_enabled:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('Thrust is needed to use cupy.sort. Please '
 *                                'install CUDA Toolkit with Thrust then '
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_cuda); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_thrust_enabled); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 757, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((!__pyx_t_4) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":758
 * 
 *         if not cupy.cuda.thrust_enabled:
 *             raise RuntimeError('Thrust is needed to use cupy.sort. Please '             # <<<<<<<<<<<<<<
 *                                'install CUDA Toolkit with Thrust then '
 *                                'reinstall CuPy after uninstalling it.')
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 758, __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, 758, __pyx_L1_error)

    /* "cupy/core/core.pyx":757
 *         cdef Py_ssize_t ndim = self.ndim
 * 
 *         if not cupy.cuda.thrust_enabled:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('Thrust is needed to use cupy.sort. Please '
 *                                'install CUDA Toolkit with Thrust then '
 */
  }

  /* "cupy/core/core.pyx":762
 *                                'reinstall CuPy after uninstalling it.')
 * 
 *         if ndim == 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Sorting arrays with the rank of zero is not '
 *                              'supported')  # as numpy.sort() raises
 */
  __pyx_t_5 = ((__pyx_v_ndim == 0) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":763
 * 
 *         if ndim == 0:
 *             raise ValueError('Sorting arrays with the rank of zero is not '             # <<<<<<<<<<<<<<
 *                              'supported')  # as numpy.sort() raises
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 763, __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, 763, __pyx_L1_error)

    /* "cupy/core/core.pyx":762
 *                                'reinstall CuPy after uninstalling it.')
 * 
 *         if ndim == 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Sorting arrays with the rank of zero is not '
 *                              'supported')  # as numpy.sort() raises
 */
  }

  /* "cupy/core/core.pyx":767
 * 
 *         # TODO(takagi): Support sorting views
 *         if not self._c_contiguous:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('Sorting non-contiguous array is not '
 *                                       'supported.')
 */
  __pyx_t_5 = ((!(__pyx_v_self->_c_contiguous != 0)) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":768
 *         # TODO(takagi): Support sorting views
 *         if not self._c_contiguous:
 *             raise NotImplementedError('Sorting non-contiguous array is not '             # <<<<<<<<<<<<<<
 *                                       'supported.')
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 768, __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, 768, __pyx_L1_error)

    /* "cupy/core/core.pyx":767
 * 
 *         # TODO(takagi): Support sorting views
 *         if not self._c_contiguous:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('Sorting non-contiguous array is not '
 *                                       'supported.')
 */
  }

  /* "cupy/core/core.pyx":771
 *                                       'supported.')
 * 
 *         if axis < 0:             # <<<<<<<<<<<<<<
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 771, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 771, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":772
 * 
 *         if axis < 0:
 *             axis += ndim             # <<<<<<<<<<<<<<
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')
 */
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 772, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_axis, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 772, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":771
 *                                       'supported.')
 * 
 *         if axis < 0:             # <<<<<<<<<<<<<<
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 */
  }

  /* "cupy/core/core.pyx":773
 *         if axis < 0:
 *             axis += ndim
 *         if not (0 <= axis < ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis out of range')
 * 
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_int_0, __pyx_v_axis, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 773, __pyx_L1_error)
  if (__Pyx_PyObject_IsTrue(__pyx_t_3)) {
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 773, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 773, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = ((!__pyx_t_5) != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":774
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')             # <<<<<<<<<<<<<<
 * 
 *         if axis == ndim - 1:
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 774, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 774, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 774, __pyx_L1_error)

    /* "cupy/core/core.pyx":773
 *         if axis < 0:
 *             axis += ndim
 *         if not (0 <= axis < ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis out of range')
 * 
 */
  }

  /* "cupy/core/core.pyx":776
 *             raise _AxisError('Axis out of range')
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             data = self
 *         else:
 */
  __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_ndim - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 776, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 776, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 776, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":777
 * 
 *         if axis == ndim - 1:
 *             data = self             # <<<<<<<<<<<<<<
 *         else:
 *             data = cupy.rollaxis(self, axis, ndim).copy()
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_v_data = ((PyObject *)__pyx_v_self);

    /* "cupy/core/core.pyx":776
 *             raise _AxisError('Axis out of range')
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             data = self
 *         else:
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":779
 *             data = self
 *         else:
 *             data = cupy.rollaxis(self, axis, ndim).copy()             # <<<<<<<<<<<<<<
 * 
 *         if ndim == 1:
 */
  /*else*/ {
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_rollaxis); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[4] = {__pyx_t_8, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_t_6};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 779, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[4] = {__pyx_t_8, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_t_6};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 779, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 779, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_axis);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 779, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_copy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (__pyx_t_1) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 779, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 779, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_data = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_L8:;

  /* "cupy/core/core.pyx":781
 *             data = cupy.rollaxis(self, axis, ndim).copy()
 * 
 *         if ndim == 1:             # <<<<<<<<<<<<<<
 *             thrust.sort(self.dtype, data.data.ptr, 0, self._shape)
 *         else:
 */
  __pyx_t_4 = ((__pyx_v_ndim == 1) != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":782
 * 
 *         if ndim == 1:
 *             thrust.sort(self.dtype, data.data.ptr, 0, self._shape)             # <<<<<<<<<<<<<<
 *         else:
 *             keys_array = ndarray(data._shape, dtype=numpy.intp)
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_thrust); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_sort); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_data); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_ptr); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_shape); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_v_self->dtype, __pyx_t_10, __pyx_int_0, __pyx_t_7};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 782, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_v_self->dtype, __pyx_t_10, __pyx_int_0, __pyx_t_7};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 782, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 782, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_v_self->dtype);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_t_10);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_9, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_9, __pyx_t_7);
      __pyx_t_10 = 0;
      __pyx_t_7 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 782, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":781
 *             data = cupy.rollaxis(self, axis, ndim).copy()
 * 
 *         if ndim == 1:             # <<<<<<<<<<<<<<
 *             thrust.sort(self.dtype, data.data.ptr, 0, self._shape)
 *         else:
 */
    goto __pyx_L9;
  }

  /* "cupy/core/core.pyx":784
 *             thrust.sort(self.dtype, data.data.ptr, 0, self._shape)
 *         else:
 *             keys_array = ndarray(data._shape, dtype=numpy.intp)             # <<<<<<<<<<<<<<
 *             thrust.sort(
 *                 self.dtype, data.data.ptr, keys_array.data.ptr, data._shape)
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 784, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 784, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 784, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 784, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_intp); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 784, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 784, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 784, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_keys_array = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":785
 *         else:
 *             keys_array = ndarray(data._shape, dtype=numpy.intp)
 *             thrust.sort(             # <<<<<<<<<<<<<<
 *                 self.dtype, data.data.ptr, keys_array.data.ptr, data._shape)
 * 
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_thrust); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 785, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sort); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 785, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":786
 *             keys_array = ndarray(data._shape, dtype=numpy.intp)
 *             thrust.sort(
 *                 self.dtype, data.data.ptr, keys_array.data.ptr, data._shape)             # <<<<<<<<<<<<<<
 * 
 *         if axis == ndim - 1:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ptr); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_keys_array->data->ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_6 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_v_self->dtype, __pyx_t_8, __pyx_t_3, __pyx_t_10};
      __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 785, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_v_self->dtype, __pyx_t_8, __pyx_t_3, __pyx_t_10};
      __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 785, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 785, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_v_self->dtype);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_9, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_9, __pyx_t_10);
      __pyx_t_8 = 0;
      __pyx_t_3 = 0;
      __pyx_t_10 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 785, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __pyx_L9:;

  /* "cupy/core/core.pyx":788
 *                 self.dtype, data.data.ptr, keys_array.data.ptr, data._shape)
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             pass
 *         else:
 */
  __pyx_t_7 = PyInt_FromSsize_t((__pyx_v_ndim - 1)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_7, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 788, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 788, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {
    goto __pyx_L10;
  }

  /* "cupy/core/core.pyx":791
 *             pass
 *         else:
 *             data = cupy.rollaxis(data, -1, axis)             # <<<<<<<<<<<<<<
 *             elementwise_copy(data, self)
 * 
 */
  /*else*/ {
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 791, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_rollaxis); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 791, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_data, __pyx_int_neg_1, __pyx_v_axis};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 791, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_data, __pyx_int_neg_1, __pyx_v_axis};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 791, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 791, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_v_data);
      __Pyx_GIVEREF(__pyx_v_data);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_data);
      __Pyx_INCREF(__pyx_int_neg_1);
      __Pyx_GIVEREF(__pyx_int_neg_1);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_int_neg_1);
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_v_axis);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 791, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":792
 *         else:
 *             data = cupy.rollaxis(data, -1, axis)
 *             elementwise_copy(data, self)             # <<<<<<<<<<<<<<
 * 
 *     def argsort(self, axis=-1):
 */
    __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 792, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_10 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_data, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 792, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_data, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 792, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 792, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_INCREF(__pyx_v_data);
      __Pyx_GIVEREF(__pyx_v_data);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_9, __pyx_v_data);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_9, ((PyObject *)__pyx_v_self));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 792, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L10:;

  /* "cupy/core/core.pyx":735
 *         return out
 * 
 *     def sort(self, axis=-1):             # <<<<<<<<<<<<<<
 *         """Sort an array, in-place with a stable sorting algorithm.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core.ndarray.sort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XDECREF((PyObject *)__pyx_v_keys_array);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":794
 *             elementwise_copy(data, self)
 * 
 *     def argsort(self, axis=-1):             # <<<<<<<<<<<<<<
 *         """Returns the indices that would sort an array with stable sorting
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_43argsort(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_42argsort[] = "ndarray.argsort(self, axis=-1)\nReturns the indices that would sort an array with stable sorting\n\n        Args:\n            axis (int or None): Axis along which to sort. Default is -1, which\n                means sort along the last axis. If None is supplied, the array\n                is flattened before sorting.\n\n        Returns:\n            cupy.ndarray: Array of indices that sort the array.\n\n        .. seealso::\n            :func:`cupy.argsort` for full documentation,\n            :meth:`numpy.ndarray.argsort`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_43argsort(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argsort (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_neg_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 794, __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, 794, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.argsort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_42argsort(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_42argsort(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis) {
  Py_ssize_t __pyx_v_ndim;
  PyObject *__pyx_v_data = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_idx_array = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_keys_array = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  __Pyx_RefNannySetupContext("argsort", 0);
  __Pyx_INCREF(__pyx_v_axis);

  /* "cupy/core/core.pyx":813
 *         # TODO(takagi): Support kind argument.
 * 
 *         cdef Py_ssize_t ndim = self.ndim             # <<<<<<<<<<<<<<
 * 
 *         if not cupy.cuda.thrust_enabled:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 813, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 813, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_2;

  /* "cupy/core/core.pyx":815
 *         cdef Py_ssize_t ndim = self.ndim
 * 
 *         if not cupy.cuda.thrust_enabled:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('Thrust is needed to use cupy.argsort. Please '
 *                                'install CUDA Toolkit with Thrust then '
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 815, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_cuda); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 815, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_thrust_enabled); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 815, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 815, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((!__pyx_t_4) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":816
 * 
 *         if not cupy.cuda.thrust_enabled:
 *             raise RuntimeError('Thrust is needed to use cupy.argsort. Please '             # <<<<<<<<<<<<<<
 *                                'install CUDA Toolkit with Thrust then '
 *                                'reinstall CuPy after uninstalling it.')
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 816, __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, 816, __pyx_L1_error)

    /* "cupy/core/core.pyx":815
 *         cdef Py_ssize_t ndim = self.ndim
 * 
 *         if not cupy.cuda.thrust_enabled:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('Thrust is needed to use cupy.argsort. Please '
 *                                'install CUDA Toolkit with Thrust then '
 */
  }

  /* "cupy/core/core.pyx":820
 *                                'reinstall CuPy after uninstalling it.')
 * 
 *         if ndim == 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Sorting arrays with the rank of zero is not '
 *                              'supported')  # as numpy.argsort() raises
 */
  __pyx_t_5 = ((__pyx_v_ndim == 0) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":821
 * 
 *         if ndim == 0:
 *             raise ValueError('Sorting arrays with the rank of zero is not '             # <<<<<<<<<<<<<<
 *                              'supported')  # as numpy.argsort() raises
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 821, __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, 821, __pyx_L1_error)

    /* "cupy/core/core.pyx":820
 *                                'reinstall CuPy after uninstalling it.')
 * 
 *         if ndim == 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Sorting arrays with the rank of zero is not '
 *                              'supported')  # as numpy.argsort() raises
 */
  }

  /* "cupy/core/core.pyx":824
 *                              'supported')  # as numpy.argsort() raises
 * 
 *         if axis is None:             # <<<<<<<<<<<<<<
 *             data = self.reshape(self.size)
 *             axis = -1
 */
  __pyx_t_5 = (__pyx_v_axis == Py_None);
  __pyx_t_4 = (__pyx_t_5 != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":825
 * 
 *         if axis is None:
 *             data = self.reshape(self.size)             # <<<<<<<<<<<<<<
 *             axis = -1
 *         else:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 825, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 825, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 825, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 825, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 825, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 825, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 825, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_data = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":826
 *         if axis is None:
 *             data = self.reshape(self.size)
 *             axis = -1             # <<<<<<<<<<<<<<
 *         else:
 *             data = self
 */
    __Pyx_INCREF(__pyx_int_neg_1);
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_int_neg_1);

    /* "cupy/core/core.pyx":824
 *                              'supported')  # as numpy.argsort() raises
 * 
 *         if axis is None:             # <<<<<<<<<<<<<<
 *             data = self.reshape(self.size)
 *             axis = -1
 */
    goto __pyx_L5;
  }

  /* "cupy/core/core.pyx":828
 *             axis = -1
 *         else:
 *             data = self             # <<<<<<<<<<<<<<
 * 
 *         if axis < 0:
 */
  /*else*/ {
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_v_data = ((PyObject *)__pyx_v_self);
  }
  __pyx_L5:;

  /* "cupy/core/core.pyx":830
 *             data = self
 * 
 *         if axis < 0:             # <<<<<<<<<<<<<<
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 830, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 830, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":831
 * 
 *         if axis < 0:
 *             axis += ndim             # <<<<<<<<<<<<<<
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')
 */
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 831, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_axis, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 831, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":830
 *             data = self
 * 
 *         if axis < 0:             # <<<<<<<<<<<<<<
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 */
  }

  /* "cupy/core/core.pyx":832
 *         if axis < 0:
 *             axis += ndim
 *         if not (0 <= axis < ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis out of range')
 * 
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_int_0, __pyx_v_axis, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 832, __pyx_L1_error)
  if (__Pyx_PyObject_IsTrue(__pyx_t_3)) {
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 832, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 832, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 832, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = ((!__pyx_t_4) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":833
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')             # <<<<<<<<<<<<<<
 * 
 *         if axis == ndim - 1:
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 833, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 833, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 833, __pyx_L1_error)

    /* "cupy/core/core.pyx":832
 *         if axis < 0:
 *             axis += ndim
 *         if not (0 <= axis < ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis out of range')
 * 
 */
  }

  /* "cupy/core/core.pyx":835
 *             raise _AxisError('Axis out of range')
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             data = data.copy()
 *         else:
 */
  __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_ndim - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 835, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 835, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 835, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":836
 * 
 *         if axis == ndim - 1:
 *             data = data.copy()             # <<<<<<<<<<<<<<
 *         else:
 *             data = cupy.rollaxis(data, axis, ndim).copy()
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 836, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (__pyx_t_8) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 836, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 836, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":835
 *             raise _AxisError('Axis out of range')
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             data = data.copy()
 *         else:
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":838
 *             data = data.copy()
 *         else:
 *             data = cupy.rollaxis(data, axis, ndim).copy()             # <<<<<<<<<<<<<<
 * 
 *         idx_array = ndarray(data.shape, dtype=numpy.intp)
 */
  /*else*/ {
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 838, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_rollaxis); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 838, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 838, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_data, __pyx_v_axis, __pyx_t_8};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 838, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_data, __pyx_v_axis, __pyx_t_8};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 838, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 838, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_v_data);
      __Pyx_GIVEREF(__pyx_v_data);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_data);
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_axis);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 838, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_copy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 838, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_1) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 838, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 838, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L8:;

  /* "cupy/core/core.pyx":840
 *             data = cupy.rollaxis(data, axis, ndim).copy()
 * 
 *         idx_array = ndarray(data.shape, dtype=numpy.intp)             # <<<<<<<<<<<<<<
 * 
 *         if ndim == 1:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 840, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 840, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 840, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 840, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_intp); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 840, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_10) < 0) __PYX_ERR(0, 840, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 840, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_idx_array = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10);
  __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":842
 *         idx_array = ndarray(data.shape, dtype=numpy.intp)
 * 
 *         if ndim == 1:             # <<<<<<<<<<<<<<
 *             thrust.argsort(self.dtype, idx_array.data.ptr, data.data.ptr, 0,
 *                            data._shape)
 */
  __pyx_t_5 = ((__pyx_v_ndim == 1) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":843
 * 
 *         if ndim == 1:
 *             thrust.argsort(self.dtype, idx_array.data.ptr, data.data.ptr, 0,             # <<<<<<<<<<<<<<
 *                            data._shape)
 *         else:
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_thrust); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 843, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_argsort); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 843, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_idx_array->data->ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 843, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 843, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ptr); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 843, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":844
 *         if ndim == 1:
 *             thrust.argsort(self.dtype, idx_array.data.ptr, data.data.ptr, 0,
 *                            data._shape)             # <<<<<<<<<<<<<<
 *         else:
 *             keys_array = ndarray(data._shape, dtype=numpy.intp)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 844, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[6] = {__pyx_t_7, __pyx_v_self->dtype, __pyx_t_3, __pyx_t_8, __pyx_int_0, __pyx_t_1};
      __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 843, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[6] = {__pyx_t_7, __pyx_v_self->dtype, __pyx_t_3, __pyx_t_8, __pyx_int_0, __pyx_t_1};
      __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 843, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 843, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_v_self->dtype);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_9, __pyx_t_8);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_9, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_9, __pyx_t_1);
      __pyx_t_3 = 0;
      __pyx_t_8 = 0;
      __pyx_t_1 = 0;
      __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 843, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":842
 *         idx_array = ndarray(data.shape, dtype=numpy.intp)
 * 
 *         if ndim == 1:             # <<<<<<<<<<<<<<
 *             thrust.argsort(self.dtype, idx_array.data.ptr, data.data.ptr, 0,
 *                            data._shape)
 */
    goto __pyx_L9;
  }

  /* "cupy/core/core.pyx":846
 *                            data._shape)
 *         else:
 *             keys_array = ndarray(data._shape, dtype=numpy.intp)             # <<<<<<<<<<<<<<
 *             thrust.argsort(self.dtype, idx_array.data.ptr, data.data.ptr,
 *                            keys_array.data.ptr, data._shape)
 */
  /*else*/ {
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 846, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 846, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 846, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 846, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_intp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 846, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 846, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_6, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 846, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_v_keys_array = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":847
 *         else:
 *             keys_array = ndarray(data._shape, dtype=numpy.intp)
 *             thrust.argsort(self.dtype, idx_array.data.ptr, data.data.ptr,             # <<<<<<<<<<<<<<
 *                            keys_array.data.ptr, data._shape)
 * 
 */
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_thrust); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 847, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_argsort); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 847, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyInt_FromSize_t(__pyx_v_idx_array->data->ptr); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 847, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_data); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 847, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_ptr); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 847, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

    /* "cupy/core/core.pyx":848
 *             keys_array = ndarray(data._shape, dtype=numpy.intp)
 *             thrust.argsort(self.dtype, idx_array.data.ptr, data.data.ptr,
 *                            keys_array.data.ptr, data._shape)             # <<<<<<<<<<<<<<
 * 
 *         if axis == ndim - 1:
 */
    __pyx_t_11 = __Pyx_PyInt_FromSize_t(__pyx_v_keys_array->data->ptr); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 848, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 848, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[6] = {__pyx_t_7, __pyx_v_self->dtype, __pyx_t_10, __pyx_t_8, __pyx_t_11, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 847, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[6] = {__pyx_t_7, __pyx_v_self->dtype, __pyx_t_10, __pyx_t_8, __pyx_t_11, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 847, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 847, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_v_self->dtype);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_9, __pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_9, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_9, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_9, __pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_9, __pyx_t_3);
      __pyx_t_10 = 0;
      __pyx_t_8 = 0;
      __pyx_t_11 = 0;
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 847, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L9:;

  /* "cupy/core/core.pyx":850
 *                            keys_array.data.ptr, data._shape)
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             return idx_array
 *         else:
 */
  __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_ndim - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 850, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 850, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":851
 * 
 *         if axis == ndim - 1:
 *             return idx_array             # <<<<<<<<<<<<<<
 *         else:
 *             return cupy.rollaxis(idx_array, -1, axis)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_idx_array));
    __pyx_r = ((PyObject *)__pyx_v_idx_array);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":850
 *                            keys_array.data.ptr, data._shape)
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             return idx_array
 *         else:
 */
  }

  /* "cupy/core/core.pyx":853
 *             return idx_array
 *         else:
 *             return cupy.rollaxis(idx_array, -1, axis)             # <<<<<<<<<<<<<<
 * 
 *     def partition(self, kth, axis=-1):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 853, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_rollaxis); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 853, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[4] = {__pyx_t_1, ((PyObject *)__pyx_v_idx_array), __pyx_int_neg_1, __pyx_v_axis};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 853, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[4] = {__pyx_t_1, ((PyObject *)__pyx_v_idx_array), __pyx_int_neg_1, __pyx_v_axis};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 853, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 853, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_idx_array));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_idx_array));
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, ((PyObject *)__pyx_v_idx_array));
      __Pyx_INCREF(__pyx_int_neg_1);
      __Pyx_GIVEREF(__pyx_int_neg_1);
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_int_neg_1);
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_9, __pyx_v_axis);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 853, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":794
 *             elementwise_copy(data, self)
 * 
 *     def argsort(self, axis=-1):             # <<<<<<<<<<<<<<
 *         """Returns the indices that would sort an array with stable sorting
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core.ndarray.argsort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XDECREF((PyObject *)__pyx_v_idx_array);
  __Pyx_XDECREF((PyObject *)__pyx_v_keys_array);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":855
 *             return cupy.rollaxis(idx_array, -1, axis)
 * 
 *     def partition(self, kth, axis=-1):             # <<<<<<<<<<<<<<
 *         """Partially sorts an array.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_45partition(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_44partition[] = "ndarray.partition(self, kth, axis=-1)\nPartially sorts 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        .. note::\n           For its implementation reason, :func:`cupy.ndarray.partition` fully\n           sorts the given array as :meth:`cupy.ndarray.sort` does. It also\n           does not support ``kind`` and ``order`` parameters that\n           :func:`numpy.partition` supports.\n\n        .. seealso::\n            :func:`cupy.partition` for full documentation,\n            :meth:`numpy.ndarray.partition`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_45partition(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_kth = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("partition (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_kth,&__pyx_n_s_axis,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_int_neg_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__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 = PyDict_GetItem(__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, 855, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_kth = values[0];
    __pyx_v_axis = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("partition", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 855, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.partition", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_44partition(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_kth, __pyx_v_axis);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_44partition(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_kth, PyObject *__pyx_v_axis) {
  PyObject *__pyx_v_ndim = NULL;
  PyObject *__pyx_v_length = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  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;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("partition", 0);
  __Pyx_INCREF(__pyx_v_kth);
  __Pyx_INCREF(__pyx_v_axis);

  /* "cupy/core/core.pyx":877
 * 
 *         """
 *         ndim = self.ndim             # <<<<<<<<<<<<<<
 *         if axis < 0:
 *             axis += ndim
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 877, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ndim = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":878
 *         """
 *         ndim = self.ndim
 *         if axis < 0:             # <<<<<<<<<<<<<<
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 878, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 878, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":879
 *         ndim = self.ndim
 *         if axis < 0:
 *             axis += ndim             # <<<<<<<<<<<<<<
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_axis, __pyx_v_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 879, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":878
 *         """
 *         ndim = self.ndim
 *         if axis < 0:             # <<<<<<<<<<<<<<
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 */
  }

  /* "cupy/core/core.pyx":880
 *         if axis < 0:
 *             axis += ndim
 *         if not (0 <= axis < ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis out of range')
 * 
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_int_0, __pyx_v_axis, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 880, __pyx_L1_error)
  if (__Pyx_PyObject_IsTrue(__pyx_t_1)) {
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_axis, __pyx_v_ndim, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 880, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 880, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":881
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')             # <<<<<<<<<<<<<<
 * 
 *         length = self.shape[axis]
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 881, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 881, __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, 881, __pyx_L1_error)

    /* "cupy/core/core.pyx":880
 *         if axis < 0:
 *             axis += ndim
 *         if not (0 <= axis < ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis out of range')
 * 
 */
  }

  /* "cupy/core/core.pyx":883
 *             raise _AxisError('Axis out of range')
 * 
 *         length = self.shape[axis]             # <<<<<<<<<<<<<<
 *         if isinstance(kth, int):
 *             kth = kth,
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyObject_GetItem(__pyx_t_4, __pyx_v_axis); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_length = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":884
 * 
 *         length = self.shape[axis]
 *         if isinstance(kth, int):             # <<<<<<<<<<<<<<
 *             kth = kth,
 *         for k in kth:
 */
  __pyx_t_3 = PyInt_Check(__pyx_v_kth); 
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":885
 *         length = self.shape[axis]
 *         if isinstance(kth, int):
 *             kth = kth,             # <<<<<<<<<<<<<<
 *         for k in kth:
 *             if k < 0:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 885, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_kth);
    __Pyx_GIVEREF(__pyx_v_kth);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_kth);
    __Pyx_DECREF_SET(__pyx_v_kth, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":884
 * 
 *         length = self.shape[axis]
 *         if isinstance(kth, int):             # <<<<<<<<<<<<<<
 *             kth = kth,
 *         for k in kth:
 */
  }

  /* "cupy/core/core.pyx":886
 *         if isinstance(kth, int):
 *             kth = kth,
 *         for k in kth:             # <<<<<<<<<<<<<<
 *             if k < 0:
 *                 k += length
 */
  if (likely(PyList_CheckExact(__pyx_v_kth)) || PyTuple_CheckExact(__pyx_v_kth)) {
    __pyx_t_1 = __pyx_v_kth; __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_kth); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 886, __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, 886, __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_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 886, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 886, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_5 >= 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_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 886, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 886, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_6(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 886, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":887
 *             kth = kth,
 *         for k in kth:
 *             if k < 0:             # <<<<<<<<<<<<<<
 *                 k += length
 *             if not (0 <= k < length):
 */
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 887, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 887, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":888
 *         for k in kth:
 *             if k < 0:
 *                 k += length             # <<<<<<<<<<<<<<
 *             if not (0 <= k < length):
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))
 */
      __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_k, __pyx_v_length); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 888, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":887
 *             kth = kth,
 *         for k in kth:
 *             if k < 0:             # <<<<<<<<<<<<<<
 *                 k += length
 *             if not (0 <= k < length):
 */
    }

    /* "cupy/core/core.pyx":889
 *             if k < 0:
 *                 k += length
 *             if not (0 <= k < length):             # <<<<<<<<<<<<<<
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))
 * 
 */
    __pyx_t_4 = PyObject_RichCompare(__pyx_int_0, __pyx_v_k, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 889, __pyx_L1_error)
    if (__Pyx_PyObject_IsTrue(__pyx_t_4)) {
      __Pyx_DECREF(__pyx_t_4);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_v_length, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 889, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 889, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_3 = ((!__pyx_t_2) != 0);
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":890
 *                 k += length
 *             if not (0 <= k < length):
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))             # <<<<<<<<<<<<<<
 * 
 *         # kth is ignored.
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_kth_out_of_bounds, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 890, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_9 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_k, __pyx_v_length};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 890, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_k, __pyx_v_length};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 890, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 890, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        if (__pyx_t_8) {
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
        }
        __Pyx_INCREF(__pyx_v_k);
        __Pyx_GIVEREF(__pyx_v_k);
        PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_k);
        __Pyx_INCREF(__pyx_v_length);
        __Pyx_GIVEREF(__pyx_v_length);
        PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_length);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 890, __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;
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 890, __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 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 890, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 890, __pyx_L1_error)

      /* "cupy/core/core.pyx":889
 *             if k < 0:
 *                 k += length
 *             if not (0 <= k < length):             # <<<<<<<<<<<<<<
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))
 * 
 */
    }

    /* "cupy/core/core.pyx":886
 *         if isinstance(kth, int):
 *             kth = kth,
 *         for k in kth:             # <<<<<<<<<<<<<<
 *             if k < 0:
 *                 k += length
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":893
 * 
 *         # kth is ignored.
 *         self.sort(axis=axis)             # <<<<<<<<<<<<<<
 * 
 *     def argpartition(self, kth, axis=-1):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_sort); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 893, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 893, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 893, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 893, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":855
 *             return cupy.rollaxis(idx_array, -1, axis)
 * 
 *     def partition(self, kth, axis=-1):             # <<<<<<<<<<<<<<
 *         """Partially sorts 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_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cupy.core.core.ndarray.partition", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ndim);
  __Pyx_XDECREF(__pyx_v_length);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_kth);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_47argpartition(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_46argpartition[] = "ndarray.argpartition(self, kth, axis=-1)\nReturns the indices that would partially sort an array.\n\n        Args:\n            kth (int or sequence of ints): Element index to partition by. If\n                supplied with a sequence of k-th it will partition all elements\n                indexed by k-th of them into their sorted position at once.\n            axis (int or None): Axis along which to sort. Default is -1, which\n                means sort along the last axis. If None is supplied, the array\n                is flattened before sorting.\n\n        Returns:\n            cupy.ndarray: Array of the same type and shape as ``a``.\n\n        .. seealso::\n            :func:`cupy.argpartition` for full documentation,\n            :meth:`numpy.ndarray.argpartition`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_47argpartition(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_kth = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argpartition (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_kth,&__pyx_n_s_axis,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_int_neg_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__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 = PyDict_GetItem(__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, 895, __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, 895, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.argpartition", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_46argpartition(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_kth, __pyx_v_axis);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_46argpartition(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_kth, PyObject *__pyx_v_axis) {
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_v_ndim = NULL;
  PyObject *__pyx_v_length = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("argpartition", 0);
  __Pyx_INCREF(__pyx_v_kth);
  __Pyx_INCREF(__pyx_v_axis);

  /* "cupy/core/core.pyx":914
 * 
 *         """
 *         if axis is None:             # <<<<<<<<<<<<<<
 *             data = self.reshape(self.size)
 *             axis = -1
 */
  __pyx_t_1 = (__pyx_v_axis == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":915
 *         """
 *         if axis is None:
 *             data = self.reshape(self.size)             # <<<<<<<<<<<<<<
 *             axis = -1
 *         else:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 915, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 915, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 915, __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, 915, __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, 915, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 915, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
        __pyx_t_5 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 915, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_data = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":916
 *         if axis is None:
 *             data = self.reshape(self.size)
 *             axis = -1             # <<<<<<<<<<<<<<
 *         else:
 *             data = self
 */
    __Pyx_INCREF(__pyx_int_neg_1);
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_int_neg_1);

    /* "cupy/core/core.pyx":914
 * 
 *         """
 *         if axis is None:             # <<<<<<<<<<<<<<
 *             data = self.reshape(self.size)
 *             axis = -1
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":918
 *             axis = -1
 *         else:
 *             data = self             # <<<<<<<<<<<<<<
 * 
 *         ndim = data.ndim
 */
  /*else*/ {
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_v_data = ((PyObject *)__pyx_v_self);
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":920
 *             data = self
 * 
 *         ndim = data.ndim             # <<<<<<<<<<<<<<
 *         if axis < 0:
 *             axis += ndim
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 920, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ndim = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":921
 * 
 *         ndim = data.ndim
 *         if axis < 0:             # <<<<<<<<<<<<<<
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 921, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 921, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":922
 *         ndim = data.ndim
 *         if axis < 0:
 *             axis += ndim             # <<<<<<<<<<<<<<
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')
 */
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_axis, __pyx_v_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 922, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":921
 * 
 *         ndim = data.ndim
 *         if axis < 0:             # <<<<<<<<<<<<<<
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 */
  }

  /* "cupy/core/core.pyx":923
 *         if axis < 0:
 *             axis += ndim
 *         if not (0 <= axis < ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis out of range')
 * 
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_int_0, __pyx_v_axis, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 923, __pyx_L1_error)
  if (__Pyx_PyObject_IsTrue(__pyx_t_3)) {
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_axis, __pyx_v_ndim, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 923, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 923, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = ((!__pyx_t_2) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":924
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')             # <<<<<<<<<<<<<<
 * 
 *         length = data.shape[axis]
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 924, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 924, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 924, __pyx_L1_error)

    /* "cupy/core/core.pyx":923
 *         if axis < 0:
 *             axis += ndim
 *         if not (0 <= axis < ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis out of range')
 * 
 */
  }

  /* "cupy/core/core.pyx":926
 *             raise _AxisError('Axis out of range')
 * 
 *         length = data.shape[axis]             # <<<<<<<<<<<<<<
 *         if isinstance(kth, int):
 *             kth = kth,
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 926, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_GetItem(__pyx_t_4, __pyx_v_axis); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 926, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_length = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":927
 * 
 *         length = data.shape[axis]
 *         if isinstance(kth, int):             # <<<<<<<<<<<<<<
 *             kth = kth,
 *         for k in kth:
 */
  __pyx_t_1 = PyInt_Check(__pyx_v_kth); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":928
 *         length = data.shape[axis]
 *         if isinstance(kth, int):
 *             kth = kth,             # <<<<<<<<<<<<<<
 *         for k in kth:
 *             if k < 0:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 928, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_kth);
    __Pyx_GIVEREF(__pyx_v_kth);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_kth);
    __Pyx_DECREF_SET(__pyx_v_kth, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":927
 * 
 *         length = data.shape[axis]
 *         if isinstance(kth, int):             # <<<<<<<<<<<<<<
 *             kth = kth,
 *         for k in kth:
 */
  }

  /* "cupy/core/core.pyx":929
 *         if isinstance(kth, int):
 *             kth = kth,
 *         for k in kth:             # <<<<<<<<<<<<<<
 *             if k < 0:
 *                 k += length
 */
  if (likely(PyList_CheckExact(__pyx_v_kth)) || PyTuple_CheckExact(__pyx_v_kth)) {
    __pyx_t_3 = __pyx_v_kth; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_kth); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 929, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 929, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_9)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 929, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 929, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 929, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 929, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_9(__pyx_t_3);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 929, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":930
 *             kth = kth,
 *         for k in kth:
 *             if k < 0:             # <<<<<<<<<<<<<<
 *                 k += length
 *             if not (0 <= k < length):
 */
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 930, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 930, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":931
 *         for k in kth:
 *             if k < 0:
 *                 k += length             # <<<<<<<<<<<<<<
 *             if not (0 <= k < length):
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))
 */
      __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_k, __pyx_v_length); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 931, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":930
 *             kth = kth,
 *         for k in kth:
 *             if k < 0:             # <<<<<<<<<<<<<<
 *                 k += length
 *             if not (0 <= k < length):
 */
    }

    /* "cupy/core/core.pyx":932
 *             if k < 0:
 *                 k += length
 *             if not (0 <= k < length):             # <<<<<<<<<<<<<<
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))
 * 
 */
    __pyx_t_4 = PyObject_RichCompare(__pyx_int_0, __pyx_v_k, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 932, __pyx_L1_error)
    if (__Pyx_PyObject_IsTrue(__pyx_t_4)) {
      __Pyx_DECREF(__pyx_t_4);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_v_length, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 932, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 932, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = ((!__pyx_t_2) != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":933
 *                 k += length
 *             if not (0 <= k < length):
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))             # <<<<<<<<<<<<<<
 * 
 *         # TODO(takgi) For its implementation reason, cupy.ndarray.argsort
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_kth_out_of_bounds, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 933, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_5 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_k, __pyx_v_length};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 933, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_k, __pyx_v_length};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 933, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 933, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_5) {
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        }
        __Pyx_INCREF(__pyx_v_k);
        __Pyx_GIVEREF(__pyx_v_k);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_10, __pyx_v_k);
        __Pyx_INCREF(__pyx_v_length);
        __Pyx_GIVEREF(__pyx_v_length);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_10, __pyx_v_length);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 933, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 933, __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 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 933, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 933, __pyx_L1_error)

      /* "cupy/core/core.pyx":932
 *             if k < 0:
 *                 k += length
 *             if not (0 <= k < length):             # <<<<<<<<<<<<<<
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))
 * 
 */
    }

    /* "cupy/core/core.pyx":929
 *         if isinstance(kth, int):
 *             kth = kth,
 *         for k in kth:             # <<<<<<<<<<<<<<
 *             if k < 0:
 *                 k += length
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":940
 * 
 *         # kth is ignored.
 *         return cupy.argsort(data, axis=axis)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement searchsorted
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 940, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_argsort); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 940, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 940, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_data);
  __Pyx_GIVEREF(__pyx_v_data);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_data);
  __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 940, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 940, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 940, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

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

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core.ndarray.argpartition", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XDECREF(__pyx_v_ndim);
  __Pyx_XDECREF(__pyx_v_length);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_kth);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":944
 *     # TODO(okuta): Implement searchsorted
 * 
 *     def nonzero(self):             # <<<<<<<<<<<<<<
 *         """Return the indices of the elements that are non-zero.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_49nonzero(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_48nonzero[] = "ndarray.nonzero(self)\nReturn the indices of the elements that are non-zero.\n\n        Returned Array is containing the indices of the non-zero elements\n        in that dimension.\n\n        Returns:\n            tuple of arrays: Indices of elements that are non-zero.\n\n        .. seealso::\n            :func:`numpy.nonzero`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_49nonzero(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("nonzero (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_48nonzero(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_48nonzero(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  Py_ssize_t __pyx_v_count_nonzero;
  Py_ssize_t __pyx_v_ndim;
  PyObject *__pyx_v_dtype = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_r = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_scan_index = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dst = NULL;
  PyObject *__pyx_v_kern = NULL;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  long __pyx_t_7;
  std::vector<Py_ssize_t> ::size_type __pyx_t_8;
  std::vector<Py_ssize_t> ::size_type __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  Py_ssize_t __pyx_t_13;
  __Pyx_RefNannySetupContext("nonzero", 0);

  /* "cupy/core/core.pyx":958
 *         """
 *         cdef Py_ssize_t count_nonzero, ndim
 *         dtype = numpy.int64             # <<<<<<<<<<<<<<
 *         if self.size == 0:
 *             count_nonzero = 0
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 958, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 958, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_dtype = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":959
 *         cdef Py_ssize_t count_nonzero, ndim
 *         dtype = numpy.int64
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             count_nonzero = 0
 *         else:
 */
  __pyx_t_3 = ((__pyx_v_self->size == 0) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":960
 *         dtype = numpy.int64
 *         if self.size == 0:
 *             count_nonzero = 0             # <<<<<<<<<<<<<<
 *         else:
 *             r = self.ravel()
 */
    __pyx_v_count_nonzero = 0;

    /* "cupy/core/core.pyx":959
 *         cdef Py_ssize_t count_nonzero, ndim
 *         dtype = numpy.int64
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             count_nonzero = 0
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":962
 *             count_nonzero = 0
 *         else:
 *             r = self.ravel()             # <<<<<<<<<<<<<<
 *             scan_index = scan((r != 0).astype(dtype))
 *             count_nonzero = int(scan_index[-1])
 */
  /*else*/ {
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->ravel(__pyx_v_self, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 962, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":963
 *         else:
 *             r = self.ravel()
 *             scan_index = scan((r != 0).astype(dtype))             # <<<<<<<<<<<<<<
 *             count_nonzero = int(scan_index[-1])
 *         ndim = max(self._shape.size(), 1)
 */
    __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_r), __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 963, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_astype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 963, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_1) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 963, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_dtype};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 963, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_dtype};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 963, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 963, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL;
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_dtype);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 963, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 963, __pyx_L1_error)
    __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core_scan(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2), 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 963, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_scan_index = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":964
 *             r = self.ravel()
 *             scan_index = scan((r != 0).astype(dtype))
 *             count_nonzero = int(scan_index[-1])             # <<<<<<<<<<<<<<
 *         ndim = max(self._shape.size(), 1)
 *         if count_nonzero == 0:
 */
    __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_v_scan_index), -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 964, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 964, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 964, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_count_nonzero = __pyx_t_6;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":965
 *             scan_index = scan((r != 0).astype(dtype))
 *             count_nonzero = int(scan_index[-1])
 *         ndim = max(self._shape.size(), 1)             # <<<<<<<<<<<<<<
 *         if count_nonzero == 0:
 *             return (ndarray((0,), dtype=dtype),) * ndim
 */
  __pyx_t_7 = 1;
  __pyx_t_8 = __pyx_v_self->_shape.size();
  if (((__pyx_t_7 > __pyx_t_8) != 0)) {
    __pyx_t_9 = __pyx_t_7;
  } else {
    __pyx_t_9 = __pyx_t_8;
  }
  __pyx_v_ndim = __pyx_t_9;

  /* "cupy/core/core.pyx":966
 *             count_nonzero = int(scan_index[-1])
 *         ndim = max(self._shape.size(), 1)
 *         if count_nonzero == 0:             # <<<<<<<<<<<<<<
 *             return (ndarray((0,), dtype=dtype),) * ndim
 * 
 */
  __pyx_t_3 = ((__pyx_v_count_nonzero == 0) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":967
 *         ndim = max(self._shape.size(), 1)
 *         if count_nonzero == 0:
 *             return (ndarray((0,), dtype=dtype),) * ndim             # <<<<<<<<<<<<<<
 * 
 *         dst = ndarray((count_nonzero * ndim,), dtype=dtype)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 967, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 967, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_tuple__32, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 967, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1 * ((__pyx_v_ndim<0) ? 0:__pyx_v_ndim)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 967, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    { Py_ssize_t __pyx_temp;
      for (__pyx_temp=0; __pyx_temp < __pyx_v_ndim; __pyx_temp++) {
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_2, __pyx_temp, __pyx_t_4);
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":966
 *             count_nonzero = int(scan_index[-1])
 *         ndim = max(self._shape.size(), 1)
 *         if count_nonzero == 0:             # <<<<<<<<<<<<<<
 *             return (ndarray((0,), dtype=dtype),) * ndim
 * 
 */
  }

  /* "cupy/core/core.pyx":969
 *             return (ndarray((0,), dtype=dtype),) * ndim
 * 
 *         dst = ndarray((count_nonzero * ndim,), dtype=dtype)             # <<<<<<<<<<<<<<
 *         if ndim <= 1:
 *             kern = _nonzero_1d_kernel(self.dtype, dtype)
 */
  __pyx_t_2 = PyInt_FromSsize_t((__pyx_v_count_nonzero * __pyx_v_ndim)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 969, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 969, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 969, __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 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 969, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 969, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 969, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_dst = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":970
 * 
 *         dst = ndarray((count_nonzero * ndim,), dtype=dtype)
 *         if ndim <= 1:             # <<<<<<<<<<<<<<
 *             kern = _nonzero_1d_kernel(self.dtype, dtype)
 *             kern.linear_launch(self.size, (r, scan_index, dst))
 */
  __pyx_t_3 = ((__pyx_v_ndim <= 1) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":971
 *         dst = ndarray((count_nonzero * ndim,), dtype=dtype)
 *         if ndim <= 1:
 *             kern = _nonzero_1d_kernel(self.dtype, dtype)             # <<<<<<<<<<<<<<
 *             kern.linear_launch(self.size, (r, scan_index, dst))
 *             return dst,
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_nonzero_1d_kernel); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_self->dtype, __pyx_v_dtype};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 971, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_self->dtype, __pyx_v_dtype};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 971, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 971, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_v_self->dtype);
      PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_10, __pyx_v_self->dtype);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_10, __pyx_v_dtype);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 971, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_kern = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":972
 *         if ndim <= 1:
 *             kern = _nonzero_1d_kernel(self.dtype, dtype)
 *             kern.linear_launch(self.size, (r, scan_index, dst))             # <<<<<<<<<<<<<<
 *             return dst,
 *         else:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_kern, __pyx_n_s_linear_launch); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(!__pyx_v_r)) { __Pyx_RaiseUnboundLocalError("r"); __PYX_ERR(0, 972, __pyx_L1_error) }
    if (unlikely(!__pyx_v_scan_index)) { __Pyx_RaiseUnboundLocalError("scan_index"); __PYX_ERR(0, 972, __pyx_L1_error) }
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_r));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_r));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_scan_index));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_scan_index));
    PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_scan_index));
    __Pyx_INCREF(((PyObject *)__pyx_v_dst));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_dst));
    PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_dst));
    __pyx_t_11 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_1, __pyx_t_2};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 972, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_1, __pyx_t_2};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 972, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 972, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_11) {
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_10, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_10, __pyx_t_2);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 972, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":973
 *             kern = _nonzero_1d_kernel(self.dtype, dtype)
 *             kern.linear_launch(self.size, (r, scan_index, dst))
 *             return dst,             # <<<<<<<<<<<<<<
 *         else:
 *             kern = _nonzero_kernel(self.dtype, ndim, dtype, dtype)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 973, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_v_dst));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_dst));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_dst));
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":970
 * 
 *         dst = ndarray((count_nonzero * ndim,), dtype=dtype)
 *         if ndim <= 1:             # <<<<<<<<<<<<<<
 *             kern = _nonzero_1d_kernel(self.dtype, dtype)
 *             kern.linear_launch(self.size, (r, scan_index, dst))
 */
  }

  /* "cupy/core/core.pyx":975
 *             return dst,
 *         else:
 *             kern = _nonzero_kernel(self.dtype, ndim, dtype, dtype)             # <<<<<<<<<<<<<<
 *             kern.linear_launch(self.size,
 *                                (r, Indexer(self.shape), scan_index, dst))
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_nonzero_kernel); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 975, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 975, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_2 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_2, __pyx_v_self->dtype, __pyx_t_12, __pyx_v_dtype, __pyx_v_dtype};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 975, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_2, __pyx_v_self->dtype, __pyx_t_12, __pyx_v_dtype, __pyx_v_dtype};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 975, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 975, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_v_self->dtype);
      PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_10, __pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_10, __pyx_t_12);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_10, __pyx_v_dtype);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_1, 3+__pyx_t_10, __pyx_v_dtype);
      __pyx_t_12 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 975, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_kern = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":976
 *         else:
 *             kern = _nonzero_kernel(self.dtype, ndim, dtype, dtype)
 *             kern.linear_launch(self.size,             # <<<<<<<<<<<<<<
 *                                (r, Indexer(self.shape), scan_index, dst))
 *             return tuple([dst[i::ndim] for i in range(ndim)])
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_kern, __pyx_n_s_linear_launch); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 976, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 976, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "cupy/core/core.pyx":977
 *             kern = _nonzero_kernel(self.dtype, ndim, dtype, dtype)
 *             kern.linear_launch(self.size,
 *                                (r, Indexer(self.shape), scan_index, dst))             # <<<<<<<<<<<<<<
 *             return tuple([dst[i::ndim] for i in range(ndim)])
 * 
 */
    if (unlikely(!__pyx_v_r)) { __Pyx_RaiseUnboundLocalError("r"); __PYX_ERR(0, 977, __pyx_L1_error) }
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 977, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 977, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_t_2, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 977, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_v_scan_index)) { __Pyx_RaiseUnboundLocalError("scan_index"); __PYX_ERR(0, 977, __pyx_L1_error) }
    __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 977, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_r));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_r));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_r));
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_12);
    __Pyx_INCREF(((PyObject *)__pyx_v_scan_index));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_scan_index));
    PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_scan_index));
    __Pyx_INCREF(((PyObject *)__pyx_v_dst));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_dst));
    PyTuple_SET_ITEM(__pyx_t_2, 3, ((PyObject *)__pyx_v_dst));
    __pyx_t_12 = 0;
    __pyx_t_12 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_t_1, __pyx_t_2};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 976, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_t_1, __pyx_t_2};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 976, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 976, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_12) {
        __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_12); __pyx_t_12 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_2);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 976, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":978
 *             kern.linear_launch(self.size,
 *                                (r, Indexer(self.shape), scan_index, dst))
 *             return tuple([dst[i::ndim] for i in range(ndim)])             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement compress
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 978, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __pyx_v_ndim;
    for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_6; __pyx_t_13+=1) {
      __pyx_v_i = __pyx_t_13;
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 978, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_11 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 978, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_2 = PySlice_New(__pyx_t_4, Py_None, __pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 978, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = PyObject_GetItem(((PyObject *)__pyx_v_dst), __pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 978, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_11))) __PYX_ERR(0, 978, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __pyx_t_11 = PyList_AsTuple(((PyObject*)__pyx_t_5)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 978, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_t_11;
    __pyx_t_11 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":944
 *     # TODO(okuta): Implement searchsorted
 * 
 *     def nonzero(self):             # <<<<<<<<<<<<<<
 *         """Return the indices of the elements that are non-zero.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core.ndarray.nonzero", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF((PyObject *)__pyx_v_r);
  __Pyx_XDECREF((PyObject *)__pyx_v_scan_index);
  __Pyx_XDECREF((PyObject *)__pyx_v_dst);
  __Pyx_XDECREF(__pyx_v_kern);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":982
 *     # TODO(okuta): Implement compress
 * 
 *     cpdef ndarray diagonal(self, offset=0, axis1=0, axis2=1):             # <<<<<<<<<<<<<<
 *         """Returns a view of the specified diagonals.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_51diagonal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_diagonal(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_diagonal *__pyx_optional_args) {
  PyObject *__pyx_v_offset = ((PyObject *)__pyx_int_0);
  PyObject *__pyx_v_axis1 = ((PyObject *)__pyx_int_0);
  PyObject *__pyx_v_axis2 = ((PyObject *)__pyx_int_1);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  struct __pyx_opt_args_4cupy_4core_4core__diagonal __pyx_t_10;
  __Pyx_RefNannySetupContext("diagonal", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_offset = __pyx_optional_args->offset;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_axis1 = __pyx_optional_args->axis1;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_axis2 = __pyx_optional_args->axis2;
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_diagonal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 982, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_51diagonal)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_offset, __pyx_v_axis1, __pyx_v_axis2};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 982, __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, 982, __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, 982, __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, 982, __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, 982, __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":990
 * 
 *         """
 *         return _diagonal(self, offset, axis1, axis2)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_v_offset); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 990, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_v_axis1); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 990, __pyx_L1_error)
  __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_v_axis2); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 990, __pyx_L1_error)
  __pyx_t_10.__pyx_n = 3;
  __pyx_t_10.offset = __pyx_t_7;
  __pyx_t_10.axis1 = __pyx_t_8;
  __pyx_t_10.axis2 = __pyx_t_9;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__diagonal(__pyx_v_self, 0, &__pyx_t_10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 990, __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":982
 *     # TODO(okuta): Implement compress
 * 
 *     cpdef ndarray diagonal(self, offset=0, axis1=0, axis2=1):             # <<<<<<<<<<<<<<
 *         """Returns a view of the specified diagonals.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.diagonal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_51diagonal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_50diagonal[] = "ndarray.diagonal(self, offset=0, axis1=0, axis2=1) -> ndarray\nReturns a view of the specified diagonals.\n\n        .. seealso::\n           :func:`cupy.diagonal` for full documentation,\n           :meth:`numpy.ndarray.diagonal`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_51diagonal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_offset = 0;
  PyObject *__pyx_v_axis1 = 0;
  PyObject *__pyx_v_axis2 = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("diagonal (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_offset,&__pyx_n_s_axis1,&__pyx_n_s_axis2,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)__pyx_int_0);
    values[1] = ((PyObject *)__pyx_int_0);
    values[2] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_offset);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis1);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 982, __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, 982, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.diagonal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_50diagonal(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_offset, __pyx_v_axis1, __pyx_v_axis2);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_50diagonal(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_offset, PyObject *__pyx_v_axis1, PyObject *__pyx_v_axis2) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_diagonal __pyx_t_2;
  __Pyx_RefNannySetupContext("diagonal", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.offset = __pyx_v_offset;
  __pyx_t_2.axis1 = __pyx_v_axis1;
  __pyx_t_2.axis2 = __pyx_v_axis2;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->diagonal(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 982, __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":995
 *     # Calculation
 *     # -------------------------------------------------------------------------
 *     cpdef ndarray max(self, axis=None, out=None, dtype=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the maximum along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_53max(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_max(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_max *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("max", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_out = __pyx_optional_args->out;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_dtype = __pyx_optional_args->dtype;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_keepdims = __pyx_optional_args->keepdims;
          }
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_max); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 995, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_53max)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 995, __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, 995, __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, 995, __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, 995, __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, 995, __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":1003
 * 
 *         """
 *         return _amax(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_amax); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1003, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":1004
 *         """
 *         return _amax(
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray argmax(self, axis=None, out=None, dtype=None,
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1003, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1004, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 1004, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 1004, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 1004, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 1004, __pyx_L1_error)

  /* "cupy/core/core.pyx":1003
 * 
 *         """
 *         return _amax(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1003, __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, 1003, __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":995
 *     # Calculation
 *     # -------------------------------------------------------------------------
 *     cpdef ndarray max(self, axis=None, out=None, dtype=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the maximum along a given axis.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.max", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_53max(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_52max[] = "ndarray.max(self, axis=None, out=None, dtype=None, keepdims=False) -> ndarray\nReturns the maximum along a given axis.\n\n        .. seealso::\n           :func:`cupy.amax` for full documentation,\n           :meth:`numpy.ndarray.max`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_53max(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("max (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_out,&__pyx_n_s_dtype,&__pyx_n_s_keepdims,0};
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "max") < 0)) __PYX_ERR(0, 995, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_axis = values[0];
    __pyx_v_out = values[1];
    __pyx_v_dtype = values[2];
    __pyx_v_keepdims = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("max", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 995, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.max", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_52max(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_52max(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_dtype, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_max __pyx_t_2;
  __Pyx_RefNannySetupContext("max", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->max(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 995, __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":1006
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray argmax(self, axis=None, out=None, dtype=None,             # <<<<<<<<<<<<<<
 *                          keepdims=False):
 *         """Returns the indices of the maximum along a given axis.
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_55argmax(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_argmax(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmax *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);

  /* "cupy/core/core.pyx":1007
 * 
 *     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":1006
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray argmax(self, axis=None, out=None, dtype=None,             # <<<<<<<<<<<<<<
 *                          keepdims=False):
 *         """Returns the indices of the maximum along a given axis.
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_argmax); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1006, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_55argmax)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1006, __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, 1006, __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, 1006, __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, 1006, __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, 1006, __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":1015
 * 
 *         """
 *         return _argmax(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":1016
 *         """
 *         return _argmax(
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray min(self, axis=None, out=None, dtype=None, keepdims=False):
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1016, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 1016, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 1016, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 1016, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 1016, __pyx_L1_error)

  /* "cupy/core/core.pyx":1015
 * 
 *         """
 *         return _argmax(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__argmax, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1015, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1006
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray argmax(self, axis=None, out=None, dtype=None,             # <<<<<<<<<<<<<<
 *                          keepdims=False):
 *         """Returns the indices of the maximum along a given axis.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.argmax", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_55argmax(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_54argmax[] = "ndarray.argmax(self, axis=None, out=None, dtype=None, keepdims=False) -> ndarray\nReturns the indices of the maximum along a given axis.\n\n        .. seealso::\n           :func:`cupy.argmax` for full documentation,\n           :meth:`numpy.ndarray.argmax`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_55argmax(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argmax (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_out,&__pyx_n_s_dtype,&__pyx_n_s_keepdims,0};
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);

    /* "cupy/core/core.pyx":1007
 * 
 *     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 = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 1006, __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, 1006, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.argmax", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_54argmax(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims);

  /* "cupy/core/core.pyx":1006
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray argmax(self, axis=None, out=None, dtype=None,             # <<<<<<<<<<<<<<
 *                          keepdims=False):
 *         """Returns the indices of the maximum along a given axis.
 */

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_54argmax(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_dtype, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmax __pyx_t_2;
  __Pyx_RefNannySetupContext("argmax", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->argmax(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1006, __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":1018
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray min(self, axis=None, out=None, dtype=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the minimum along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_57min(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_min(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_min *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("min", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_out = __pyx_optional_args->out;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_dtype = __pyx_optional_args->dtype;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_keepdims = __pyx_optional_args->keepdims;
          }
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_min); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1018, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_57min)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1018, __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, 1018, __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, 1018, __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, 1018, __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, 1018, __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":1026
 * 
 *         """
 *         return _amin(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_amin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1026, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":1027
 *         """
 *         return _amin(
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray argmin(self, axis=None, out=None, dtype=None,
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1026, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1027, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 1027, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 1027, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 1027, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 1027, __pyx_L1_error)

  /* "cupy/core/core.pyx":1026
 * 
 *         """
 *         return _amin(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1026, __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, 1026, __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":1018
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray min(self, axis=None, out=None, dtype=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the minimum along a given axis.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.min", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_57min(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_56min[] = "ndarray.min(self, axis=None, out=None, dtype=None, keepdims=False) -> ndarray\nReturns the minimum along a given axis.\n\n        .. seealso::\n           :func:`cupy.amin` for full documentation,\n           :meth:`numpy.ndarray.min`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_57min(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("min (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_out,&__pyx_n_s_dtype,&__pyx_n_s_keepdims,0};
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "min") < 0)) __PYX_ERR(0, 1018, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_axis = values[0];
    __pyx_v_out = values[1];
    __pyx_v_dtype = values[2];
    __pyx_v_keepdims = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("min", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1018, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.min", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_56min(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_56min(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_dtype, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_min __pyx_t_2;
  __Pyx_RefNannySetupContext("min", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->min(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1018, __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":1029
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray argmin(self, axis=None, out=None, dtype=None,             # <<<<<<<<<<<<<<
 *                          keepdims=False):
 *         """Returns the indices of the minimum along a given axis.
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_59argmin(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_argmin(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmin *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);

  /* "cupy/core/core.pyx":1030
 * 
 *     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":1029
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray argmin(self, axis=None, out=None, dtype=None,             # <<<<<<<<<<<<<<
 *                          keepdims=False):
 *         """Returns the indices of the minimum along a given axis.
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_argmin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1029, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_59argmin)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1029, __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, 1029, __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, 1029, __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, 1029, __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, 1029, __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":1038
 * 
 *         """
 *         return _argmin(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":1039
 *         """
 *         return _argmin(
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement ptp
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1038, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1039, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 1039, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 1039, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 1039, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 1039, __pyx_L1_error)

  /* "cupy/core/core.pyx":1038
 * 
 *         """
 *         return _argmin(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__argmin, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1038, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1038, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1029
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray argmin(self, axis=None, out=None, dtype=None,             # <<<<<<<<<<<<<<
 *                          keepdims=False):
 *         """Returns the indices of the minimum along a given axis.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.argmin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_59argmin(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_58argmin[] = "ndarray.argmin(self, axis=None, out=None, dtype=None, keepdims=False) -> ndarray\nReturns the indices of the minimum along a given axis.\n\n        .. seealso::\n           :func:`cupy.argmin` for full documentation,\n           :meth:`numpy.ndarray.argmin`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_59argmin(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argmin (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_out,&__pyx_n_s_dtype,&__pyx_n_s_keepdims,0};
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);

    /* "cupy/core/core.pyx":1030
 * 
 *     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 = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 1029, __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, 1029, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.argmin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_58argmin(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims);

  /* "cupy/core/core.pyx":1029
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray argmin(self, axis=None, out=None, dtype=None,             # <<<<<<<<<<<<<<
 *                          keepdims=False):
 *         """Returns the indices of the minimum along a given axis.
 */

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_58argmin(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_dtype, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmin __pyx_t_2;
  __Pyx_RefNannySetupContext("argmin", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->argmin(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1029, __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":1043
 *     # TODO(okuta): Implement ptp
 * 
 *     cpdef ndarray clip(self, a_min=None, a_max=None, out=None):             # <<<<<<<<<<<<<<
 *         """Returns an array with values limited to [a_min, a_max].
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_61clip(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_clip(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_clip *__pyx_optional_args) {
  PyObject *__pyx_v_a_min = ((PyObject *)Py_None);
  PyObject *__pyx_v_a_max = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("clip", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_a_min = __pyx_optional_args->a_min;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_a_max = __pyx_optional_args->a_max;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
        }
      }
    }
  }
  __Pyx_INCREF(__pyx_v_a_min);
  __Pyx_INCREF(__pyx_v_a_max);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clip); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1043, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_61clip)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_a_min, __pyx_v_a_max, __pyx_v_out};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1043, __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, 1043, __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, 1043, __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, 1043, __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, 1043, __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":1051
 * 
 *         """
 *         if a_min is None and a_max is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('array_clip: must set either max or min')
 *         if a_min is None:
 */
  __pyx_t_8 = (__pyx_v_a_min == Py_None);
  __pyx_t_9 = (__pyx_t_8 != 0);
  if (__pyx_t_9) {
  } else {
    __pyx_t_7 = __pyx_t_9;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_9 = (__pyx_v_a_max == Py_None);
  __pyx_t_8 = (__pyx_t_9 != 0);
  __pyx_t_7 = __pyx_t_8;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":1052
 *         """
 *         if a_min is None and a_max is None:
 *             raise ValueError('array_clip: must set either max or min')             # <<<<<<<<<<<<<<
 *         if a_min is None:
 *             if issubclass(self.dtype.type, numpy.floating):
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1052, __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, 1052, __pyx_L1_error)

    /* "cupy/core/core.pyx":1051
 * 
 *         """
 *         if a_min is None and a_max is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('array_clip: must set either max or min')
 *         if a_min is None:
 */
  }

  /* "cupy/core/core.pyx":1053
 *         if a_min is None and a_max is None:
 *             raise ValueError('array_clip: must set either max or min')
 *         if a_min is None:             # <<<<<<<<<<<<<<
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_min = self.dtype.type('-inf')
 */
  __pyx_t_7 = (__pyx_v_a_min == Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1054
 *             raise ValueError('array_clip: must set either max or min')
 *         if a_min is None:
 *             if issubclass(self.dtype.type, numpy.floating):             # <<<<<<<<<<<<<<
 *                 a_min = self.dtype.type('-inf')
 *             elif issubclass(self.dtype.type, numpy.integer):
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1054, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1054, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_floating); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1054, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_8 = PyObject_IsSubclass(__pyx_t_1, __pyx_t_3); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 1054, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = (__pyx_t_8 != 0);
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":1055
 *         if a_min is None:
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_min = self.dtype.type('-inf')             # <<<<<<<<<<<<<<
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_min = numpy.iinfo(self.dtype.type).min
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1055, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1055, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF_SET(__pyx_v_a_min, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":1054
 *             raise ValueError('array_clip: must set either max or min')
 *         if a_min is None:
 *             if issubclass(self.dtype.type, numpy.floating):             # <<<<<<<<<<<<<<
 *                 a_min = self.dtype.type('-inf')
 *             elif issubclass(self.dtype.type, numpy.integer):
 */
      goto __pyx_L7;
    }

    /* "cupy/core/core.pyx":1056
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_min = self.dtype.type('-inf')
 *             elif issubclass(self.dtype.type, numpy.integer):             # <<<<<<<<<<<<<<
 *                 a_min = numpy.iinfo(self.dtype.type).min
 *         if a_max is None:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1056, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1056, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_integer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1056, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = PyObject_IsSubclass(__pyx_t_1, __pyx_t_2); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1056, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_8 = (__pyx_t_7 != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":1057
 *                 a_min = self.dtype.type('-inf')
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_min = numpy.iinfo(self.dtype.type).min             # <<<<<<<<<<<<<<
 *         if a_max is None:
 *             if issubclass(self.dtype.type, numpy.floating):
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1057, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_iinfo); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1057, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1057, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_6) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1057, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_1};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1057, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_1};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1057, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        {
          __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1057, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_1);
          __pyx_t_1 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1057, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_min); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1057, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_a_min, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":1056
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_min = self.dtype.type('-inf')
 *             elif issubclass(self.dtype.type, numpy.integer):             # <<<<<<<<<<<<<<
 *                 a_min = numpy.iinfo(self.dtype.type).min
 *         if a_max is None:
 */
    }
    __pyx_L7:;

    /* "cupy/core/core.pyx":1053
 *         if a_min is None and a_max is None:
 *             raise ValueError('array_clip: must set either max or min')
 *         if a_min is None:             # <<<<<<<<<<<<<<
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_min = self.dtype.type('-inf')
 */
  }

  /* "cupy/core/core.pyx":1058
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_min = numpy.iinfo(self.dtype.type).min
 *         if a_max is None:             # <<<<<<<<<<<<<<
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_max = self.dtype.type('inf')
 */
  __pyx_t_8 = (__pyx_v_a_max == Py_None);
  __pyx_t_7 = (__pyx_t_8 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":1059
 *                 a_min = numpy.iinfo(self.dtype.type).min
 *         if a_max is None:
 *             if issubclass(self.dtype.type, numpy.floating):             # <<<<<<<<<<<<<<
 *                 a_max = self.dtype.type('inf')
 *             elif issubclass(self.dtype.type, numpy.integer):
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1059, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1059, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_floating); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1059, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = PyObject_IsSubclass(__pyx_t_3, __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1059, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = (__pyx_t_7 != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":1060
 *         if a_max is None:
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_max = self.dtype.type('inf')             # <<<<<<<<<<<<<<
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_max = numpy.iinfo(self.dtype.type).max
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1060, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1060, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_a_max, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":1059
 *                 a_min = numpy.iinfo(self.dtype.type).min
 *         if a_max is None:
 *             if issubclass(self.dtype.type, numpy.floating):             # <<<<<<<<<<<<<<
 *                 a_max = self.dtype.type('inf')
 *             elif issubclass(self.dtype.type, numpy.integer):
 */
      goto __pyx_L9;
    }

    /* "cupy/core/core.pyx":1061
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_max = self.dtype.type('inf')
 *             elif issubclass(self.dtype.type, numpy.integer):             # <<<<<<<<<<<<<<
 *                 a_max = numpy.iinfo(self.dtype.type).max
 *         return _clip(self, a_min, a_max, out=out)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1061, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1061, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_integer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1061, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = PyObject_IsSubclass(__pyx_t_3, __pyx_t_2); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 1061, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = (__pyx_t_8 != 0);
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":1062
 *                 a_max = self.dtype.type('inf')
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_max = numpy.iinfo(self.dtype.type).max             # <<<<<<<<<<<<<<
 *         return _clip(self, a_min, a_max, out=out)
 * 
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1062, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_iinfo); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1062, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1062, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_1) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1062, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_3};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1062, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_3};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1062, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1062, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1062, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_max); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1062, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_a_max, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":1061
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_max = self.dtype.type('inf')
 *             elif issubclass(self.dtype.type, numpy.integer):             # <<<<<<<<<<<<<<
 *                 a_max = numpy.iinfo(self.dtype.type).max
 *         return _clip(self, a_min, a_max, out=out)
 */
    }
    __pyx_L9:;

    /* "cupy/core/core.pyx":1058
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_min = numpy.iinfo(self.dtype.type).min
 *         if a_max is None:             # <<<<<<<<<<<<<<
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_max = self.dtype.type('inf')
 */
  }

  /* "cupy/core/core.pyx":1063
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_max = numpy.iinfo(self.dtype.type).max
 *         return _clip(self, a_min, a_max, out=out)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement round
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_clip_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1063, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1063, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_INCREF(__pyx_v_a_min);
  __Pyx_GIVEREF(__pyx_v_a_min);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_a_min);
  __Pyx_INCREF(__pyx_v_a_max);
  __Pyx_GIVEREF(__pyx_v_a_max);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_a_max);
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1063, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 1063, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1063, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1063, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1043
 *     # TODO(okuta): Implement ptp
 * 
 *     cpdef ndarray clip(self, a_min=None, a_max=None, out=None):             # <<<<<<<<<<<<<<
 *         """Returns an array with values limited to [a_min, a_max].
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.clip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_a_min);
  __Pyx_XDECREF(__pyx_v_a_max);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_61clip(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_60clip[] = "ndarray.clip(self, a_min=None, a_max=None, out=None) -> ndarray\nReturns an array with values limited to [a_min, a_max].\n\n        .. seealso::\n           :func:`cupy.clip` for full documentation,\n           :meth:`numpy.ndarray.clip`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_61clip(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_a_min = 0;
  PyObject *__pyx_v_a_max = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clip (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a_min,&__pyx_n_s_a_max,&__pyx_n_s_out,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a_min);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a_max);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 1043, __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, 1043, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.clip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_60clip(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_a_min, __pyx_v_a_max, __pyx_v_out);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_60clip(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_a_min, PyObject *__pyx_v_a_max, PyObject *__pyx_v_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_clip __pyx_t_2;
  __Pyx_RefNannySetupContext("clip", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.a_min = __pyx_v_a_min;
  __pyx_t_2.a_max = __pyx_v_a_max;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->clip(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1043, __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":1067
 *     # TODO(okuta): Implement round
 * 
 *     cpdef ndarray trace(self, offset=0, axis1=0, axis2=1, dtype=None,             # <<<<<<<<<<<<<<
 *                         out=None):
 *         """Returns the sum along diagonals of the array.
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_63trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_trace(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_trace *__pyx_optional_args) {
  PyObject *__pyx_v_offset = ((PyObject *)__pyx_int_0);
  PyObject *__pyx_v_axis1 = ((PyObject *)__pyx_int_0);
  PyObject *__pyx_v_axis2 = ((PyObject *)__pyx_int_1);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);

  /* "cupy/core/core.pyx":1068
 * 
 *     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":1067
 *     # TODO(okuta): Implement round
 * 
 *     cpdef ndarray trace(self, offset=0, axis1=0, axis2=1, dtype=None,             # <<<<<<<<<<<<<<
 *                         out=None):
 *         """Returns the sum along diagonals of the array.
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1067, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_63trace)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_v_offset, __pyx_v_axis1, __pyx_v_axis2, __pyx_v_dtype, __pyx_v_out};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1067, __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, 1067, __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, 1067, __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, 1067, __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, 1067, __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":1076
 * 
 *         """
 *         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, 1076, __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":1077
 *         """
 *         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, 1077, __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":1067
 *     # TODO(okuta): Implement round
 * 
 *     cpdef ndarray trace(self, offset=0, axis1=0, axis2=1, dtype=None,             # <<<<<<<<<<<<<<
 *                         out=None):
 *         """Returns the sum along diagonals of the array.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.trace", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_d);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_63trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_62trace[] = "ndarray.trace(self, offset=0, axis1=0, axis2=1, dtype=None, out=None) -> ndarray\nReturns the sum along diagonals of the array.\n\n        .. seealso::\n           :func:`cupy.trace` for full documentation,\n           :meth:`numpy.ndarray.trace`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_63trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_offset = 0;
  PyObject *__pyx_v_axis1 = 0;
  PyObject *__pyx_v_axis2 = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("trace (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_offset,&__pyx_n_s_axis1,&__pyx_n_s_axis2,&__pyx_n_s_dtype,&__pyx_n_s_out,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[0] = ((PyObject *)__pyx_int_0);
    values[1] = ((PyObject *)__pyx_int_0);
    values[2] = ((PyObject *)__pyx_int_1);
    values[3] = ((PyObject *)Py_None);

    /* "cupy/core/core.pyx":1068
 * 
 *     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 = PyDict_GetItem(__pyx_kwds, __pyx_n_s_offset);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis1);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis2);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 1067, __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, 1067, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.trace", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_62trace(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_offset, __pyx_v_axis1, __pyx_v_axis2, __pyx_v_dtype, __pyx_v_out);

  /* "cupy/core/core.pyx":1067
 *     # TODO(okuta): Implement round
 * 
 *     cpdef ndarray trace(self, offset=0, axis1=0, axis2=1, dtype=None,             # <<<<<<<<<<<<<<
 *                         out=None):
 *         """Returns the sum along diagonals of the array.
 */

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_62trace(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_offset, PyObject *__pyx_v_axis1, PyObject *__pyx_v_axis2, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_trace __pyx_t_2;
  __Pyx_RefNannySetupContext("trace", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 5;
  __pyx_t_2.offset = __pyx_v_offset;
  __pyx_t_2.axis1 = __pyx_v_axis1;
  __pyx_t_2.axis2 = __pyx_v_axis2;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->trace(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1067, __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":1079
 *         return d.sum(-1, dtype, out, False)
 * 
 *     cpdef ndarray sum(self, axis=None, dtype=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the sum along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_65sum(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_sum(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sum *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __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, 1079, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_65sum)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1079, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[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, 1079, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1079, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_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, 1079, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1079, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1087
 * 
 *         """
 *         return _sum(self, axis, dtype, out, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement cumsum
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_sum_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1087, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[6] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 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[6] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1087, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1087, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_axis);
    __Pyx_GIVEREF(__pyx_v_axis);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_axis);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_dtype);
    __Pyx_INCREF(__pyx_v_out);
    __Pyx_GIVEREF(__pyx_v_out);
    PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_out);
    __Pyx_INCREF(__pyx_v_keepdims);
    __Pyx_GIVEREF(__pyx_v_keepdims);
    PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_5, __pyx_v_keepdims);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1087, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1087, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1079
 *         return d.sum(-1, dtype, out, False)
 * 
 *     cpdef ndarray sum(self, axis=None, dtype=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the sum along a given axis.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.sum", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_65sum(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_64sum[] = "ndarray.sum(self, axis=None, dtype=None, out=None, keepdims=False) -> ndarray\nReturns the sum along a given axis.\n\n        .. seealso::\n           :func:`cupy.sum` for full documentation,\n           :meth:`numpy.ndarray.sum`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_65sum(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sum (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_dtype,&__pyx_n_s_out,&__pyx_n_s_keepdims,0};
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 1079, __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, 1079, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.sum", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_64sum(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_64sum(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sum __pyx_t_2;
  __Pyx_RefNannySetupContext("sum", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->sum(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1079, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.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":1091
 *     # TODO(okuta): Implement cumsum
 * 
 *     cpdef ndarray mean(self, axis=None, dtype=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the mean along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_67mean(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_mean(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_mean *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("mean", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_dtype = __pyx_optional_args->dtype;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_keepdims = __pyx_optional_args->keepdims;
          }
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_mean); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1091, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_67mean)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1091, __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, 1091, __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, 1091, __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, 1091, __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, 1091, __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":1099
 * 
 *         """
 *         return _mean(self, axis=axis, dtype=dtype, out=out, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray var(self, axis=None, dtype=None, out=None, ddof=0,
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1099, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1099, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 1099, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 1099, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 1099, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 1099, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__mean, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1099, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1099, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1091
 *     # TODO(okuta): Implement cumsum
 * 
 *     cpdef ndarray mean(self, axis=None, dtype=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the mean along a given axis.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.mean", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_67mean(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_66mean[] = "ndarray.mean(self, axis=None, dtype=None, out=None, keepdims=False) -> ndarray\nReturns the mean along a given axis.\n\n        .. seealso::\n           :func:`cupy.mean` for full documentation,\n           :meth:`numpy.ndarray.mean`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_67mean(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("mean (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_dtype,&__pyx_n_s_out,&__pyx_n_s_keepdims,0};
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 1091, __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, 1091, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.mean", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_66mean(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_66mean(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_mean __pyx_t_2;
  __Pyx_RefNannySetupContext("mean", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->mean(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1091, __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":1101
 *         return _mean(self, axis=axis, dtype=dtype, out=out, keepdims=keepdims)
 * 
 *     cpdef ndarray var(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the variance along a given axis.
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_69var(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_var(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_var *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_ddof = ((PyObject *)__pyx_int_0);

  /* "cupy/core/core.pyx":1102
 * 
 *     cpdef ndarray var(self, axis=None, dtype=None, out=None, ddof=0,
 *                       keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the variance along a given axis.
 * 
 */
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__var __pyx_t_7;
  __Pyx_RefNannySetupContext("var", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_dtype = __pyx_optional_args->dtype;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_ddof = __pyx_optional_args->ddof;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_keepdims = __pyx_optional_args->keepdims;
            }
          }
        }
      }
    }
  }

  /* "cupy/core/core.pyx":1101
 *         return _mean(self, axis=axis, dtype=dtype, out=out, keepdims=keepdims)
 * 
 *     cpdef ndarray var(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the variance along a given axis.
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_var); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1101, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_69var)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_ddof, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1101, __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, 1101, __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, 1101, __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, 1101, __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, 1101, __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":1110
 * 
 *         """
 *         return _var(self, axis=axis, dtype=dtype, out=out, ddof=ddof,             # <<<<<<<<<<<<<<
 *                     keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":1111
 *         """
 *         return _var(self, axis=axis, dtype=dtype, out=out, ddof=ddof,
 *                     keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray std(self, axis=None, dtype=None, out=None, ddof=0,
 */
  __pyx_t_7.__pyx_n = 5;
  __pyx_t_7.axis = __pyx_v_axis;
  __pyx_t_7.dtype = __pyx_v_dtype;
  __pyx_t_7.out = __pyx_v_out;
  __pyx_t_7.ddof = __pyx_v_ddof;
  __pyx_t_7.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__var(__pyx_v_self, 0, &__pyx_t_7)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1110, __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":1101
 *         return _mean(self, axis=axis, dtype=dtype, out=out, keepdims=keepdims)
 * 
 *     cpdef ndarray var(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the variance along a given axis.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_69var(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_68var[] = "ndarray.var(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False) -> ndarray\nReturns the variance along a given axis.\n\n        .. seealso::\n           :func:`cupy.var` for full documentation,\n           :meth:`numpy.ndarray.var`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_69var(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_ddof = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("var (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_dtype,&__pyx_n_s_out,&__pyx_n_s_ddof,&__pyx_n_s_keepdims,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)__pyx_int_0);

    /* "cupy/core/core.pyx":1102
 * 
 *     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 = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ddof);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 1101, __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, 1101, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_68var(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_ddof, __pyx_v_keepdims);

  /* "cupy/core/core.pyx":1101
 *         return _mean(self, axis=axis, dtype=dtype, out=out, keepdims=keepdims)
 * 
 *     cpdef ndarray var(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the variance along a given axis.
 */

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_68var(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_ddof, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_var __pyx_t_2;
  __Pyx_RefNannySetupContext("var", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 5;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.ddof = __pyx_v_ddof;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->var(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1101, __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":1113
 *                     keepdims=keepdims)
 * 
 *     cpdef ndarray std(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the standard deviation along a given axis.
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_71std(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_std(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_std *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_ddof = ((PyObject *)__pyx_int_0);

  /* "cupy/core/core.pyx":1114
 * 
 *     cpdef ndarray std(self, axis=None, dtype=None, out=None, ddof=0,
 *                       keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the standard deviation along a given axis.
 * 
 */
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__std __pyx_t_7;
  __Pyx_RefNannySetupContext("std", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_dtype = __pyx_optional_args->dtype;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_ddof = __pyx_optional_args->ddof;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_keepdims = __pyx_optional_args->keepdims;
            }
          }
        }
      }
    }
  }

  /* "cupy/core/core.pyx":1113
 *                     keepdims=keepdims)
 * 
 *     cpdef ndarray std(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the standard deviation along a given axis.
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_std); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_71std)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_ddof, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1113, __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, 1113, __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, 1113, __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, 1113, __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, 1113, __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":1122
 * 
 *         """
 *         return _std(self, axis=axis, dtype=dtype, out=out, ddof=ddof,             # <<<<<<<<<<<<<<
 *                     keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":1123
 *         """
 *         return _std(self, axis=axis, dtype=dtype, out=out, ddof=ddof,
 *                     keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray prod(self, axis=None, dtype=None, out=None, keepdims=None):
 */
  __pyx_t_7.__pyx_n = 5;
  __pyx_t_7.axis = __pyx_v_axis;
  __pyx_t_7.dtype = __pyx_v_dtype;
  __pyx_t_7.out = __pyx_v_out;
  __pyx_t_7.ddof = __pyx_v_ddof;
  __pyx_t_7.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__std(((PyObject *)__pyx_v_self), 0, &__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1122, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":1122
 * 
 *         """
 *         return _std(self, axis=axis, dtype=dtype, out=out, ddof=ddof,             # <<<<<<<<<<<<<<
 *                     keepdims=keepdims)
 * 
 */
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1122, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1113
 *                     keepdims=keepdims)
 * 
 *     cpdef ndarray std(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the standard deviation along a given axis.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.std", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_71std(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_70std[] = "ndarray.std(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False) -> ndarray\nReturns the standard deviation along a given axis.\n\n        .. seealso::\n           :func:`cupy.std` for full documentation,\n           :meth:`numpy.ndarray.std`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_71std(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_ddof = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("std (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_dtype,&__pyx_n_s_out,&__pyx_n_s_ddof,&__pyx_n_s_keepdims,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)__pyx_int_0);

    /* "cupy/core/core.pyx":1114
 * 
 *     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 = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ddof);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 1113, __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, 1113, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.std", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_70std(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_ddof, __pyx_v_keepdims);

  /* "cupy/core/core.pyx":1113
 *                     keepdims=keepdims)
 * 
 *     cpdef ndarray std(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the standard deviation along a given axis.
 */

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_70std(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_ddof, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_std __pyx_t_2;
  __Pyx_RefNannySetupContext("std", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 5;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.ddof = __pyx_v_ddof;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->std(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1113, __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":1125
 *                     keepdims=keepdims)
 * 
 *     cpdef ndarray prod(self, axis=None, dtype=None, out=None, keepdims=None):             # <<<<<<<<<<<<<<
 *         """Returns the product along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_73prod(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_prod(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_prod *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __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, 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_73prod)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1125, __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, 1125, __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, 1125, __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, 1125, __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, 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":1133
 * 
 *         """
 *         return _prod(self, axis, dtype, out, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement cumprod
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_prod_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[6] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1133, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[6] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1133, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_axis);
    __Pyx_GIVEREF(__pyx_v_axis);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_axis);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_dtype);
    __Pyx_INCREF(__pyx_v_out);
    __Pyx_GIVEREF(__pyx_v_out);
    PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_out);
    __Pyx_INCREF(__pyx_v_keepdims);
    __Pyx_GIVEREF(__pyx_v_keepdims);
    PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_5, __pyx_v_keepdims);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1133, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1125
 *                     keepdims=keepdims)
 * 
 *     cpdef ndarray prod(self, axis=None, dtype=None, out=None, keepdims=None):             # <<<<<<<<<<<<<<
 *         """Returns the product along a given axis.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.prod", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_73prod(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_72prod[] = "ndarray.prod(self, axis=None, dtype=None, out=None, keepdims=None) -> ndarray\nReturns the product along a given axis.\n\n        .. seealso::\n           :func:`cupy.prod` for full documentation,\n           :meth:`numpy.ndarray.prod`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_73prod(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("prod (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_dtype,&__pyx_n_s_out,&__pyx_n_s_keepdims,0};
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 1125, __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, 1125, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.prod", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_72prod(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_72prod(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_prod __pyx_t_2;
  __Pyx_RefNannySetupContext("prod", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->prod(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 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.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":1137
 *     # TODO(okuta): Implement cumprod
 * 
 *     cpdef ndarray all(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         return _all(self, axis=axis, out=out, keepdims=keepdims)
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_75all(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_all(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_all *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("all", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_out = __pyx_optional_args->out;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_keepdims = __pyx_optional_args->keepdims;
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1137, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_75all)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1137, __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, 1137, __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, 1137, __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, 1137, __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, 1137, __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":1138
 * 
 *     cpdef ndarray all(self, axis=None, out=None, keepdims=False):
 *         return _all(self, axis=axis, out=out, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray any(self, axis=None, out=None, keepdims=False):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_all_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 1138, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 1138, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 1138, __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, 1138, __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, 1138, __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":1137
 *     # TODO(okuta): Implement cumprod
 * 
 *     cpdef ndarray all(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         return _all(self, axis=axis, out=out, keepdims=keepdims)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.all", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_75all(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_74all[] = "ndarray.all(self, axis=None, out=None, keepdims=False) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_75all(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("all (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_out,&__pyx_n_s_keepdims,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 1137, __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, 1137, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.all", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_74all(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_out, __pyx_v_keepdims);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_74all(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_all __pyx_t_2;
  __Pyx_RefNannySetupContext("all", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->all(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1137, __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":1140
 *         return _all(self, axis=axis, out=out, keepdims=keepdims)
 * 
 *     cpdef ndarray any(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         return _any(self, axis=axis, out=out, keepdims=keepdims)
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_77any(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_any(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_any *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("any", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_out = __pyx_optional_args->out;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_keepdims = __pyx_optional_args->keepdims;
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_any); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1140, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_77any)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1140, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_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, 1140, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1140, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_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, 1140, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1140, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1141
 * 
 *     cpdef ndarray any(self, axis=None, out=None, keepdims=False):
 *         return _any(self, axis=axis, out=out, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_any_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 1141, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 1141, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 1141, __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, 1141, __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, 1141, __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":1140
 *         return _all(self, axis=axis, out=out, keepdims=keepdims)
 * 
 *     cpdef ndarray any(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         return _any(self, axis=axis, out=out, keepdims=keepdims)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.any", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_77any(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_76any[] = "ndarray.any(self, axis=None, out=None, keepdims=False) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_77any(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("any (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_out,&__pyx_n_s_keepdims,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 1140, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_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, 1140, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.any", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_76any(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_out, __pyx_v_keepdims);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_76any(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_any __pyx_t_2;
  __Pyx_RefNannySetupContext("any", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->any(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.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":1148
 *     # Comparison operators:
 * 
 *     def __richcmp__(object self, object other, int op):             # <<<<<<<<<<<<<<
 *         if op == 0:
 *             return less(self, other)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_79__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_79__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_78__richcmp__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other), ((int)__pyx_v_op));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_78__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__richcmp__", 0);

  /* "cupy/core/core.pyx":1149
 * 
 *     def __richcmp__(object self, object other, int op):
 *         if op == 0:             # <<<<<<<<<<<<<<
 *             return less(self, other)
 *         if op == 1:
 */
  __pyx_t_1 = ((__pyx_v_op == 0) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1150
 *     def __richcmp__(object self, object other, int op):
 *         if op == 0:
 *             return less(self, other)             # <<<<<<<<<<<<<<
 *         if op == 1:
 *             return less_equal(self, other)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_less); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1150, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_self, __pyx_v_other};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1150, __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_self, __pyx_v_other};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1150, __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, 1150, __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_self);
      __Pyx_GIVEREF(__pyx_v_self);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_self);
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1150, __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":1149
 * 
 *     def __richcmp__(object self, object other, int op):
 *         if op == 0:             # <<<<<<<<<<<<<<
 *             return less(self, other)
 *         if op == 1:
 */
  }

  /* "cupy/core/core.pyx":1151
 *         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":1152
 *             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, 1152, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_self, __pyx_v_other};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1152, __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, __pyx_v_self, __pyx_v_other};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1152, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self);
      __Pyx_GIVEREF(__pyx_v_self);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_self);
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1151
 *         if op == 0:
 *             return less(self, other)
 *         if op == 1:             # <<<<<<<<<<<<<<
 *             return less_equal(self, other)
 *         if op == 2:
 */
  }

  /* "cupy/core/core.pyx":1153
 *         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":1154
 *             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, 1154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_self, __pyx_v_other};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1154, __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_self, __pyx_v_other};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1154, __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, 1154, __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_self);
      __Pyx_GIVEREF(__pyx_v_self);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_self);
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1154, __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":1153
 *         if op == 1:
 *             return less_equal(self, other)
 *         if op == 2:             # <<<<<<<<<<<<<<
 *             return equal(self, other)
 *         if op == 3:
 */
  }

  /* "cupy/core/core.pyx":1155
 *         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":1156
 *             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, 1156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_self, __pyx_v_other};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1156, __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, __pyx_v_self, __pyx_v_other};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1156, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1156, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self);
      __Pyx_GIVEREF(__pyx_v_self);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_self);
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1156, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1155
 *         if op == 2:
 *             return equal(self, other)
 *         if op == 3:             # <<<<<<<<<<<<<<
 *             return not_equal(self, other)
 *         if op == 4:
 */
  }

  /* "cupy/core/core.pyx":1157
 *         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":1158
 *             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, 1158, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_self, __pyx_v_other};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1158, __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_self, __pyx_v_other};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1158, __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, 1158, __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_self);
      __Pyx_GIVEREF(__pyx_v_self);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_self);
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1158, __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":1157
 *         if op == 3:
 *             return not_equal(self, other)
 *         if op == 4:             # <<<<<<<<<<<<<<
 *             return greater(self, other)
 *         if op == 5:
 */
  }

  /* "cupy/core/core.pyx":1159
 *         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":1160
 *             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, 1160, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_self, __pyx_v_other};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1160, __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, __pyx_v_self, __pyx_v_other};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1160, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self);
      __Pyx_GIVEREF(__pyx_v_self);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_self);
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1159
 *         if op == 4:
 *             return greater(self, other)
 *         if op == 5:             # <<<<<<<<<<<<<<
 *             return greater_equal(self, other)
 *         return NotImplemented
 */
  }

  /* "cupy/core/core.pyx":1161
 *         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":1148
 *     # Comparison operators:
 * 
 *     def __richcmp__(object self, object other, int op):             # <<<<<<<<<<<<<<
 *         if op == 0:
 *             return less(self, other)
 */

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

/* "cupy/core/core.pyx":1165
 *     # Truth value of an array (bool):
 * 
 *     def __nonzero__(self):             # <<<<<<<<<<<<<<
 *         if self.size == 0:
 *             return False
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_81__nonzero__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_81__nonzero__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__nonzero__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_80__nonzero__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

static int __pyx_pf_4cupy_4core_4core_7ndarray_80__nonzero__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_v_msg = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__nonzero__", 0);

  /* "cupy/core/core.pyx":1166
 * 
 *     def __nonzero__(self):
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return False
 *         elif self.size == 1:
 */
  switch (__pyx_v_self->size) {
    case 0:

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

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

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

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

    /* "cupy/core/core.pyx":1171
 *             return bool(self.get())
 *         else:
 *             msg = ('The truth value of an array with more than one element is '             # <<<<<<<<<<<<<<
 *                    'ambiguous. Use a.any() or a.all()')
 *             raise ValueError(msg)
 */
    __Pyx_INCREF(__pyx_kp_s_The_truth_value_of_an_array_with);
    __pyx_v_msg = __pyx_kp_s_The_truth_value_of_an_array_with;

    /* "cupy/core/core.pyx":1173
 *             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 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1173, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_msg);
    __Pyx_GIVEREF(__pyx_v_msg);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_msg);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1173, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1173, __pyx_L1_error)
    break;
  }

  /* "cupy/core/core.pyx":1165
 *     # 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_XDECREF(__pyx_t_3);
  __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":1177
 *     # Unary operations:
 * 
 *     def __neg__(self):             # <<<<<<<<<<<<<<
 *         return negative(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_83__neg__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_83__neg__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__neg__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_82__neg__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

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

  /* "cupy/core/core.pyx":1178
 * 
 *     def __neg__(self):
 *         return negative(self)             # <<<<<<<<<<<<<<
 * 
 *     def __pos__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_negative); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1178, __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, 1178, __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, 1178, __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, 1178, __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, 1178, __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, 1178, __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":1177
 *     # Unary operations:
 * 
 *     def __neg__(self):             # <<<<<<<<<<<<<<
 *         return negative(self)
 * 
 */

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

/* "cupy/core/core.pyx":1180
 *         return negative(self)
 * 
 *     def __pos__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_85__pos__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_85__pos__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pos__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_84__pos__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_84__pos__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pos__", 0);

  /* "cupy/core/core.pyx":1181
 * 
 *     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":1180
 *         return negative(self)
 * 
 *     def __pos__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

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

/* "cupy/core/core.pyx":1183
 *         return self
 * 
 *     def __abs__(self):             # <<<<<<<<<<<<<<
 *         return absolute(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_87__abs__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_87__abs__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__abs__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_86__abs__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

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

  /* "cupy/core/core.pyx":1184
 * 
 *     def __abs__(self):
 *         return absolute(self)             # <<<<<<<<<<<<<<
 * 
 *     def __invert__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_absolute); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1184, __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, 1184, __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, 1184, __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, 1184, __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, 1184, __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, 1184, __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":1183
 *         return self
 * 
 *     def __abs__(self):             # <<<<<<<<<<<<<<
 *         return absolute(self)
 * 
 */

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

/* "cupy/core/core.pyx":1186
 *         return absolute(self)
 * 
 *     def __invert__(self):             # <<<<<<<<<<<<<<
 *         return invert(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_89__invert__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_89__invert__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__invert__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_88__invert__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

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

  /* "cupy/core/core.pyx":1187
 * 
 *     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, 1187, __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, 1187, __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, 1187, __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, 1187, __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, 1187, __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, 1187, __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":1186
 *         return absolute(self)
 * 
 *     def __invert__(self):             # <<<<<<<<<<<<<<
 *         return invert(self)
 * 
 */

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

/* "cupy/core/core.pyx":1191
 *     # Arithmetic:
 * 
 *     def __add__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__radd__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_91__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_91__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_90__add__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_90__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__add__", 0);

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

    /* "cupy/core/core.pyx":1193
 *     def __add__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__radd__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return add(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_radd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1193, __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, 1193, __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, 1193, __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, 1193, __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, 1193, __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, 1193, __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":1192
 * 
 *     def __add__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__radd__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1195
 *             return y.__radd__(x)
 *         else:
 *             return add(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __sub__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_add); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1195, __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, 1195, __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, 1195, __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, 1195, __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, 1195, __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":1191
 *     # 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":1197
 *             return add(x, y)
 * 
 *     def __sub__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rsub__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_93__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_93__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__sub__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_92__sub__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_92__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__sub__", 0);

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

    /* "cupy/core/core.pyx":1199
 *     def __sub__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rsub__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return subtract(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rsub); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1199, __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, 1199, __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, 1199, __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, 1199, __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, 1199, __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, 1199, __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":1198
 * 
 *     def __sub__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rsub__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1201
 *             return y.__rsub__(x)
 *         else:
 *             return subtract(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __mul__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_subtract); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1201, __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, 1201, __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, 1201, __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, 1201, __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, 1201, __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":1197
 *             return add(x, y)
 * 
 *     def __sub__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rsub__(x)
 */

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

/* "cupy/core/core.pyx":1203
 *             return subtract(x, y)
 * 
 *     def __mul__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rmul__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_95__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_95__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__mul__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_94__mul__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_94__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__mul__", 0);

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

    /* "cupy/core/core.pyx":1205
 *     def __mul__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rmul__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return multiply(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rmul); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1205, __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, 1205, __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, 1205, __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, 1205, __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, 1205, __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, 1205, __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":1204
 * 
 *     def __mul__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rmul__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1207
 *             return y.__rmul__(x)
 *         else:
 *             return multiply(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __matmul__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_multiply); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1207, __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, 1207, __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, 1207, __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, 1207, __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, 1207, __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":1203
 *             return subtract(x, y)
 * 
 *     def __mul__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rmul__(x)
 */

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

/* "cupy/core/core.pyx":1209
 *             return multiply(x, y)
 * 
 *     def __matmul__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rmatmul__(x)
 */

/* Python wrapper */
#if PY_VERSION_HEX >= 0x03050000
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_97__matmul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_97__matmul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__matmul__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_96__matmul__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_VERSION_HEX >= 0x03050000)*/

#if PY_VERSION_HEX >= 0x03050000
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_96__matmul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__matmul__", 0);

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

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

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

  /* "cupy/core/core.pyx":1209
 *             return multiply(x, y)
 * 
 *     def __matmul__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rmatmul__(x)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__matmul__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_VERSION_HEX >= 0x03050000)*/

/* "cupy/core/core.pyx":1215
 *             return matmul(x, y)
 * 
 *     def __div__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rdiv__(x)
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_99__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_99__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__div__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_98__div__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000))*/

#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_98__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__div__", 0);

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

    /* "cupy/core/core.pyx":1217
 *     def __div__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rdiv__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return divide(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rdiv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1217, __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, 1217, __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, 1217, __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, 1217, __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, 1217, __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, 1217, __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":1216
 * 
 *     def __div__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rdiv__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1219
 *             return y.__rdiv__(x)
 *         else:
 *             return divide(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __truediv__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_divide); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1219, __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, 1219, __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, 1219, __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, 1219, __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, 1219, __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":1215
 *             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":1221
 *             return divide(x, y)
 * 
 *     def __truediv__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rtruediv__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_101__truediv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_101__truediv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__truediv__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_100__truediv__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_100__truediv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__truediv__", 0);

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

    /* "cupy/core/core.pyx":1223
 *     def __truediv__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rtruediv__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return true_divide(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rtruediv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1223, __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, 1223, __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, 1223, __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, 1223, __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, 1223, __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, 1223, __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":1222
 * 
 *     def __truediv__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rtruediv__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1225
 *             return y.__rtruediv__(x)
 *         else:
 *             return true_divide(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __floordiv__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_true_divide); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1225, __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, 1225, __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, 1225, __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, 1225, __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, 1225, __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":1221
 *             return divide(x, y)
 * 
 *     def __truediv__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rtruediv__(x)
 */

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

/* "cupy/core/core.pyx":1227
 *             return true_divide(x, y)
 * 
 *     def __floordiv__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rfloordiv__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_103__floordiv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_103__floordiv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__floordiv__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_102__floordiv__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_102__floordiv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__floordiv__", 0);

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

    /* "cupy/core/core.pyx":1229
 *     def __floordiv__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rfloordiv__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return floor_divide(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rfloordiv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1229, __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, 1229, __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, 1229, __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, 1229, __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, 1229, __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, 1229, __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":1228
 * 
 *     def __floordiv__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rfloordiv__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1231
 *             return y.__rfloordiv__(x)
 *         else:
 *             return floor_divide(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __mod__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_floor_divide); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1231, __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, 1231, __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, 1231, __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, 1231, __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, 1231, __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":1227
 *             return true_divide(x, y)
 * 
 *     def __floordiv__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rfloordiv__(x)
 */

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

/* "cupy/core/core.pyx":1233
 *             return floor_divide(x, y)
 * 
 *     def __mod__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rmod__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_105__mod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_105__mod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__mod__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_104__mod__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_104__mod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__mod__", 0);

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

    /* "cupy/core/core.pyx":1235
 *     def __mod__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rmod__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return remainder(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rmod); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1235, __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, 1235, __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, 1235, __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, 1235, __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, 1235, __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, 1235, __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":1234
 * 
 *     def __mod__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rmod__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1237
 *             return y.__rmod__(x)
 *         else:
 *             return remainder(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __divmod__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_remainder); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1237, __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, 1237, __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, 1237, __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, 1237, __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, 1237, __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":1233
 *             return floor_divide(x, y)
 * 
 *     def __mod__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rmod__(x)
 */

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

/* "cupy/core/core.pyx":1239
 *             return remainder(x, y)
 * 
 *     def __divmod__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rdivmod__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_107__divmod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_107__divmod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__divmod__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_106__divmod__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_106__divmod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__divmod__", 0);

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

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

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

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

/* "cupy/core/core.pyx":1245
 *             return divmod(x, y)
 * 
 *     def __pow__(x, y, modulo):             # <<<<<<<<<<<<<<
 *         # Note that we ignore the modulo argument as well as NumPy.
 *         if _should_use_rop(x, y):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_109__pow__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_modulo); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_109__pow__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_modulo) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pow__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_108__pow__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), ((PyObject *)__pyx_v_modulo));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_108__pow__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, CYTHON_UNUSED PyObject *__pyx_v_modulo) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__pow__", 0);

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

    /* "cupy/core/core.pyx":1248
 *         # Note that we ignore the modulo argument as well as NumPy.
 *         if _should_use_rop(x, y):
 *             return y.__rpow__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return power(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rpow); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1248, __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, 1248, __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, 1248, __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, 1248, __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, 1248, __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, 1248, __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":1247
 *     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":1250
 *             return y.__rpow__(x)
 *         else:
 *             return power(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __lshift__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_power); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1250, __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, 1250, __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, 1250, __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, 1250, __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, 1250, __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":1245
 *             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":1252
 *             return power(x, y)
 * 
 *     def __lshift__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rlshift__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_111__lshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_111__lshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__lshift__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_110__lshift__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_110__lshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__lshift__", 0);

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

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

    /* "cupy/core/core.pyx":1253
 * 
 *     def __lshift__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rlshift__(x)
 *         else:
 */
  }

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

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

/* "cupy/core/core.pyx":1258
 *             return left_shift(x, y)
 * 
 *     def __rshift__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rrshift__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_113__rshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_113__rshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__rshift__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_112__rshift__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_112__rshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__rshift__", 0);

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

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

  /* "cupy/core/core.pyx":1262
 *             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, 1262, __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, 1262, __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, 1262, __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, 1262, __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, 1262, __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":1258
 *             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":1264
 *             return right_shift(x, y)
 * 
 *     def __and__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rand__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_115__and__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_115__and__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__and__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_114__and__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_114__and__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__and__", 0);

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

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

  /* "cupy/core/core.pyx":1268
 *             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, 1268, __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, 1268, __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, 1268, __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, 1268, __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, 1268, __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":1264
 *             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":1270
 *             return bitwise_and(x, y)
 * 
 *     def __or__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__ror__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_117__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_117__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__or__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_116__or__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_116__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__or__", 0);

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

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

  /* "cupy/core/core.pyx":1274
 *             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, 1274, __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, 1274, __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, 1274, __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, 1274, __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, 1274, __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":1270
 *             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":1276
 *             return bitwise_or(x, y)
 * 
 *     def __xor__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rxor__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_119__xor__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_119__xor__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__xor__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_118__xor__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_118__xor__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__xor__", 0);

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

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

  /* "cupy/core/core.pyx":1280
 *             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, 1280, __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, 1280, __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, 1280, __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, 1280, __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, 1280, __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":1276
 *             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":1284
 *     # Arithmetic, in-place:
 * 
 *     def __iadd__(self, other):             # <<<<<<<<<<<<<<
 *         return add(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_121__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_121__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iadd__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_120__iadd__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_120__iadd__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__iadd__", 0);

  /* "cupy/core/core.pyx":1285
 * 
 *     def __iadd__(self, other):
 *         return add(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __isub__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_add); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1285, __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, 1285, __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, 1285, __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, 1285, __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, 1285, __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":1284
 *     # Arithmetic, in-place:
 * 
 *     def __iadd__(self, other):             # <<<<<<<<<<<<<<
 *         return add(self, other, self)
 * 
 */

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

/* "cupy/core/core.pyx":1287
 *         return add(self, other, self)
 * 
 *     def __isub__(self, other):             # <<<<<<<<<<<<<<
 *         return subtract(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_123__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_123__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__isub__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_122__isub__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_122__isub__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__isub__", 0);

  /* "cupy/core/core.pyx":1288
 * 
 *     def __isub__(self, other):
 *         return subtract(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __imul__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_subtract); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1288, __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, 1288, __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, 1288, __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, 1288, __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, 1288, __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":1287
 *         return add(self, other, self)
 * 
 *     def __isub__(self, other):             # <<<<<<<<<<<<<<
 *         return subtract(self, other, self)
 * 
 */

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

/* "cupy/core/core.pyx":1290
 *         return subtract(self, other, self)
 * 
 *     def __imul__(self, other):             # <<<<<<<<<<<<<<
 *         return multiply(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_125__imul__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_125__imul__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__imul__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_124__imul__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_124__imul__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__imul__", 0);

  /* "cupy/core/core.pyx":1291
 * 
 *     def __imul__(self, other):
 *         return multiply(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __idiv__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_multiply); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1291, __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, 1291, __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, 1291, __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, 1291, __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, 1291, __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":1290
 *         return subtract(self, other, self)
 * 
 *     def __imul__(self, other):             # <<<<<<<<<<<<<<
 *         return multiply(self, other, self)
 * 
 */

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

/* "cupy/core/core.pyx":1293
 *         return multiply(self, other, self)
 * 
 *     def __idiv__(self, other):             # <<<<<<<<<<<<<<
 *         return divide(self, other, self)
 * 
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_127__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_127__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__idiv__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_126__idiv__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000))*/

#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_126__idiv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__idiv__", 0);

  /* "cupy/core/core.pyx":1294
 * 
 *     def __idiv__(self, other):
 *         return divide(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __itruediv__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_divide); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1294, __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, 1294, __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, 1294, __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, 1294, __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, 1294, __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":1293
 *         return multiply(self, other, self)
 * 
 *     def __idiv__(self, other):             # <<<<<<<<<<<<<<
 *         return divide(self, other, self)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__idiv__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000))*/

/* "cupy/core/core.pyx":1296
 *         return divide(self, other, self)
 * 
 *     def __itruediv__(self, other):             # <<<<<<<<<<<<<<
 *         return true_divide(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_129__itruediv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_129__itruediv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__itruediv__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_128__itruediv__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_128__itruediv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__itruediv__", 0);

  /* "cupy/core/core.pyx":1297
 * 
 *     def __itruediv__(self, other):
 *         return true_divide(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __ifloordiv__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_true_divide); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1297, __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, 1297, __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, 1297, __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, 1297, __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, 1297, __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":1296
 *         return divide(self, other, self)
 * 
 *     def __itruediv__(self, other):             # <<<<<<<<<<<<<<
 *         return true_divide(self, other, self)
 * 
 */

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

/* "cupy/core/core.pyx":1299
 *         return true_divide(self, other, self)
 * 
 *     def __ifloordiv__(self, other):             # <<<<<<<<<<<<<<
 *         return floor_divide(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_131__ifloordiv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_131__ifloordiv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ifloordiv__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_130__ifloordiv__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_130__ifloordiv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__ifloordiv__", 0);

  /* "cupy/core/core.pyx":1300
 * 
 *     def __ifloordiv__(self, other):
 *         return floor_divide(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __imod__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_floor_divide); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1300, __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, 1300, __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, 1300, __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, 1300, __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, 1300, __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":1299
 *         return true_divide(self, other, self)
 * 
 *     def __ifloordiv__(self, other):             # <<<<<<<<<<<<<<
 *         return floor_divide(self, other, self)
 * 
 */

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

/* "cupy/core/core.pyx":1302
 *         return floor_divide(self, other, self)
 * 
 *     def __imod__(self, other):             # <<<<<<<<<<<<<<
 *         return remainder(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_133__imod__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_133__imod__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__imod__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_132__imod__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_132__imod__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__imod__", 0);

  /* "cupy/core/core.pyx":1303
 * 
 *     def __imod__(self, other):
 *         return remainder(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __ipow__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_remainder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1303, __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, 1303, __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, 1303, __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, 1303, __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, 1303, __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":1302
 *         return floor_divide(self, other, self)
 * 
 *     def __imod__(self, other):             # <<<<<<<<<<<<<<
 *         return remainder(self, other, self)
 * 
 */

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

/* "cupy/core/core.pyx":1305
 *         return remainder(self, other, self)
 * 
 *     def __ipow__(self, other):             # <<<<<<<<<<<<<<
 *         return power(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_135__ipow__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_135__ipow__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ipow__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_134__ipow__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_134__ipow__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__ipow__", 0);

  /* "cupy/core/core.pyx":1306
 * 
 *     def __ipow__(self, other):
 *         return power(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __ilshift__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_power); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1306, __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, 1306, __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, 1306, __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, 1306, __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, 1306, __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":1305
 *         return remainder(self, other, self)
 * 
 *     def __ipow__(self, other):             # <<<<<<<<<<<<<<
 *         return power(self, other, self)
 * 
 */

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

/* "cupy/core/core.pyx":1308
 *         return power(self, other, self)
 * 
 *     def __ilshift__(self, other):             # <<<<<<<<<<<<<<
 *         return left_shift(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_137__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_137__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ilshift__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_136__ilshift__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_136__ilshift__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__ilshift__", 0);

  /* "cupy/core/core.pyx":1309
 * 
 *     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, 1309, __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, 1309, __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, 1309, __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, 1309, __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, 1309, __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":1308
 *         return power(self, other, self)
 * 
 *     def __ilshift__(self, other):             # <<<<<<<<<<<<<<
 *         return left_shift(self, other, self)
 * 
 */

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

/* "cupy/core/core.pyx":1311
 *         return left_shift(self, other, self)
 * 
 *     def __irshift__(self, other):             # <<<<<<<<<<<<<<
 *         return right_shift(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_139__irshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_139__irshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__irshift__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_138__irshift__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_138__irshift__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__irshift__", 0);

  /* "cupy/core/core.pyx":1312
 * 
 *     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, 1312, __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, 1312, __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, 1312, __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, 1312, __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, 1312, __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":1311
 *         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":1314
 *         return right_shift(self, other, self)
 * 
 *     def __iand__(self, other):             # <<<<<<<<<<<<<<
 *         return bitwise_and(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_141__iand__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_141__iand__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iand__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_140__iand__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_140__iand__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__iand__", 0);

  /* "cupy/core/core.pyx":1315
 * 
 *     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, 1315, __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, 1315, __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, 1315, __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, 1315, __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, 1315, __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":1314
 *         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":1317
 *         return bitwise_and(self, other, self)
 * 
 *     def __ior__(self, other):             # <<<<<<<<<<<<<<
 *         return bitwise_or(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_143__ior__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_143__ior__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ior__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_142__ior__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_142__ior__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__ior__", 0);

  /* "cupy/core/core.pyx":1318
 * 
 *     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, 1318, __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, 1318, __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, 1318, __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, 1318, __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, 1318, __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":1317
 *         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":1320
 *         return bitwise_or(self, other, self)
 * 
 *     def __ixor__(self, other):             # <<<<<<<<<<<<<<
 *         return bitwise_xor(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_145__ixor__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_145__ixor__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ixor__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_144__ixor__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_144__ixor__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__ixor__", 0);

  /* "cupy/core/core.pyx":1321
 * 
 *     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, 1321, __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, 1321, __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, 1321, __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, 1321, __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, 1321, __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":1320
 *         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":1323
 *         return bitwise_xor(self, other, self)
 * 
 *     cpdef ndarray conj(self):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             return conj(self)
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_147conj(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_conj(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("conj", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_conj); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1323, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_147conj)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1323, __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, 1323, __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, 1323, __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":1324
 * 
 *     cpdef ndarray conj(self):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             return conj(self)
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1324, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1324, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":1325
 *     cpdef ndarray conj(self):
 *         if self.dtype.kind == 'c':
 *             return conj(self)             # <<<<<<<<<<<<<<
 *         else:
 *             return self
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_conj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1325, __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, 1325, __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, 1325, __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, 1325, __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, 1325, __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, 1325, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1325, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1324
 * 
 *     cpdef ndarray conj(self):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             return conj(self)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1327
 *             return conj(self)
 *         else:
 *             return self             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1323
 *         return bitwise_xor(self, other, self)
 * 
 *     cpdef ndarray conj(self):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             return conj(self)
 */

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_147conj(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_146conj[] = "ndarray.conj(self) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_147conj(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("conj (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_146conj(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_146conj(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("conj", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_7ndarray_conj(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1323, __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":1330
 * 
 *     @property
 *     def real(self):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             return real(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;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":1331
 *     @property
 *     def real(self):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             return real(self)
 *         return self
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1331, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1332
 *     def real(self):
 *         if self.dtype.kind == 'c':
 *             return real(self)             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_real); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1332, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1332, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, ((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, 1332, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, ((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, 1332, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1332, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_self));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_self));
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1332, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1331
 *     @property
 *     def real(self):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             return real(self)
 *         return self
 */
  }

  /* "cupy/core/core.pyx":1333
 *         if self.dtype.kind == 'c':
 *             return real(self)
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     @real.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1330
 * 
 *     @property
 *     def real(self):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             return real(self)
 */

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

/* "cupy/core/core.pyx":1336
 * 
 *     @real.setter
 *     def real(self, value):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             _real_setter(value, self)
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_4real_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_4real_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_4real_2__set__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4cupy_4core_4core_7ndarray_4real_2__set__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "cupy/core/core.pyx":1337
 *     @real.setter
 *     def real(self, value):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             _real_setter(value, self)
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1337, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1338
 *     def real(self, value):
 *         if self.dtype.kind == 'c':
 *             _real_setter(value, self)             # <<<<<<<<<<<<<<
 *         else:
 *             elementwise_copy(value, self)
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_real_setter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_value, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1338, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_value, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1338, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1338, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_value);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1338, __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":1337
 *     @real.setter
 *     def real(self, value):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             _real_setter(value, self)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1340
 *             _real_setter(value, self)
 *         else:
 *             elementwise_copy(value, self)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1340, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_value, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1340, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_value, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1340, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1340, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_value);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1340, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1336
 * 
 *     @real.setter
 *     def real(self, value):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             _real_setter(value, self)
 */

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

/* "cupy/core/core.pyx":1343
 * 
 *     @property
 *     def imag(self):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             return imag(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) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_new_array = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":1344
 *     @property
 *     def imag(self):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             return imag(self)
 *         new_array = ndarray(self.shape, dtype=self.dtype)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1344, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1345
 *     def imag(self):
 *         if self.dtype.kind == 'c':
 *             return imag(self)             # <<<<<<<<<<<<<<
 *         new_array = ndarray(self.shape, dtype=self.dtype)
 *         new_array.fill(0)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_imag); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1345, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1345, __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, ((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, 1345, __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, ((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, 1345, __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, 1345, __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(((PyObject *)__pyx_v_self));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_self));
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1345, __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":1344
 *     @property
 *     def imag(self):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             return imag(self)
 *         new_array = ndarray(self.shape, dtype=self.dtype)
 */
  }

  /* "cupy/core/core.pyx":1346
 *         if self.dtype.kind == 'c':
 *             return imag(self)
 *         new_array = ndarray(self.shape, dtype=self.dtype)             # <<<<<<<<<<<<<<
 *         new_array.fill(0)
 *         return new_array
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_self->dtype) < 0) __PYX_ERR(0, 1346, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_new_array = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":1347
 *             return imag(self)
 *         new_array = ndarray(self.shape, dtype=self.dtype)
 *         new_array.fill(0)             # <<<<<<<<<<<<<<
 *         return new_array
 * 
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_new_array->__pyx_vtab)->fill(__pyx_v_new_array, __pyx_int_0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":1348
 *         new_array = ndarray(self.shape, dtype=self.dtype)
 *         new_array.fill(0)
 *         return new_array             # <<<<<<<<<<<<<<
 * 
 *     @imag.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_new_array));
  __pyx_r = ((PyObject *)__pyx_v_new_array);
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1343
 * 
 *     @property
 *     def imag(self):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             return imag(self)
 */

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

/* "cupy/core/core.pyx":1351
 * 
 *     @imag.setter
 *     def imag(self, value):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             _imag_setter(value, self)
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_4imag_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_4imag_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_4imag_2__set__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4cupy_4core_4core_7ndarray_4imag_2__set__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "cupy/core/core.pyx":1352
 *     @imag.setter
 *     def imag(self, value):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             _imag_setter(value, self)
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1352, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1353
 *     def imag(self, value):
 *         if self.dtype.kind == 'c':
 *             _imag_setter(value, self)             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError('cupy.ndarray does not have imaginary part to set')
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_imag_setter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1353, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_value, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1353, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_value, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1353, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1353, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_value);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1353, __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":1352
 *     @imag.setter
 *     def imag(self, value):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             _imag_setter(value, self)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1355
 *             _imag_setter(value, self)
 *         else:
 *             raise TypeError('cupy.ndarray does not have imaginary part to set')             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1355, __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, 1355, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1351
 * 
 *     @imag.setter
 *     def imag(self, value):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             _imag_setter(value, self)
 */

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

/* "cupy/core/core.pyx":1362
 *     # For standard library functions:
 * 
 *     def __copy__(self):             # <<<<<<<<<<<<<<
 *         return self.copy()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_149__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_148__copy__[] = "ndarray.__copy__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_149__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__copy__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_148__copy__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

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

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

  /* "cupy/core/core.pyx":1362
 *     # 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":1365
 *         return self.copy()
 * 
 *     def __deepcopy__(self, memo):             # <<<<<<<<<<<<<<
 *         if self.device is not None:
 *             with self.device:
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_151__deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_150__deepcopy__[] = "ndarray.__deepcopy__(self, memo)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_151__deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__deepcopy__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_150__deepcopy__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_memo));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_150__deepcopy__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_memo) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("__deepcopy__", 0);

  /* "cupy/core/core.pyx":1366
 * 
 *     def __deepcopy__(self, memo):
 *         if self.device is not None:             # <<<<<<<<<<<<<<
 *             with self.device:
 *                 return self.copy()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1366, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__pyx_t_1 != Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":1367
 *     def __deepcopy__(self, memo):
 *         if self.device is not None:
 *             with self.device:             # <<<<<<<<<<<<<<
 *                 return self.copy()
 *         else:
 */
    /*with:*/ {
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1367, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1367, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1367, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (__pyx_t_7) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1367, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1367, __pyx_L4_error)
      }
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      /*try:*/ {
        {
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_8);
          __Pyx_XGOTREF(__pyx_t_9);
          __Pyx_XGOTREF(__pyx_t_10);
          /*try:*/ {

            /* "cupy/core/core.pyx":1368
 *         if self.device is not None:
 *             with self.device:
 *                 return self.copy()             # <<<<<<<<<<<<<<
 *         else:
 *             return self.copy()
 */
            __Pyx_XDECREF(__pyx_r);
            __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->copy(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1368, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_r = __pyx_t_1;
            __pyx_t_1 = 0;
            goto __pyx_L12_try_return;

            /* "cupy/core/core.pyx":1367
 *     def __deepcopy__(self, memo):
 *         if self.device is not None:
 *             with self.device:             # <<<<<<<<<<<<<<
 *                 return self.copy()
 *         else:
 */
          }
          __pyx_L8_error:;
          __Pyx_PyThreadState_assign
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          /*except:*/ {
            __Pyx_AddTraceback("cupy.core.core.ndarray.__deepcopy__", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 1367, __pyx_L10_except_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_7 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1367, __pyx_L10_except_error)
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1367, __pyx_L10_except_error)
            __Pyx_GOTREF(__pyx_t_11);
            __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_11);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            if (__pyx_t_3 < 0) __PYX_ERR(0, 1367, __pyx_L10_except_error)
            __pyx_t_2 = ((!(__pyx_t_3 != 0)) != 0);
            if (__pyx_t_2) {
              __Pyx_GIVEREF(__pyx_t_1);
              __Pyx_GIVEREF(__pyx_t_5);
              __Pyx_XGIVEREF(__pyx_t_6);
              __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_5, __pyx_t_6);
              __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; 
              __PYX_ERR(0, 1367, __pyx_L10_except_error)
            }
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            goto __pyx_L9_exception_handled;
          }
          __pyx_L10_except_error:;
          __Pyx_PyThreadState_assign
          __Pyx_XGIVEREF(__pyx_t_8);
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
          goto __pyx_L1_error;
          __pyx_L12_try_return:;
          __Pyx_PyThreadState_assign
          __Pyx_XGIVEREF(__pyx_t_8);
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
          goto __pyx_L5_return;
          __pyx_L9_exception_handled:;
          __Pyx_PyThreadState_assign
          __Pyx_XGIVEREF(__pyx_t_8);
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        }
      }
      /*finally:*/ {
        /*normal exit:*/{
          if (__pyx_t_4) {
            __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__37, NULL);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1367, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          }
          goto __pyx_L7;
        }
        __pyx_L5_return: {
          __pyx_t_10 = __pyx_r;
          __pyx_r = 0;
          if (__pyx_t_4) {
            __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__38, NULL);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1367, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          }
          __pyx_r = __pyx_t_10;
          __pyx_t_10 = 0;
          goto __pyx_L0;
        }
        __pyx_L7:;
      }
      goto __pyx_L17;
      __pyx_L4_error:;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L1_error;
      __pyx_L17:;
    }

    /* "cupy/core/core.pyx":1366
 * 
 *     def __deepcopy__(self, memo):
 *         if self.device is not None:             # <<<<<<<<<<<<<<
 *             with self.device:
 *                 return self.copy()
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1370
 *                 return self.copy()
 *         else:
 *             return self.copy()             # <<<<<<<<<<<<<<
 * 
 *     def __reduce__(self):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->copy(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1370, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1365
 *         return self.copy()
 * 
 *     def __deepcopy__(self, memo):             # <<<<<<<<<<<<<<
 *         if self.device is not None:
 *             with self.device:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__deepcopy__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1372
 *             return self.copy()
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return array, (self.get(),)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_153__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_152__reduce__[] = "ndarray.__reduce__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_153__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_152__reduce__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

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

  /* "cupy/core/core.pyx":1373
 * 
 *     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, 1373, __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, 1373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1373, __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, 1373, __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":1372
 *             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":1379
 *     # cupy.ndarray does not define __new__
 * 
 *     def __array__(self, dtype=None):             # <<<<<<<<<<<<<<
 *         if dtype is None or self.dtype == dtype:
 *             return self
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_155__array__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_154__array__[] = "ndarray.__array__(self, dtype=None)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_155__array__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__array__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dtype,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 1379, __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, 1379, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.__array__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_154__array__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_dtype);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_154__array__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__array__", 0);

  /* "cupy/core/core.pyx":1380
 * 
 *     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, 1380, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1380, __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":1381
 *     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":1380
 * 
 *     def __array__(self, dtype=None):
 *         if dtype is None or self.dtype == dtype:             # <<<<<<<<<<<<<<
 *             return self
 *         else:
 */
  }

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

  /* "cupy/core/core.pyx":1379
 *     # 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":1389
 *     # Container customization:
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         if self._shape.size() == 0:
 *             raise TypeError('len() of unsized object')
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_4cupy_4core_4core_7ndarray_157__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_4cupy_4core_4core_7ndarray_157__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_156__len__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

static Py_ssize_t __pyx_pf_4cupy_4core_4core_7ndarray_156__len__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "cupy/core/core.pyx":1390
 * 
 *     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 (__pyx_t_1) {

    /* "cupy/core/core.pyx":1391
 *     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__39, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1391, __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, 1391, __pyx_L1_error)

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

  /* "cupy/core/core.pyx":1392
 *         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":1389
 *     # Container customization:
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         if self._shape.size() == 0:
 *             raise TypeError('len() of unsized object')
 */

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

/* "cupy/core/core.pyx":1394
 *         return self._shape[0]
 * 
 *     def __getitem__(self, slices):             # <<<<<<<<<<<<<<
 *         """x.__getitem__(y) <==> x[y]
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_159__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_slices); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_158__getitem__[] = "x.__getitem__(y) <==> x[y]\n\n        Supports both basic and advanced indexing.\n\n        .. note::\n\n            Currently, it does not support ``slices`` that consists of more\n            than one boolean arrays\n\n        .. note::\n\n           CuPy handles out-of-bounds indices differently from NumPy.\n           NumPy handles them by raising an error, but CuPy wraps around them.\n\n           Examples\n           --------\n           >>> a = cupy.arange(3)\n           >>> a[[1, 3]]\n           array([1, 0])\n\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_4cupy_4core_4core_7ndarray_158__getitem__;
#endif
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_159__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_slices) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_158__getitem__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_slices));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_158__getitem__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_slices) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_j;
  Py_ssize_t __pyx_v_offset;
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_n_newaxes;
  Py_ssize_t __pyx_v_n_ellipses;
  Py_ssize_t __pyx_v_ellipsis;
  Py_ssize_t __pyx_v_s_start;
  Py_ssize_t __pyx_v_s_stop;
  Py_ssize_t __pyx_v_s_step;
  Py_ssize_t __pyx_v_dim;
  Py_ssize_t __pyx_v_ind;
  std::vector<Py_ssize_t>  __pyx_v_shape;
  std::vector<Py_ssize_t>  __pyx_v_strides;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_v_noneslices = NULL;
  PyObject *__pyx_v_ellipsis_size = NULL;
  int __pyx_v_advanced;
  int __pyx_v_mask_exists;
  int __pyx_v_is_list;
  PyObject *__pyx_v_n_not_slice_none = NULL;
  PyObject *__pyx_v_mask_i = NULL;
  PyObject *__pyx_v_basic_slices = NULL;
  PyObject *__pyx_v_adv_slices = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_scalar_array = NULL;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_arr_slices_mask = NULL;
  PyObject *__pyx_v_axis = NULL;
  PyObject *__pyx_v_msg = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  int __pyx_t_14;
  Py_ssize_t __pyx_t_15;
  long __pyx_t_16;
  Py_ssize_t __pyx_t_17;
  __Pyx_RefNannySetupContext("__getitem__", 0);
  __Pyx_INCREF(__pyx_v_slices);

  /* "cupy/core/core.pyx":1422
 *         cdef Py_ssize_t ellipsis_sizem, s_start, s_stop, s_step, dim, ind
 *         cdef vector.vector[Py_ssize_t] shape, strides
 *         if isinstance(slices, tuple):             # <<<<<<<<<<<<<<
 *             slices = list(slices)
 *         elif isinstance(slices, list):
 */
  __pyx_t_1 = PyTuple_Check(__pyx_v_slices); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1423
 *         cdef vector.vector[Py_ssize_t] shape, strides
 *         if isinstance(slices, tuple):
 *             slices = list(slices)             # <<<<<<<<<<<<<<
 *         elif isinstance(slices, list):
 *             slices = list(slices)  # copy list
 */
    __pyx_t_3 = PySequence_List(__pyx_v_slices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1423, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_slices, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1422
 *         cdef Py_ssize_t ellipsis_sizem, s_start, s_stop, s_step, dim, ind
 *         cdef vector.vector[Py_ssize_t] shape, strides
 *         if isinstance(slices, tuple):             # <<<<<<<<<<<<<<
 *             slices = list(slices)
 *         elif isinstance(slices, list):
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1424
 *         if isinstance(slices, tuple):
 *             slices = list(slices)
 *         elif isinstance(slices, list):             # <<<<<<<<<<<<<<
 *             slices = list(slices)  # copy list
 *             if all([isinstance(s, int) for s in slices]):
 */
  __pyx_t_2 = PyList_Check(__pyx_v_slices); 
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1425
 *             slices = list(slices)
 *         elif isinstance(slices, list):
 *             slices = list(slices)  # copy list             # <<<<<<<<<<<<<<
 *             if all([isinstance(s, int) for s in slices]):
 *                 slices = [slices]
 */
    __pyx_t_3 = PySequence_List(__pyx_v_slices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1425, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_slices, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1426
 *         elif isinstance(slices, list):
 *             slices = list(slices)  # copy list
 *             if all([isinstance(s, int) for s in slices]):             # <<<<<<<<<<<<<<
 *                 slices = [slices]
 *         else:
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1426, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (likely(PyList_CheckExact(__pyx_v_slices)) || PyTuple_CheckExact(__pyx_v_slices)) {
      __pyx_t_4 = __pyx_v_slices; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_slices); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1426, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1426, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1426, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1426, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1426, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1426, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        }
      } else {
        __pyx_t_7 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_7)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 1426, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_1 = PyInt_Check(__pyx_v_s); 
      __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1426, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 1426, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1426, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_all, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1426, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1426, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1427
 *             slices = list(slices)  # copy list
 *             if all([isinstance(s, int) for s in slices]):
 *                 slices = [slices]             # <<<<<<<<<<<<<<
 *         else:
 *             slices = [slices]
 */
      __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1427, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_slices);
      __Pyx_GIVEREF(__pyx_v_slices);
      PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_slices);
      __Pyx_DECREF_SET(__pyx_v_slices, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":1426
 *         elif isinstance(slices, list):
 *             slices = list(slices)  # copy list
 *             if all([isinstance(s, int) for s in slices]):             # <<<<<<<<<<<<<<
 *                 slices = [slices]
 *         else:
 */
    }

    /* "cupy/core/core.pyx":1424
 *         if isinstance(slices, tuple):
 *             slices = list(slices)
 *         elif isinstance(slices, list):             # <<<<<<<<<<<<<<
 *             slices = list(slices)  # copy list
 *             if all([isinstance(s, int) for s in slices]):
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1429
 *                 slices = [slices]
 *         else:
 *             slices = [slices]             # <<<<<<<<<<<<<<
 * 
 *         # Expand ellipsis into empty slices
 */
  /*else*/ {
    __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1429, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_slices);
    __Pyx_GIVEREF(__pyx_v_slices);
    PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_slices);
    __Pyx_DECREF_SET(__pyx_v_slices, __pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1432
 * 
 *         # Expand ellipsis into empty slices
 *         ellipsis = -1             # <<<<<<<<<<<<<<
 *         n_newaxes = n_ellipses = 0
 *         for i, s in enumerate(slices):
 */
  __pyx_v_ellipsis = -1L;

  /* "cupy/core/core.pyx":1433
 *         # Expand ellipsis into empty slices
 *         ellipsis = -1
 *         n_newaxes = n_ellipses = 0             # <<<<<<<<<<<<<<
 *         for i, s in enumerate(slices):
 *             if s is None:
 */
  __pyx_v_n_newaxes = 0;
  __pyx_v_n_ellipses = 0;

  /* "cupy/core/core.pyx":1434
 *         ellipsis = -1
 *         n_newaxes = n_ellipses = 0
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if s is None:
 *                 n_newaxes += 1
 */
  __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_v_slices)) || PyTuple_CheckExact(__pyx_v_slices)) {
    __pyx_t_3 = __pyx_v_slices; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_slices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1434, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1434, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1434, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1434, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1434, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1434, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_6(__pyx_t_3);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1434, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_v_i = __pyx_t_5;
    __pyx_t_5 = (__pyx_t_5 + 1);

    /* "cupy/core/core.pyx":1435
 *         n_newaxes = n_ellipses = 0
 *         for i, s in enumerate(slices):
 *             if s is None:             # <<<<<<<<<<<<<<
 *                 n_newaxes += 1
 *             elif s is Ellipsis:
 */
    __pyx_t_1 = (__pyx_v_s == Py_None);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1436
 *         for i, s in enumerate(slices):
 *             if s is None:
 *                 n_newaxes += 1             # <<<<<<<<<<<<<<
 *             elif s is Ellipsis:
 *                 n_ellipses += 1
 */
      __pyx_v_n_newaxes = (__pyx_v_n_newaxes + 1);

      /* "cupy/core/core.pyx":1435
 *         n_newaxes = n_ellipses = 0
 *         for i, s in enumerate(slices):
 *             if s is None:             # <<<<<<<<<<<<<<
 *                 n_newaxes += 1
 *             elif s is Ellipsis:
 */
      goto __pyx_L9;
    }

    /* "cupy/core/core.pyx":1437
 *             if s is None:
 *                 n_newaxes += 1
 *             elif s is Ellipsis:             # <<<<<<<<<<<<<<
 *                 n_ellipses += 1
 *                 ellipsis = i
 */
    __pyx_t_2 = (__pyx_v_s == __pyx_builtin_Ellipsis);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1438
 *                 n_newaxes += 1
 *             elif s is Ellipsis:
 *                 n_ellipses += 1             # <<<<<<<<<<<<<<
 *                 ellipsis = i
 *         ndim = self._shape.size()
 */
      __pyx_v_n_ellipses = (__pyx_v_n_ellipses + 1);

      /* "cupy/core/core.pyx":1439
 *             elif s is Ellipsis:
 *                 n_ellipses += 1
 *                 ellipsis = i             # <<<<<<<<<<<<<<
 *         ndim = self._shape.size()
 *         noneslices = [slice(None)]
 */
      __pyx_v_ellipsis = __pyx_v_i;

      /* "cupy/core/core.pyx":1437
 *             if s is None:
 *                 n_newaxes += 1
 *             elif s is Ellipsis:             # <<<<<<<<<<<<<<
 *                 n_ellipses += 1
 *                 ellipsis = i
 */
    }
    __pyx_L9:;

    /* "cupy/core/core.pyx":1434
 *         ellipsis = -1
 *         n_newaxes = n_ellipses = 0
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if s is None:
 *                 n_newaxes += 1
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1440
 *                 n_ellipses += 1
 *                 ellipsis = i
 *         ndim = self._shape.size()             # <<<<<<<<<<<<<<
 *         noneslices = [slice(None)]
 *         if n_ellipses > 0:
 */
  __pyx_v_ndim = __pyx_v_self->_shape.size();

  /* "cupy/core/core.pyx":1441
 *                 ellipsis = i
 *         ndim = self._shape.size()
 *         noneslices = [slice(None)]             # <<<<<<<<<<<<<<
 *         if n_ellipses > 0:
 *             if n_ellipses > 1:
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_slice__40);
  __Pyx_GIVEREF(__pyx_slice__40);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_slice__40);
  __pyx_v_noneslices = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1442
 *         ndim = self._shape.size()
 *         noneslices = [slice(None)]
 *         if n_ellipses > 0:             # <<<<<<<<<<<<<<
 *             if n_ellipses > 1:
 *                 raise ValueError('Only one Ellipsis is allowed in index')
 */
  __pyx_t_1 = ((__pyx_v_n_ellipses > 0) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1443
 *         noneslices = [slice(None)]
 *         if n_ellipses > 0:
 *             if n_ellipses > 1:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Only one Ellipsis is allowed in index')
 *             ellipsis_size = ndim - (<Py_ssize_t>len(slices) - n_newaxes - 1)
 */
    __pyx_t_1 = ((__pyx_v_n_ellipses > 1) != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1444
 *         if n_ellipses > 0:
 *             if n_ellipses > 1:
 *                 raise ValueError('Only one Ellipsis is allowed in index')             # <<<<<<<<<<<<<<
 *             ellipsis_size = ndim - (<Py_ssize_t>len(slices) - n_newaxes - 1)
 *             slices[ellipsis:ellipsis + 1] = noneslices * ellipsis_size
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1444, __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, 1444, __pyx_L1_error)

      /* "cupy/core/core.pyx":1443
 *         noneslices = [slice(None)]
 *         if n_ellipses > 0:
 *             if n_ellipses > 1:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Only one Ellipsis is allowed in index')
 *             ellipsis_size = ndim - (<Py_ssize_t>len(slices) - n_newaxes - 1)
 */
    }

    /* "cupy/core/core.pyx":1445
 *             if n_ellipses > 1:
 *                 raise ValueError('Only one Ellipsis is allowed in index')
 *             ellipsis_size = ndim - (<Py_ssize_t>len(slices) - n_newaxes - 1)             # <<<<<<<<<<<<<<
 *             slices[ellipsis:ellipsis + 1] = noneslices * ellipsis_size
 * 
 */
    __pyx_t_5 = PyObject_Length(__pyx_v_slices); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 1445, __pyx_L1_error)
    __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_ndim - ((((Py_ssize_t)__pyx_t_5) - __pyx_v_n_newaxes) - 1))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1445, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_ellipsis_size = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1446
 *                 raise ValueError('Only one Ellipsis is allowed in index')
 *             ellipsis_size = ndim - (<Py_ssize_t>len(slices) - n_newaxes - 1)
 *             slices[ellipsis:ellipsis + 1] = noneslices * ellipsis_size             # <<<<<<<<<<<<<<
 * 
 *         slices += noneslices * (ndim - <Py_ssize_t>len(slices) + n_newaxes)
 */
    __pyx_t_3 = PyNumber_Multiply(__pyx_v_noneslices, __pyx_v_ellipsis_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1446, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_PyObject_SetSlice(__pyx_v_slices, __pyx_t_3, __pyx_v_ellipsis, (__pyx_v_ellipsis + 1), NULL, NULL, NULL, 1, 1, 1) < 0) __PYX_ERR(0, 1446, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1442
 *         ndim = self._shape.size()
 *         noneslices = [slice(None)]
 *         if n_ellipses > 0:             # <<<<<<<<<<<<<<
 *             if n_ellipses > 1:
 *                 raise ValueError('Only one Ellipsis is allowed in index')
 */
  }

  /* "cupy/core/core.pyx":1448
 *             slices[ellipsis:ellipsis + 1] = noneslices * ellipsis_size
 * 
 *         slices += noneslices * (ndim - <Py_ssize_t>len(slices) + n_newaxes)             # <<<<<<<<<<<<<<
 * 
 *         # Check if advanced is true,
 */
  __pyx_t_5 = PyObject_Length(__pyx_v_slices); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 1448, __pyx_L1_error)
  __pyx_t_3 = PyInt_FromSsize_t(((__pyx_v_ndim - ((Py_ssize_t)__pyx_t_5)) + __pyx_v_n_newaxes)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyNumber_Multiply(__pyx_v_noneslices, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_slices, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF_SET(__pyx_v_slices, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1452
 *         # Check if advanced is true,
 *         # and convert list/NumPy arrays to cupy.ndarray
 *         advanced = False             # <<<<<<<<<<<<<<
 *         mask_exists = False
 *         for i, s in enumerate(slices):
 */
  __pyx_v_advanced = 0;

  /* "cupy/core/core.pyx":1453
 *         # and convert list/NumPy arrays to cupy.ndarray
 *         advanced = False
 *         mask_exists = False             # <<<<<<<<<<<<<<
 *         for i, s in enumerate(slices):
 *             is_list = False
 */
  __pyx_v_mask_exists = 0;

  /* "cupy/core/core.pyx":1454
 *         advanced = False
 *         mask_exists = False
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             is_list = False
 *             if isinstance(s, (list, numpy.ndarray)):
 */
  __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_v_slices)) || PyTuple_CheckExact(__pyx_v_slices)) {
    __pyx_t_3 = __pyx_v_slices; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_slices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1454, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1454, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1454, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1454, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1454, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1454, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_6(__pyx_t_3);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1454, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_v_i = __pyx_t_5;
    __pyx_t_5 = (__pyx_t_5 + 1);

    /* "cupy/core/core.pyx":1455
 *         mask_exists = False
 *         for i, s in enumerate(slices):
 *             is_list = False             # <<<<<<<<<<<<<<
 *             if isinstance(s, (list, numpy.ndarray)):
 *                 is_list = isinstance(s, list)
 */
    __pyx_v_is_list = 0;

    /* "cupy/core/core.pyx":1456
 *         for i, s in enumerate(slices):
 *             is_list = False
 *             if isinstance(s, (list, numpy.ndarray)):             # <<<<<<<<<<<<<<
 *                 is_list = isinstance(s, list)
 *                 s = array(s)
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = PyList_Check(__pyx_v_s); 
    __pyx_t_9 = (__pyx_t_2 != 0);
    if (!__pyx_t_9) {
    } else {
      __pyx_t_1 = __pyx_t_9;
      goto __pyx_L15_bool_binop_done;
    }
    __pyx_t_9 = PyObject_IsInstance(__pyx_v_s, __pyx_t_7); 
    __pyx_t_2 = (__pyx_t_9 != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L15_bool_binop_done:;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1457
 *             is_list = False
 *             if isinstance(s, (list, numpy.ndarray)):
 *                 is_list = isinstance(s, list)             # <<<<<<<<<<<<<<
 *                 s = array(s)
 *                 # handle the case when s is an empty list
 */
      __pyx_t_2 = PyList_Check(__pyx_v_s); 
      __pyx_v_is_list = __pyx_t_2;

      /* "cupy/core/core.pyx":1458
 *             if isinstance(s, (list, numpy.ndarray)):
 *                 is_list = isinstance(s, list)
 *                 s = array(s)             # <<<<<<<<<<<<<<
 *                 # handle the case when s is an empty list
 *                 if is_list and s.size == 0:
 */
      __pyx_t_7 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_v_s, 0, NULL)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1458, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "cupy/core/core.pyx":1460
 *                 s = array(s)
 *                 # handle the case when s is an empty list
 *                 if is_list and s.size == 0:             # <<<<<<<<<<<<<<
 *                     s = s.astype(numpy.int32)
 *                 slices[i] = s
 */
      __pyx_t_1 = (__pyx_v_is_list != 0);
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L18_bool_binop_done;
      }
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1460, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_t_7, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1460, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1460, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_2 = __pyx_t_1;
      __pyx_L18_bool_binop_done:;
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1461
 *                 # handle the case when s is an empty list
 *                 if is_list and s.size == 0:
 *                     s = s.astype(numpy.int32)             # <<<<<<<<<<<<<<
 *                 slices[i] = s
 *             if isinstance(s, ndarray):
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_astype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1461, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1461, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_int32); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1461, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1461, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10);
        __pyx_t_10 = 0;
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1461, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_10);
        __pyx_t_10 = 0;

        /* "cupy/core/core.pyx":1460
 *                 s = array(s)
 *                 # handle the case when s is an empty list
 *                 if is_list and s.size == 0:             # <<<<<<<<<<<<<<
 *                     s = s.astype(numpy.int32)
 *                 slices[i] = s
 */
      }

      /* "cupy/core/core.pyx":1462
 *                 if is_list and s.size == 0:
 *                     s = s.astype(numpy.int32)
 *                 slices[i] = s             # <<<<<<<<<<<<<<
 *             if isinstance(s, ndarray):
 *                 if issubclass(s.dtype.type, numpy.integer):
 */
      if (unlikely(__Pyx_SetItemInt(__pyx_v_slices, __pyx_v_i, __pyx_v_s, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1) < 0)) __PYX_ERR(0, 1462, __pyx_L1_error)

      /* "cupy/core/core.pyx":1456
 *         for i, s in enumerate(slices):
 *             is_list = False
 *             if isinstance(s, (list, numpy.ndarray)):             # <<<<<<<<<<<<<<
 *                 is_list = isinstance(s, list)
 *                 s = array(s)
 */
    }

    /* "cupy/core/core.pyx":1463
 *                     s = s.astype(numpy.int32)
 *                 slices[i] = s
 *             if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *                 if issubclass(s.dtype.type, numpy.integer):
 *                     advanced = True
 */
    __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1464
 *                 slices[i] = s
 *             if isinstance(s, ndarray):
 *                 if issubclass(s.dtype.type, numpy.integer):             # <<<<<<<<<<<<<<
 *                     advanced = True
 *                 elif issubclass(s.dtype.type, numpy.bool_):
 */
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1464, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_type); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1464, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1464, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_integer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1464, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_1 = PyObject_IsSubclass(__pyx_t_7, __pyx_t_4); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 1464, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_2 = (__pyx_t_1 != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1465
 *             if isinstance(s, ndarray):
 *                 if issubclass(s.dtype.type, numpy.integer):
 *                     advanced = True             # <<<<<<<<<<<<<<
 *                 elif issubclass(s.dtype.type, numpy.bool_):
 *                     mask_exists = not is_list
 */
        __pyx_v_advanced = 1;

        /* "cupy/core/core.pyx":1464
 *                 slices[i] = s
 *             if isinstance(s, ndarray):
 *                 if issubclass(s.dtype.type, numpy.integer):             # <<<<<<<<<<<<<<
 *                     advanced = True
 *                 elif issubclass(s.dtype.type, numpy.bool_):
 */
        goto __pyx_L21;
      }

      /* "cupy/core/core.pyx":1466
 *                 if issubclass(s.dtype.type, numpy.integer):
 *                     advanced = True
 *                 elif issubclass(s.dtype.type, numpy.bool_):             # <<<<<<<<<<<<<<
 *                     mask_exists = not is_list
 *                 else:
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_type); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_bool); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_2 = PyObject_IsSubclass(__pyx_t_7, __pyx_t_10); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 1466, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_1 = (__pyx_t_2 != 0);
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":1467
 *                     advanced = True
 *                 elif issubclass(s.dtype.type, numpy.bool_):
 *                     mask_exists = not is_list             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise IndexError(
 */
        __pyx_v_mask_exists = (!(__pyx_v_is_list != 0));

        /* "cupy/core/core.pyx":1466
 *                 if issubclass(s.dtype.type, numpy.integer):
 *                     advanced = True
 *                 elif issubclass(s.dtype.type, numpy.bool_):             # <<<<<<<<<<<<<<
 *                     mask_exists = not is_list
 *                 else:
 */
        goto __pyx_L21;
      }

      /* "cupy/core/core.pyx":1469
 *                     mask_exists = not is_list
 *                 else:
 *                     raise IndexError(             # <<<<<<<<<<<<<<
 *                         'arrays used as indices must be of integer or boolean '
 *                         'type. (actual: {})'.format(s.dtype.type))
 */
      /*else*/ {

        /* "cupy/core/core.pyx":1471
 *                     raise IndexError(
 *                         'arrays used as indices must be of integer or boolean '
 *                         'type. (actual: {})'.format(s.dtype.type))             # <<<<<<<<<<<<<<
 * 
 *         if not mask_exists and len(slices) > self.ndim + n_newaxes:
 */
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_arrays_used_as_indices_must_be_o, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1471, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1471, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_type); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1471, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(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);
          }
        }
        if (!__pyx_t_4) {
          __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1471, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_t_10);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_7)) {
            PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_11};
            __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1471, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
            PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_11};
            __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1471, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          } else
          #endif
          {
            __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1471, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_4); __pyx_t_4 = NULL;
            __Pyx_GIVEREF(__pyx_t_11);
            PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_11);
            __pyx_t_11 = 0;
            __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1471, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "cupy/core/core.pyx":1469
 *                     mask_exists = not is_list
 *                 else:
 *                     raise IndexError(             # <<<<<<<<<<<<<<
 *                         'arrays used as indices must be of integer or boolean '
 *                         'type. (actual: {})'.format(s.dtype.type))
 */
        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1469, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10);
        __pyx_t_10 = 0;
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1469, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_Raise(__pyx_t_10, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __PYX_ERR(0, 1469, __pyx_L1_error)
      }
      __pyx_L21:;

      /* "cupy/core/core.pyx":1463
 *                     s = s.astype(numpy.int32)
 *                 slices[i] = s
 *             if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *                 if issubclass(s.dtype.type, numpy.integer):
 *                     advanced = True
 */
    }

    /* "cupy/core/core.pyx":1454
 *         advanced = False
 *         mask_exists = False
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             is_list = False
 *             if isinstance(s, (list, numpy.ndarray)):
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1473
 *                         'type. (actual: {})'.format(s.dtype.type))
 * 
 *         if not mask_exists and len(slices) > self.ndim + n_newaxes:             # <<<<<<<<<<<<<<
 *             raise IndexError('too many indices for array')
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_mask_exists != 0)) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L23_bool_binop_done;
  }
  __pyx_t_5 = PyObject_Length(__pyx_v_slices); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 1473, __pyx_L1_error)
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1473, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1473, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_n_newaxes); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1473, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_12 = PyNumber_Add(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1473, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyObject_RichCompare(__pyx_t_3, __pyx_t_12, Py_GT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1473, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1473, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_1 = __pyx_t_2;
  __pyx_L23_bool_binop_done:;
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1474
 * 
 *         if not mask_exists and len(slices) > self.ndim + n_newaxes:
 *             raise IndexError('too many indices for array')             # <<<<<<<<<<<<<<
 * 
 *         if mask_exists:
 */
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1474, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_Raise(__pyx_t_7, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __PYX_ERR(0, 1474, __pyx_L1_error)

    /* "cupy/core/core.pyx":1473
 *                         'type. (actual: {})'.format(s.dtype.type))
 * 
 *         if not mask_exists and len(slices) > self.ndim + n_newaxes:             # <<<<<<<<<<<<<<
 *             raise IndexError('too many indices for array')
 * 
 */
  }

  /* "cupy/core/core.pyx":1476
 *             raise IndexError('too many indices for array')
 * 
 *         if mask_exists:             # <<<<<<<<<<<<<<
 *             n_not_slice_none = 0
 *             mask_i = None
 */
  __pyx_t_1 = (__pyx_v_mask_exists != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1477
 * 
 *         if mask_exists:
 *             n_not_slice_none = 0             # <<<<<<<<<<<<<<
 *             mask_i = None
 *             for i, s in enumerate(slices):
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_v_n_not_slice_none = __pyx_int_0;

    /* "cupy/core/core.pyx":1478
 *         if mask_exists:
 *             n_not_slice_none = 0
 *             mask_i = None             # <<<<<<<<<<<<<<
 *             for i, s in enumerate(slices):
 *                 if not isinstance(s, slice) or s != slice(None):
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_mask_i = Py_None;

    /* "cupy/core/core.pyx":1479
 *             n_not_slice_none = 0
 *             mask_i = None
 *             for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *                 if not isinstance(s, slice) or s != slice(None):
 *                     n_not_slice_none += 1
 */
    __pyx_t_5 = 0;
    if (likely(PyList_CheckExact(__pyx_v_slices)) || PyTuple_CheckExact(__pyx_v_slices)) {
      __pyx_t_7 = __pyx_v_slices; __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_slices); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1479, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1479, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_12 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_12); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1479, __pyx_L1_error)
          #else
          __pyx_t_12 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1479, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_12); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1479, __pyx_L1_error)
          #else
          __pyx_t_12 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1479, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          #endif
        }
      } else {
        __pyx_t_12 = __pyx_t_6(__pyx_t_7);
        if (unlikely(!__pyx_t_12)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 1479, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_12);
      }
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_12);
      __pyx_t_12 = 0;
      __pyx_v_i = __pyx_t_5;
      __pyx_t_5 = (__pyx_t_5 + 1);

      /* "cupy/core/core.pyx":1480
 *             mask_i = None
 *             for i, s in enumerate(slices):
 *                 if not isinstance(s, slice) or s != slice(None):             # <<<<<<<<<<<<<<
 *                     n_not_slice_none += 1
 *                     if issubclass(s.dtype.type, numpy.bool_):
 */
      __pyx_t_2 = PySlice_Check(__pyx_v_s); 
      __pyx_t_9 = ((!(__pyx_t_2 != 0)) != 0);
      if (!__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L29_bool_binop_done;
      }
      __pyx_t_12 = PyObject_RichCompare(__pyx_v_s, __pyx_slice__43, Py_NE); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1480, __pyx_L1_error)
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1480, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_1 = __pyx_t_9;
      __pyx_L29_bool_binop_done:;
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":1481
 *             for i, s in enumerate(slices):
 *                 if not isinstance(s, slice) or s != slice(None):
 *                     n_not_slice_none += 1             # <<<<<<<<<<<<<<
 *                     if issubclass(s.dtype.type, numpy.bool_):
 *                         mask_i = i
 */
        __pyx_t_12 = __Pyx_PyInt_AddObjC(__pyx_v_n_not_slice_none, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1481, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF_SET(__pyx_v_n_not_slice_none, __pyx_t_12);
        __pyx_t_12 = 0;

        /* "cupy/core/core.pyx":1482
 *                 if not isinstance(s, slice) or s != slice(None):
 *                     n_not_slice_none += 1
 *                     if issubclass(s.dtype.type, numpy.bool_):             # <<<<<<<<<<<<<<
 *                         mask_i = i
 *             if n_not_slice_none != 1 and mask_i is not None:
 */
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1482, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1482, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1482, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_bool); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1482, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_1 = PyObject_IsSubclass(__pyx_t_3, __pyx_t_10); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 1482, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_9 = (__pyx_t_1 != 0);
        if (__pyx_t_9) {

          /* "cupy/core/core.pyx":1483
 *                     n_not_slice_none += 1
 *                     if issubclass(s.dtype.type, numpy.bool_):
 *                         mask_i = i             # <<<<<<<<<<<<<<
 *             if n_not_slice_none != 1 and mask_i is not None:
 *                 raise ValueError('currently, CuPy only supports slices that '
 */
          __pyx_t_10 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1483, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF_SET(__pyx_v_mask_i, __pyx_t_10);
          __pyx_t_10 = 0;

          /* "cupy/core/core.pyx":1482
 *                 if not isinstance(s, slice) or s != slice(None):
 *                     n_not_slice_none += 1
 *                     if issubclass(s.dtype.type, numpy.bool_):             # <<<<<<<<<<<<<<
 *                         mask_i = i
 *             if n_not_slice_none != 1 and mask_i is not None:
 */
        }

        /* "cupy/core/core.pyx":1480
 *             mask_i = None
 *             for i, s in enumerate(slices):
 *                 if not isinstance(s, slice) or s != slice(None):             # <<<<<<<<<<<<<<
 *                     n_not_slice_none += 1
 *                     if issubclass(s.dtype.type, numpy.bool_):
 */
      }

      /* "cupy/core/core.pyx":1479
 *             n_not_slice_none = 0
 *             mask_i = None
 *             for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *                 if not isinstance(s, slice) or s != slice(None):
 *                     n_not_slice_none += 1
 */
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":1484
 *                     if issubclass(s.dtype.type, numpy.bool_):
 *                         mask_i = i
 *             if n_not_slice_none != 1 and mask_i is not None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('currently, CuPy only supports slices that '
 *                                  'consist of one boolean array.')
 */
    __pyx_t_7 = PyObject_RichCompare(__pyx_v_n_not_slice_none, __pyx_int_1, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1484, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1484, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_1) {
    } else {
      __pyx_t_9 = __pyx_t_1;
      goto __pyx_L33_bool_binop_done;
    }
    __pyx_t_1 = (__pyx_v_mask_i != Py_None);
    __pyx_t_2 = (__pyx_t_1 != 0);
    __pyx_t_9 = __pyx_t_2;
    __pyx_L33_bool_binop_done:;
    if (__pyx_t_9) {

      /* "cupy/core/core.pyx":1485
 *                         mask_i = i
 *             if n_not_slice_none != 1 and mask_i is not None:
 *                 raise ValueError('currently, CuPy only supports slices that '             # <<<<<<<<<<<<<<
 *                                  'consist of one boolean array.')
 *             return _getitem_mask_single(self, slices[mask_i], mask_i)
 */
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1485, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __PYX_ERR(0, 1485, __pyx_L1_error)

      /* "cupy/core/core.pyx":1484
 *                     if issubclass(s.dtype.type, numpy.bool_):
 *                         mask_i = i
 *             if n_not_slice_none != 1 and mask_i is not None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('currently, CuPy only supports slices that '
 *                                  'consist of one boolean array.')
 */
    }

    /* "cupy/core/core.pyx":1487
 *                 raise ValueError('currently, CuPy only supports slices that '
 *                                  'consist of one boolean array.')
 *             return _getitem_mask_single(self, slices[mask_i], mask_i)             # <<<<<<<<<<<<<<
 * 
 *         if advanced:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_7 = PyObject_GetItem(__pyx_v_slices, __pyx_v_mask_i); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1487, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1487, __pyx_L1_error)
    __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_v_mask_i); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1487, __pyx_L1_error)
    __pyx_t_10 = ((PyObject *)__pyx_f_4cupy_4core_4core__getitem_mask_single(__pyx_v_self, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7), __pyx_t_13, 0)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1487, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_r = __pyx_t_10;
    __pyx_t_10 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1476
 *             raise IndexError('too many indices for array')
 * 
 *         if mask_exists:             # <<<<<<<<<<<<<<
 *             n_not_slice_none = 0
 *             mask_i = None
 */
  }

  /* "cupy/core/core.pyx":1489
 *             return _getitem_mask_single(self, slices[mask_i], mask_i)
 * 
 *         if advanced:             # <<<<<<<<<<<<<<
 *             # split slices that can be handled by basic-indexing
 *             basic_slices = []
 */
  __pyx_t_9 = (__pyx_v_advanced != 0);
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":1491
 *         if advanced:
 *             # split slices that can be handled by basic-indexing
 *             basic_slices = []             # <<<<<<<<<<<<<<
 *             adv_slices = []
 *             for i, s in enumerate(slices):
 */
    __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1491, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_v_basic_slices = ((PyObject*)__pyx_t_10);
    __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":1492
 *             # split slices that can be handled by basic-indexing
 *             basic_slices = []
 *             adv_slices = []             # <<<<<<<<<<<<<<
 *             for i, s in enumerate(slices):
 *                 if type(s) is slice:
 */
    __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1492, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_v_adv_slices = ((PyObject*)__pyx_t_10);
    __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":1493
 *             basic_slices = []
 *             adv_slices = []
 *             for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *                 if type(s) is slice:
 *                     basic_slices.append(s)
 */
    __pyx_t_5 = 0;
    if (likely(PyList_CheckExact(__pyx_v_slices)) || PyTuple_CheckExact(__pyx_v_slices)) {
      __pyx_t_10 = __pyx_v_slices; __Pyx_INCREF(__pyx_t_10); __pyx_t_8 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_v_slices); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1493, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_6 = Py_TYPE(__pyx_t_10)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1493, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_10))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_10)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_8); __Pyx_INCREF(__pyx_t_7); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1493, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_10, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1493, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_10)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_8); __Pyx_INCREF(__pyx_t_7); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1493, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_10, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1493, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        }
      } else {
        __pyx_t_7 = __pyx_t_6(__pyx_t_10);
        if (unlikely(!__pyx_t_7)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 1493, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_v_i = __pyx_t_5;
      __pyx_t_5 = (__pyx_t_5 + 1);

      /* "cupy/core/core.pyx":1494
 *             adv_slices = []
 *             for i, s in enumerate(slices):
 *                 if type(s) is slice:             # <<<<<<<<<<<<<<
 *                     basic_slices.append(s)
 *                     adv_slices.append(slice(None))
 */
      __pyx_t_9 = (((PyObject *)Py_TYPE(__pyx_v_s)) == ((PyObject *)(&PySlice_Type)));
      __pyx_t_2 = (__pyx_t_9 != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1495
 *             for i, s in enumerate(slices):
 *                 if type(s) is slice:
 *                     basic_slices.append(s)             # <<<<<<<<<<<<<<
 *                     adv_slices.append(slice(None))
 *                 elif s is None:
 */
        __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_basic_slices, __pyx_v_s); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(0, 1495, __pyx_L1_error)

        /* "cupy/core/core.pyx":1496
 *                 if type(s) is slice:
 *                     basic_slices.append(s)
 *                     adv_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *                 elif s is None:
 *                     basic_slices.append(None)
 */
        __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_adv_slices, __pyx_slice__45); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(0, 1496, __pyx_L1_error)

        /* "cupy/core/core.pyx":1494
 *             adv_slices = []
 *             for i, s in enumerate(slices):
 *                 if type(s) is slice:             # <<<<<<<<<<<<<<
 *                     basic_slices.append(s)
 *                     adv_slices.append(slice(None))
 */
        goto __pyx_L38;
      }

      /* "cupy/core/core.pyx":1497
 *                     basic_slices.append(s)
 *                     adv_slices.append(slice(None))
 *                 elif s is None:             # <<<<<<<<<<<<<<
 *                     basic_slices.append(None)
 *                     adv_slices.append(slice(None))
 */
      __pyx_t_2 = (__pyx_v_s == Py_None);
      __pyx_t_9 = (__pyx_t_2 != 0);
      if (__pyx_t_9) {

        /* "cupy/core/core.pyx":1498
 *                     adv_slices.append(slice(None))
 *                 elif s is None:
 *                     basic_slices.append(None)             # <<<<<<<<<<<<<<
 *                     adv_slices.append(slice(None))
 *                 elif (isinstance(s, ndarray) and
 */
        __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_basic_slices, Py_None); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(0, 1498, __pyx_L1_error)

        /* "cupy/core/core.pyx":1499
 *                 elif s is None:
 *                     basic_slices.append(None)
 *                     adv_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *                 elif (isinstance(s, ndarray) and
 *                         issubclass(s.dtype.type, numpy.integer)):
 */
        __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_adv_slices, __pyx_slice__46); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(0, 1499, __pyx_L1_error)

        /* "cupy/core/core.pyx":1497
 *                     basic_slices.append(s)
 *                     adv_slices.append(slice(None))
 *                 elif s is None:             # <<<<<<<<<<<<<<
 *                     basic_slices.append(None)
 *                     adv_slices.append(slice(None))
 */
        goto __pyx_L38;
      }

      /* "cupy/core/core.pyx":1500
 *                     basic_slices.append(None)
 *                     adv_slices.append(slice(None))
 *                 elif (isinstance(s, ndarray) and             # <<<<<<<<<<<<<<
 *                         issubclass(s.dtype.type, numpy.integer)):
 *                     basic_slices.append(slice(None))
 */
      __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
      __pyx_t_1 = (__pyx_t_2 != 0);
      if (__pyx_t_1) {
      } else {
        __pyx_t_9 = __pyx_t_1;
        goto __pyx_L39_bool_binop_done;
      }

      /* "cupy/core/core.pyx":1501
 *                     adv_slices.append(slice(None))
 *                 elif (isinstance(s, ndarray) and
 *                         issubclass(s.dtype.type, numpy.integer)):             # <<<<<<<<<<<<<<
 *                     basic_slices.append(slice(None))
 *                     adv_slices.append(s)
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1501, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1501, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __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, 1501, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_integer); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1501, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_1 = PyObject_IsSubclass(__pyx_t_3, __pyx_t_12); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 1501, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_2 = (__pyx_t_1 != 0);
      __pyx_t_9 = __pyx_t_2;
      __pyx_L39_bool_binop_done:;

      /* "cupy/core/core.pyx":1500
 *                     basic_slices.append(None)
 *                     adv_slices.append(slice(None))
 *                 elif (isinstance(s, ndarray) and             # <<<<<<<<<<<<<<
 *                         issubclass(s.dtype.type, numpy.integer)):
 *                     basic_slices.append(slice(None))
 */
      if (__pyx_t_9) {

        /* "cupy/core/core.pyx":1502
 *                 elif (isinstance(s, ndarray) and
 *                         issubclass(s.dtype.type, numpy.integer)):
 *                     basic_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *                     adv_slices.append(s)
 *                 elif isinstance(s, int):
 */
        __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_basic_slices, __pyx_slice__47); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(0, 1502, __pyx_L1_error)

        /* "cupy/core/core.pyx":1503
 *                         issubclass(s.dtype.type, numpy.integer)):
 *                     basic_slices.append(slice(None))
 *                     adv_slices.append(s)             # <<<<<<<<<<<<<<
 *                 elif isinstance(s, int):
 *                     basic_slices.append(slice(None))
 */
        __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_adv_slices, __pyx_v_s); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(0, 1503, __pyx_L1_error)

        /* "cupy/core/core.pyx":1500
 *                     basic_slices.append(None)
 *                     adv_slices.append(slice(None))
 *                 elif (isinstance(s, ndarray) and             # <<<<<<<<<<<<<<
 *                         issubclass(s.dtype.type, numpy.integer)):
 *                     basic_slices.append(slice(None))
 */
        goto __pyx_L38;
      }

      /* "cupy/core/core.pyx":1504
 *                     basic_slices.append(slice(None))
 *                     adv_slices.append(s)
 *                 elif isinstance(s, int):             # <<<<<<<<<<<<<<
 *                     basic_slices.append(slice(None))
 *                     scalar_array = ndarray((), dtype=numpy.int64)
 */
      __pyx_t_9 = PyInt_Check(__pyx_v_s); 
      __pyx_t_2 = (__pyx_t_9 != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1505
 *                     adv_slices.append(s)
 *                 elif isinstance(s, int):
 *                     basic_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *                     scalar_array = ndarray((), dtype=numpy.int64)
 *                     scalar_array.fill(s)
 */
        __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_basic_slices, __pyx_slice__48); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(0, 1505, __pyx_L1_error)

        /* "cupy/core/core.pyx":1506
 *                 elif isinstance(s, int):
 *                     basic_slices.append(slice(None))
 *                     scalar_array = ndarray((), dtype=numpy.int64)             # <<<<<<<<<<<<<<
 *                     scalar_array.fill(s)
 *                     adv_slices.append(scalar_array)
 */
        __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1506, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1506, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_int64); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1506, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 1506, __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_tuple__49, __pyx_t_12); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1506, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF_SET(__pyx_v_scalar_array, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7));
        __pyx_t_7 = 0;

        /* "cupy/core/core.pyx":1507
 *                     basic_slices.append(slice(None))
 *                     scalar_array = ndarray((), dtype=numpy.int64)
 *                     scalar_array.fill(s)             # <<<<<<<<<<<<<<
 *                     adv_slices.append(scalar_array)
 *                 else:
 */
        __pyx_t_7 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_scalar_array->__pyx_vtab)->fill(__pyx_v_scalar_array, __pyx_v_s, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1507, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "cupy/core/core.pyx":1508
 *                     scalar_array = ndarray((), dtype=numpy.int64)
 *                     scalar_array.fill(s)
 *                     adv_slices.append(scalar_array)             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise IndexError(
 */
        __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_adv_slices, ((PyObject *)__pyx_v_scalar_array)); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(0, 1508, __pyx_L1_error)

        /* "cupy/core/core.pyx":1504
 *                     basic_slices.append(slice(None))
 *                     adv_slices.append(s)
 *                 elif isinstance(s, int):             # <<<<<<<<<<<<<<
 *                     basic_slices.append(slice(None))
 *                     scalar_array = ndarray((), dtype=numpy.int64)
 */
        goto __pyx_L38;
      }

      /* "cupy/core/core.pyx":1510
 *                     adv_slices.append(scalar_array)
 *                 else:
 *                     raise IndexError(             # <<<<<<<<<<<<<<
 *                         'only integers, slices (`:`), ellipsis (`...`),'
 *                         'numpy.newaxis (`None`) and integer or '
 */
      /*else*/ {
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1510, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_Raise(__pyx_t_7, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __PYX_ERR(0, 1510, __pyx_L1_error)
      }
      __pyx_L38:;

      /* "cupy/core/core.pyx":1493
 *             basic_slices = []
 *             adv_slices = []
 *             for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *                 if type(s) is slice:
 *                     basic_slices.append(s)
 */
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":1516
 * 
 *             # check if this is a combination of basic and advanced indexing
 *             a = self             # <<<<<<<<<<<<<<
 *             for s in basic_slices:
 *                 if s is None or (isinstance(s, slice) and s != slice(None)):
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_v_a = ((PyObject *)__pyx_v_self);

    /* "cupy/core/core.pyx":1517
 *             # check if this is a combination of basic and advanced indexing
 *             a = self
 *             for s in basic_slices:             # <<<<<<<<<<<<<<
 *                 if s is None or (isinstance(s, slice) and s != slice(None)):
 *                     a = self[tuple(basic_slices)]
 */
    __pyx_t_10 = __pyx_v_basic_slices; __Pyx_INCREF(__pyx_t_10); __pyx_t_5 = 0;
    for (;;) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_10)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_7 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1517, __pyx_L1_error)
      #else
      __pyx_t_7 = PySequence_ITEM(__pyx_t_10, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1517, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "cupy/core/core.pyx":1518
 *             a = self
 *             for s in basic_slices:
 *                 if s is None or (isinstance(s, slice) and s != slice(None)):             # <<<<<<<<<<<<<<
 *                     a = self[tuple(basic_slices)]
 *                     break
 */
      __pyx_t_9 = (__pyx_v_s == Py_None);
      __pyx_t_1 = (__pyx_t_9 != 0);
      if (!__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L44_bool_binop_done;
      }
      __pyx_t_1 = PySlice_Check(__pyx_v_s); 
      __pyx_t_9 = (__pyx_t_1 != 0);
      if (__pyx_t_9) {
      } else {
        __pyx_t_2 = __pyx_t_9;
        goto __pyx_L44_bool_binop_done;
      }
      __pyx_t_7 = PyObject_RichCompare(__pyx_v_s, __pyx_slice__51, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1518, __pyx_L1_error)
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1518, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_2 = __pyx_t_9;
      __pyx_L44_bool_binop_done:;
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1519
 *             for s in basic_slices:
 *                 if s is None or (isinstance(s, slice) and s != slice(None)):
 *                     a = self[tuple(basic_slices)]             # <<<<<<<<<<<<<<
 *                     break
 * 
 */
        __pyx_t_7 = PyList_AsTuple(__pyx_v_basic_slices); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1519, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1519, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF_SET(__pyx_v_a, __pyx_t_12);
        __pyx_t_12 = 0;

        /* "cupy/core/core.pyx":1520
 *                 if s is None or (isinstance(s, slice) and s != slice(None)):
 *                     a = self[tuple(basic_slices)]
 *                     break             # <<<<<<<<<<<<<<
 * 
 *             arr_slices_mask = [not isinstance(s, slice) for s in adv_slices]
 */
        goto __pyx_L42_break;

        /* "cupy/core/core.pyx":1518
 *             a = self
 *             for s in basic_slices:
 *                 if s is None or (isinstance(s, slice) and s != slice(None)):             # <<<<<<<<<<<<<<
 *                     a = self[tuple(basic_slices)]
 *                     break
 */
      }

      /* "cupy/core/core.pyx":1517
 *             # check if this is a combination of basic and advanced indexing
 *             a = self
 *             for s in basic_slices:             # <<<<<<<<<<<<<<
 *                 if s is None or (isinstance(s, slice) and s != slice(None)):
 *                     a = self[tuple(basic_slices)]
 */
    }
    __pyx_L42_break:;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":1522
 *                     break
 * 
 *             arr_slices_mask = [not isinstance(s, slice) for s in adv_slices]             # <<<<<<<<<<<<<<
 *             if sum(arr_slices_mask) == 1:
 *                 axis = arr_slices_mask.index(True)
 */
    __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1522, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_12 = __pyx_v_adv_slices; __Pyx_INCREF(__pyx_t_12); __pyx_t_5 = 0;
    for (;;) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_12)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_7 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1522, __pyx_L1_error)
      #else
      __pyx_t_7 = PySequence_ITEM(__pyx_t_12, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1522, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_2 = PySlice_Check(__pyx_v_s); 
      __pyx_t_7 = __Pyx_PyBool_FromLong((!(__pyx_t_2 != 0))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1522, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_10, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 1522, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_v_arr_slices_mask = ((PyObject*)__pyx_t_10);
    __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":1523
 * 
 *             arr_slices_mask = [not isinstance(s, slice) for s in adv_slices]
 *             if sum(arr_slices_mask) == 1:             # <<<<<<<<<<<<<<
 *                 axis = arr_slices_mask.index(True)
 *                 return a.take(adv_slices[axis], axis)
 */
    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1523, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_INCREF(__pyx_v_arr_slices_mask);
    __Pyx_GIVEREF(__pyx_v_arr_slices_mask);
    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_arr_slices_mask);
    __pyx_t_12 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_10, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1523, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyInt_EqObjC(__pyx_t_12, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1523, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1523, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1524
 *             arr_slices_mask = [not isinstance(s, slice) for s in adv_slices]
 *             if sum(arr_slices_mask) == 1:
 *                 axis = arr_slices_mask.index(True)             # <<<<<<<<<<<<<<
 *                 return a.take(adv_slices[axis], axis)
 *             return _getitem_multiple(a, adv_slices)
 */
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr_slices_mask, __pyx_n_s_index); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1524, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1524, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_v_axis = __pyx_t_12;
      __pyx_t_12 = 0;

      /* "cupy/core/core.pyx":1525
 *             if sum(arr_slices_mask) == 1:
 *                 axis = arr_slices_mask.index(True)
 *                 return a.take(adv_slices[axis], axis)             # <<<<<<<<<<<<<<
 *             return _getitem_multiple(a, adv_slices)
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_take); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1525, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_7 = PyObject_GetItem(__pyx_v_adv_slices, __pyx_v_axis); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1525, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = NULL;
      __pyx_t_13 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
          __pyx_t_13 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_7, __pyx_v_axis};
        __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1525, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_7, __pyx_v_axis};
        __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1525, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1525, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        if (__pyx_t_3) {
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3); __pyx_t_3 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_13, __pyx_t_7);
        __Pyx_INCREF(__pyx_v_axis);
        __Pyx_GIVEREF(__pyx_v_axis);
        PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_13, __pyx_v_axis);
        __pyx_t_7 = 0;
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1525, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_r = __pyx_t_12;
      __pyx_t_12 = 0;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":1523
 * 
 *             arr_slices_mask = [not isinstance(s, slice) for s in adv_slices]
 *             if sum(arr_slices_mask) == 1:             # <<<<<<<<<<<<<<
 *                 axis = arr_slices_mask.index(True)
 *                 return a.take(adv_slices[axis], axis)
 */
    }

    /* "cupy/core/core.pyx":1526
 *                 axis = arr_slices_mask.index(True)
 *                 return a.take(adv_slices[axis], axis)
 *             return _getitem_multiple(a, adv_slices)             # <<<<<<<<<<<<<<
 * 
 *         # Create new shape and stride
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(((__pyx_v_a) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1526, __pyx_L1_error)
    __pyx_t_12 = ((PyObject *)__pyx_f_4cupy_4core_4core__getitem_multiple(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_a), __pyx_v_adv_slices, 0)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1526, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_r = __pyx_t_12;
    __pyx_t_12 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1489
 *             return _getitem_mask_single(self, slices[mask_i], mask_i)
 * 
 *         if advanced:             # <<<<<<<<<<<<<<
 *             # split slices that can be handled by basic-indexing
 *             basic_slices = []
 */
  }

  /* "cupy/core/core.pyx":1529
 * 
 *         # Create new shape and stride
 *         j = 0             # <<<<<<<<<<<<<<
 *         offset = 0
 *         for i, s in enumerate(slices):
 */
  __pyx_v_j = 0;

  /* "cupy/core/core.pyx":1530
 *         # Create new shape and stride
 *         j = 0
 *         offset = 0             # <<<<<<<<<<<<<<
 *         for i, s in enumerate(slices):
 *             if s is None:
 */
  __pyx_v_offset = 0;

  /* "cupy/core/core.pyx":1531
 *         j = 0
 *         offset = 0
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if s is None:
 *                 shape.push_back(1)
 */
  __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_v_slices)) || PyTuple_CheckExact(__pyx_v_slices)) {
    __pyx_t_12 = __pyx_v_slices; __Pyx_INCREF(__pyx_t_12); __pyx_t_8 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_12 = PyObject_GetIter(__pyx_v_slices); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1531, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_6 = Py_TYPE(__pyx_t_12)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1531, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_12))) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_12)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_10 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_8); __Pyx_INCREF(__pyx_t_10); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1531, __pyx_L1_error)
        #else
        __pyx_t_10 = PySequence_ITEM(__pyx_t_12, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1531, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        #endif
      } else {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_12)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_12, __pyx_t_8); __Pyx_INCREF(__pyx_t_10); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1531, __pyx_L1_error)
        #else
        __pyx_t_10 = PySequence_ITEM(__pyx_t_12, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1531, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        #endif
      }
    } else {
      __pyx_t_10 = __pyx_t_6(__pyx_t_12);
      if (unlikely(!__pyx_t_10)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1531, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_10);
    }
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_v_i = __pyx_t_5;
    __pyx_t_5 = (__pyx_t_5 + 1);

    /* "cupy/core/core.pyx":1532
 *         offset = 0
 *         for i, s in enumerate(slices):
 *             if s is None:             # <<<<<<<<<<<<<<
 *                 shape.push_back(1)
 *                 if j < ndim:
 */
    __pyx_t_2 = (__pyx_v_s == Py_None);
    __pyx_t_9 = (__pyx_t_2 != 0);
    if (__pyx_t_9) {

      /* "cupy/core/core.pyx":1533
 *         for i, s in enumerate(slices):
 *             if s is None:
 *                 shape.push_back(1)             # <<<<<<<<<<<<<<
 *                 if j < ndim:
 *                     strides.push_back(self._strides[j])
 */
      try {
        __pyx_v_shape.push_back(1);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 1533, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":1534
 *             if s is None:
 *                 shape.push_back(1)
 *                 if j < ndim:             # <<<<<<<<<<<<<<
 *                     strides.push_back(self._strides[j])
 *                 elif ndim > 0:
 */
      __pyx_t_9 = ((__pyx_v_j < __pyx_v_ndim) != 0);
      if (__pyx_t_9) {

        /* "cupy/core/core.pyx":1535
 *                 shape.push_back(1)
 *                 if j < ndim:
 *                     strides.push_back(self._strides[j])             # <<<<<<<<<<<<<<
 *                 elif ndim > 0:
 *                     strides.push_back(self._strides[ndim - 1])
 */
        try {
          __pyx_v_strides.push_back((__pyx_v_self->_strides[__pyx_v_j]));
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(0, 1535, __pyx_L1_error)
        }

        /* "cupy/core/core.pyx":1534
 *             if s is None:
 *                 shape.push_back(1)
 *                 if j < ndim:             # <<<<<<<<<<<<<<
 *                     strides.push_back(self._strides[j])
 *                 elif ndim > 0:
 */
        goto __pyx_L53;
      }

      /* "cupy/core/core.pyx":1536
 *                 if j < ndim:
 *                     strides.push_back(self._strides[j])
 *                 elif ndim > 0:             # <<<<<<<<<<<<<<
 *                     strides.push_back(self._strides[ndim - 1])
 *                 else:
 */
      __pyx_t_9 = ((__pyx_v_ndim > 0) != 0);
      if (__pyx_t_9) {

        /* "cupy/core/core.pyx":1537
 *                     strides.push_back(self._strides[j])
 *                 elif ndim > 0:
 *                     strides.push_back(self._strides[ndim - 1])             # <<<<<<<<<<<<<<
 *                 else:
 *                     strides.push_back(self.itemsize)
 */
        try {
          __pyx_v_strides.push_back((__pyx_v_self->_strides[(__pyx_v_ndim - 1)]));
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(0, 1537, __pyx_L1_error)
        }

        /* "cupy/core/core.pyx":1536
 *                 if j < ndim:
 *                     strides.push_back(self._strides[j])
 *                 elif ndim > 0:             # <<<<<<<<<<<<<<
 *                     strides.push_back(self._strides[ndim - 1])
 *                 else:
 */
        goto __pyx_L53;
      }

      /* "cupy/core/core.pyx":1539
 *                     strides.push_back(self._strides[ndim - 1])
 *                 else:
 *                     strides.push_back(self.itemsize)             # <<<<<<<<<<<<<<
 *             elif ndim <= j:
 *                 raise IndexError("too many indices for array")
 */
      /*else*/ {
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1539, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_t_10); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1539, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        try {
          __pyx_v_strides.push_back(__pyx_t_15);
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(0, 1539, __pyx_L1_error)
        }
      }
      __pyx_L53:;

      /* "cupy/core/core.pyx":1532
 *         offset = 0
 *         for i, s in enumerate(slices):
 *             if s is None:             # <<<<<<<<<<<<<<
 *                 shape.push_back(1)
 *                 if j < ndim:
 */
      goto __pyx_L52;
    }

    /* "cupy/core/core.pyx":1540
 *                 else:
 *                     strides.push_back(self.itemsize)
 *             elif ndim <= j:             # <<<<<<<<<<<<<<
 *                 raise IndexError("too many indices for array")
 *             elif isinstance(s, slice):
 */
    __pyx_t_9 = ((__pyx_v_ndim <= __pyx_v_j) != 0);
    if (__pyx_t_9) {

      /* "cupy/core/core.pyx":1541
 *                     strides.push_back(self.itemsize)
 *             elif ndim <= j:
 *                 raise IndexError("too many indices for array")             # <<<<<<<<<<<<<<
 *             elif isinstance(s, slice):
 *                 s = internal.complete_slice(s, self._shape[j])
 */
      __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__53, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1541, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_Raise(__pyx_t_10, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __PYX_ERR(0, 1541, __pyx_L1_error)

      /* "cupy/core/core.pyx":1540
 *                 else:
 *                     strides.push_back(self.itemsize)
 *             elif ndim <= j:             # <<<<<<<<<<<<<<
 *                 raise IndexError("too many indices for array")
 *             elif isinstance(s, slice):
 */
    }

    /* "cupy/core/core.pyx":1542
 *             elif ndim <= j:
 *                 raise IndexError("too many indices for array")
 *             elif isinstance(s, slice):             # <<<<<<<<<<<<<<
 *                 s = internal.complete_slice(s, self._shape[j])
 *                 s_start = s.start
 */
    __pyx_t_9 = PySlice_Check(__pyx_v_s); 
    __pyx_t_2 = (__pyx_t_9 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1543
 *                 raise IndexError("too many indices for array")
 *             elif isinstance(s, slice):
 *                 s = internal.complete_slice(s, self._shape[j])             # <<<<<<<<<<<<<<
 *                 s_start = s.start
 *                 s_stop = s.stop
 */
      if (!(likely(PySlice_Check(__pyx_v_s))||((__pyx_v_s) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "slice", Py_TYPE(__pyx_v_s)->tp_name), 0))) __PYX_ERR(0, 1543, __pyx_L1_error)
      __pyx_t_10 = __pyx_f_4cupy_4core_8internal_complete_slice(((PyObject*)__pyx_v_s), (__pyx_v_self->_shape[__pyx_v_j]), 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1543, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_10);
      __pyx_t_10 = 0;

      /* "cupy/core/core.pyx":1544
 *             elif isinstance(s, slice):
 *                 s = internal.complete_slice(s, self._shape[j])
 *                 s_start = s.start             # <<<<<<<<<<<<<<
 *                 s_stop = s.stop
 *                 s_step = s.step
 */
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_start); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1544, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_t_10); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1544, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_v_s_start = __pyx_t_15;

      /* "cupy/core/core.pyx":1545
 *                 s = internal.complete_slice(s, self._shape[j])
 *                 s_start = s.start
 *                 s_stop = s.stop             # <<<<<<<<<<<<<<
 *                 s_step = s.step
 *                 if s_step > 0:
 */
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_stop); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1545, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_t_10); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1545, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_v_s_stop = __pyx_t_15;

      /* "cupy/core/core.pyx":1546
 *                 s_start = s.start
 *                 s_stop = s.stop
 *                 s_step = s.step             # <<<<<<<<<<<<<<
 *                 if s_step > 0:
 *                     dim = (s_stop - s_start - 1) // s_step + 1
 */
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_step); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1546, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_t_10); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1546, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_v_s_step = __pyx_t_15;

      /* "cupy/core/core.pyx":1547
 *                 s_stop = s.stop
 *                 s_step = s.step
 *                 if s_step > 0:             # <<<<<<<<<<<<<<
 *                     dim = (s_stop - s_start - 1) // s_step + 1
 *                 else:
 */
      __pyx_t_2 = ((__pyx_v_s_step > 0) != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1548
 *                 s_step = s.step
 *                 if s_step > 0:
 *                     dim = (s_stop - s_start - 1) // s_step + 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     dim = (s_stop - s_start + 1) // s_step + 1
 */
        __pyx_t_15 = ((__pyx_v_s_stop - __pyx_v_s_start) - 1);
        if (unlikely(__pyx_v_s_step == 0)) {
          PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
          __PYX_ERR(0, 1548, __pyx_L1_error)
        }
        else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_s_step == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_15))) {
          PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
          __PYX_ERR(0, 1548, __pyx_L1_error)
        }
        __pyx_v_dim = (__Pyx_div_Py_ssize_t(__pyx_t_15, __pyx_v_s_step) + 1);

        /* "cupy/core/core.pyx":1547
 *                 s_stop = s.stop
 *                 s_step = s.step
 *                 if s_step > 0:             # <<<<<<<<<<<<<<
 *                     dim = (s_stop - s_start - 1) // s_step + 1
 *                 else:
 */
        goto __pyx_L54;
      }

      /* "cupy/core/core.pyx":1550
 *                     dim = (s_stop - s_start - 1) // s_step + 1
 *                 else:
 *                     dim = (s_stop - s_start + 1) // s_step + 1             # <<<<<<<<<<<<<<
 * 
 *                 if dim == 0:
 */
      /*else*/ {
        __pyx_t_15 = ((__pyx_v_s_stop - __pyx_v_s_start) + 1);
        if (unlikely(__pyx_v_s_step == 0)) {
          PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
          __PYX_ERR(0, 1550, __pyx_L1_error)
        }
        else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_s_step == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_15))) {
          PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
          __PYX_ERR(0, 1550, __pyx_L1_error)
        }
        __pyx_v_dim = (__Pyx_div_Py_ssize_t(__pyx_t_15, __pyx_v_s_step) + 1);
      }
      __pyx_L54:;

      /* "cupy/core/core.pyx":1552
 *                     dim = (s_stop - s_start + 1) // s_step + 1
 * 
 *                 if dim == 0:             # <<<<<<<<<<<<<<
 *                     strides.push_back(self._strides[j])
 *                 else:
 */
      __pyx_t_2 = ((__pyx_v_dim == 0) != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1553
 * 
 *                 if dim == 0:
 *                     strides.push_back(self._strides[j])             # <<<<<<<<<<<<<<
 *                 else:
 *                     strides.push_back(self._strides[j] * s_step)
 */
        try {
          __pyx_v_strides.push_back((__pyx_v_self->_strides[__pyx_v_j]));
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(0, 1553, __pyx_L1_error)
        }

        /* "cupy/core/core.pyx":1552
 *                     dim = (s_stop - s_start + 1) // s_step + 1
 * 
 *                 if dim == 0:             # <<<<<<<<<<<<<<
 *                     strides.push_back(self._strides[j])
 *                 else:
 */
        goto __pyx_L55;
      }

      /* "cupy/core/core.pyx":1555
 *                     strides.push_back(self._strides[j])
 *                 else:
 *                     strides.push_back(self._strides[j] * s_step)             # <<<<<<<<<<<<<<
 * 
 *                 if self.size > 0:
 */
      /*else*/ {
        try {
          __pyx_v_strides.push_back(((__pyx_v_self->_strides[__pyx_v_j]) * __pyx_v_s_step));
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(0, 1555, __pyx_L1_error)
        }
      }
      __pyx_L55:;

      /* "cupy/core/core.pyx":1557
 *                     strides.push_back(self._strides[j] * s_step)
 * 
 *                 if self.size > 0:             # <<<<<<<<<<<<<<
 *                     offset += self._strides[j] * max(0, s_start)
 * 
 */
      __pyx_t_2 = ((__pyx_v_self->size > 0) != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1558
 * 
 *                 if self.size > 0:
 *                     offset += self._strides[j] * max(0, s_start)             # <<<<<<<<<<<<<<
 * 
 *                 shape.push_back(dim)
 */
        __pyx_t_15 = __pyx_v_s_start;
        __pyx_t_16 = 0;
        if (((__pyx_t_15 > __pyx_t_16) != 0)) {
          __pyx_t_17 = __pyx_t_15;
        } else {
          __pyx_t_17 = __pyx_t_16;
        }
        __pyx_v_offset = (__pyx_v_offset + ((__pyx_v_self->_strides[__pyx_v_j]) * __pyx_t_17));

        /* "cupy/core/core.pyx":1557
 *                     strides.push_back(self._strides[j] * s_step)
 * 
 *                 if self.size > 0:             # <<<<<<<<<<<<<<
 *                     offset += self._strides[j] * max(0, s_start)
 * 
 */
      }

      /* "cupy/core/core.pyx":1560
 *                     offset += self._strides[j] * max(0, s_start)
 * 
 *                 shape.push_back(dim)             # <<<<<<<<<<<<<<
 * 
 *                 j += 1
 */
      try {
        __pyx_v_shape.push_back(__pyx_v_dim);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 1560, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":1562
 *                 shape.push_back(dim)
 * 
 *                 j += 1             # <<<<<<<<<<<<<<
 *             elif numpy.isscalar(s):
 *                 ind = int(s)
 */
      __pyx_v_j = (__pyx_v_j + 1);

      /* "cupy/core/core.pyx":1542
 *             elif ndim <= j:
 *                 raise IndexError("too many indices for array")
 *             elif isinstance(s, slice):             # <<<<<<<<<<<<<<
 *                 s = internal.complete_slice(s, self._shape[j])
 *                 s_start = s.start
 */
      goto __pyx_L52;
    }

    /* "cupy/core/core.pyx":1563
 * 
 *                 j += 1
 *             elif numpy.isscalar(s):             # <<<<<<<<<<<<<<
 *                 ind = int(s)
 *                 if ind < 0:
 */
    __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_isscalar); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_11) {
      __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_s); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1563, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_s};
        __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1563, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_10);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_s};
        __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1563, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_10);
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1563, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_11); __pyx_t_11 = NULL;
        __Pyx_INCREF(__pyx_v_s);
        __Pyx_GIVEREF(__pyx_v_s);
        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_s);
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_3, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1563, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1563, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1564
 *                 j += 1
 *             elif numpy.isscalar(s):
 *                 ind = int(s)             # <<<<<<<<<<<<<<
 *                 if ind < 0:
 *                     ind += self._shape[j]
 */
      __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_v_s); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1564, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_17 = __Pyx_PyIndex_AsSsize_t(__pyx_t_10); if (unlikely((__pyx_t_17 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1564, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_v_ind = __pyx_t_17;

      /* "cupy/core/core.pyx":1565
 *             elif numpy.isscalar(s):
 *                 ind = int(s)
 *                 if ind < 0:             # <<<<<<<<<<<<<<
 *                     ind += self._shape[j]
 *                 if not (0 <= ind < self._shape[j]):
 */
      __pyx_t_2 = ((__pyx_v_ind < 0) != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1566
 *                 ind = int(s)
 *                 if ind < 0:
 *                     ind += self._shape[j]             # <<<<<<<<<<<<<<
 *                 if not (0 <= ind < self._shape[j]):
 *                     msg = ('Index %s is out of bounds for axis %s with '
 */
        __pyx_v_ind = (__pyx_v_ind + (__pyx_v_self->_shape[__pyx_v_j]));

        /* "cupy/core/core.pyx":1565
 *             elif numpy.isscalar(s):
 *                 ind = int(s)
 *                 if ind < 0:             # <<<<<<<<<<<<<<
 *                     ind += self._shape[j]
 *                 if not (0 <= ind < self._shape[j]):
 */
      }

      /* "cupy/core/core.pyx":1567
 *                 if ind < 0:
 *                     ind += self._shape[j]
 *                 if not (0 <= ind < self._shape[j]):             # <<<<<<<<<<<<<<
 *                     msg = ('Index %s is out of bounds for axis %s with '
 *                            'size %s' % (s, j, self._shape[j]))
 */
      __pyx_t_2 = (0 <= __pyx_v_ind);
      if (__pyx_t_2) {
        __pyx_t_2 = (__pyx_v_ind < (__pyx_v_self->_shape[__pyx_v_j]));
      }
      __pyx_t_9 = ((!(__pyx_t_2 != 0)) != 0);
      if (__pyx_t_9) {

        /* "cupy/core/core.pyx":1569
 *                 if not (0 <= ind < self._shape[j]):
 *                     msg = ('Index %s is out of bounds for axis %s with '
 *                            'size %s' % (s, j, self._shape[j]))             # <<<<<<<<<<<<<<
 *                     raise IndexError(msg)
 *                 if self.size > 0:
 */
        __pyx_t_10 = PyInt_FromSsize_t(__pyx_v_j); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1569, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_7 = PyInt_FromSsize_t((__pyx_v_self->_shape[__pyx_v_j])); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1569, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1569, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_v_s);
        __Pyx_GIVEREF(__pyx_v_s);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_s);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_7);
        __pyx_t_10 = 0;
        __pyx_t_7 = 0;
        __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Index_s_is_out_of_bounds_for_axi, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1569, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_v_msg = ((PyObject*)__pyx_t_7);
        __pyx_t_7 = 0;

        /* "cupy/core/core.pyx":1570
 *                     msg = ('Index %s is out of bounds for axis %s with '
 *                            'size %s' % (s, j, self._shape[j]))
 *                     raise IndexError(msg)             # <<<<<<<<<<<<<<
 *                 if self.size > 0:
 *                     offset += ind * self._strides[j]
 */
        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1570, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_v_msg);
        __Pyx_GIVEREF(__pyx_v_msg);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_msg);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1570, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __PYX_ERR(0, 1570, __pyx_L1_error)

        /* "cupy/core/core.pyx":1567
 *                 if ind < 0:
 *                     ind += self._shape[j]
 *                 if not (0 <= ind < self._shape[j]):             # <<<<<<<<<<<<<<
 *                     msg = ('Index %s is out of bounds for axis %s with '
 *                            'size %s' % (s, j, self._shape[j]))
 */
      }

      /* "cupy/core/core.pyx":1571
 *                            'size %s' % (s, j, self._shape[j]))
 *                     raise IndexError(msg)
 *                 if self.size > 0:             # <<<<<<<<<<<<<<
 *                     offset += ind * self._strides[j]
 *                 j += 1
 */
      __pyx_t_9 = ((__pyx_v_self->size > 0) != 0);
      if (__pyx_t_9) {

        /* "cupy/core/core.pyx":1572
 *                     raise IndexError(msg)
 *                 if self.size > 0:
 *                     offset += ind * self._strides[j]             # <<<<<<<<<<<<<<
 *                 j += 1
 *             else:
 */
        __pyx_v_offset = (__pyx_v_offset + (__pyx_v_ind * (__pyx_v_self->_strides[__pyx_v_j])));

        /* "cupy/core/core.pyx":1571
 *                            'size %s' % (s, j, self._shape[j]))
 *                     raise IndexError(msg)
 *                 if self.size > 0:             # <<<<<<<<<<<<<<
 *                     offset += ind * self._strides[j]
 *                 j += 1
 */
      }

      /* "cupy/core/core.pyx":1573
 *                 if self.size > 0:
 *                     offset += ind * self._strides[j]
 *                 j += 1             # <<<<<<<<<<<<<<
 *             else:
 *                 raise TypeError('Invalid index type: %s' % type(slices[i]))
 */
      __pyx_v_j = (__pyx_v_j + 1);

      /* "cupy/core/core.pyx":1563
 * 
 *                 j += 1
 *             elif numpy.isscalar(s):             # <<<<<<<<<<<<<<
 *                 ind = int(s)
 *                 if ind < 0:
 */
      goto __pyx_L52;
    }

    /* "cupy/core/core.pyx":1575
 *                 j += 1
 *             else:
 *                 raise TypeError('Invalid index type: %s' % type(slices[i]))             # <<<<<<<<<<<<<<
 * 
 *         # TODO(niboshi): offset can be non-zero even if self.data is an empty
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_slices, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1575, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_index_type_s, ((PyObject *)Py_TYPE(__pyx_t_3))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1575, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1575, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1575, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __PYX_ERR(0, 1575, __pyx_L1_error)
    }
    __pyx_L52:;

    /* "cupy/core/core.pyx":1531
 *         j = 0
 *         offset = 0
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if s is None:
 *                 shape.push_back(1)
 */
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":1579
 *         # TODO(niboshi): offset can be non-zero even if self.data is an empty
 *         # pointer.
 *         v = self.view()             # <<<<<<<<<<<<<<
 *         v.data = self.data + offset
 *         v._set_shape_and_strides(shape, strides)
 */
  __pyx_t_12 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->view(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1579, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_v_v = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":1580
 *         # pointer.
 *         v = self.view()
 *         v.data = self.data + offset             # <<<<<<<<<<<<<<
 *         v._set_shape_and_strides(shape, strides)
 *         return v
 */
  __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_offset); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_7 = PyNumber_Add(((PyObject *)__pyx_v_self->data), __pyx_t_12); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer))))) __PYX_ERR(0, 1580, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_7);
  __Pyx_GOTREF(__pyx_v_v->data);
  __Pyx_DECREF(((PyObject *)__pyx_v_v->data));
  __pyx_v_v->data = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":1581
 *         v = self.view()
 *         v.data = self.data + offset
 *         v._set_shape_and_strides(shape, strides)             # <<<<<<<<<<<<<<
 *         return v
 * 
 */
  __pyx_t_7 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_v->__pyx_vtab)->_set_shape_and_strides(__pyx_v_v, __pyx_v_shape, __pyx_v_strides, 0, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1581, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":1582
 *         v.data = self.data + offset
 *         v._set_shape_and_strides(shape, strides)
 *         return v             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, slices, value):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_v));
  __pyx_r = ((PyObject *)__pyx_v_v);
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1394
 *         return self._shape[0]
 * 
 *     def __getitem__(self, slices):             # <<<<<<<<<<<<<<
 *         """x.__getitem__(y) <==> x[y]
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_noneslices);
  __Pyx_XDECREF(__pyx_v_ellipsis_size);
  __Pyx_XDECREF(__pyx_v_n_not_slice_none);
  __Pyx_XDECREF(__pyx_v_mask_i);
  __Pyx_XDECREF(__pyx_v_basic_slices);
  __Pyx_XDECREF(__pyx_v_adv_slices);
  __Pyx_XDECREF((PyObject *)__pyx_v_scalar_array);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_arr_slices_mask);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XDECREF((PyObject *)__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_slices);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_161__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_slices, PyObject *__pyx_v_value); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_160__setitem__[] = "x.__setitem__(slices, y) <==> x[slices] = y\n\n        Supports both basic and advanced indexing.\n\n        .. note::\n\n            Currently, it does not support ``slices`` that consists of more\n            than one boolean arrays\n\n        .. note::\n\n            CuPy handles out-of-bounds indices differently from NumPy when\n            using integer array indexing.\n            NumPy handles them by raising an error, but CuPy wraps around them.\n\n            >>> import cupy\n            >>> x = cupy.arange(3)\n            >>> x[[1, 3]] = 10\n            >>> x\n            array([10, 10,  2])\n\n        .. note::\n\n            The behavior differs from NumPy when integer arrays in ``slices``\n            reference the same location multiple times.\n            In that case, the value that is actually stored is undefined.\n\n            >>> import cupy; import numpy\n            >>> a = cupy.zeros((2,))\n            >>> i = cupy.arange(10000) % 2\n            >>> v = cupy.arange(10000).astype(numpy.float)\n            >>> a[i] = v\n            >>> a  # doctest: +SKIP\n            array([ 9150.,  9151.])\n\n            On the other hand, NumPy stores the value corresponding to the\n            last index among the indices referencing duplicate locations.\n\n            >>> import numpy\n            >>> a_cpu = numpy.zeros((2,))\n            >>> i_cpu = numpy.arange(10000) % 2\n            >>> v_cpu = numpy.arange(10000).astype(numpy.float)\n            >>> a_cpu[i_cpu] = v_cpu\n            >>> a_cpu\n            array([ 9998.,  9999.])\n\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_4cupy_4core_4core_7ndarray_160__setitem__;
#endif
static int __pyx_pw_4cupy_4core_4core_7ndarray_161__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_slices, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_160__setitem__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_slices), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4cupy_4core_4core_7ndarray_160__setitem__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_slices, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setitem__", 0);

  /* "cupy/core/core.pyx":1632
 * 
 *         """
 *         _scatter_op(self, slices, value, 'update')             # <<<<<<<<<<<<<<
 * 
 *     def scatter_add(self, slices, value):
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__scatter_op(__pyx_v_self, __pyx_v_slices, __pyx_v_value, __pyx_n_s_update, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1632, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

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

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

/* "cupy/core/core.pyx":1634
 *         _scatter_op(self, slices, value, 'update')
 * 
 *     def scatter_add(self, slices, value):             # <<<<<<<<<<<<<<
 *         """Adds given values to specified elements of an array.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_163scatter_add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_162scatter_add[] = "ndarray.scatter_add(self, slices, value)\nAdds given values to specified elements of an array.\n\n        .. seealso::\n            :func:`cupy.scatter_add` for full documentation.\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_163scatter_add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_slices = 0;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("scatter_add (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_slices,&__pyx_n_s_value,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_slices)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("scatter_add", 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, "scatter_add") < 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_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, 1634, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.scatter_add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_162scatter_add(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_slices, __pyx_v_value);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_162scatter_add(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_slices, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("scatter_add", 0);

  /* "cupy/core/core.pyx":1641
 * 
 *         """
 *         _scatter_op(self, slices, value, 'add')             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement __getslice__
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__scatter_op(__pyx_v_self, __pyx_v_slices, __pyx_v_value, __pyx_n_s_add, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1641, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1634
 *         _scatter_op(self, slices, value, 'update')
 * 
 *     def scatter_add(self, slices, value):             # <<<<<<<<<<<<<<
 *         """Adds given values to specified elements of an array.
 * 
 */

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

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_165__int__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_165__int__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__int__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_164__int__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

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

  /* "cupy/core/core.pyx":1650
 * 
 *     def __int__(self):
 *         return int(self.get())             # <<<<<<<<<<<<<<
 * 
 *     if sys.version_info < (3,):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1650, __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, 1650, __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":1649
 *     # 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":1653
 * 
 *     if sys.version_info < (3,):
 *         def __long__(self):             # <<<<<<<<<<<<<<
 *             # Avoid using long() for flake8
 *             return self.get().__long__()
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_167__long__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_167__long__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__long__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_166__long__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_166__long__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__long__", 0);

  /* "cupy/core/core.pyx":1655
 *         def __long__(self):
 *             # Avoid using long() for flake8
 *             return self.get().__long__()             # <<<<<<<<<<<<<<
 * 
 *     def __float__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1655, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_long); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1655, __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, 1655, __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, 1655, __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":1653
 * 
 *     if sys.version_info < (3,):
 *         def __long__(self):             # <<<<<<<<<<<<<<
 *             # Avoid using long() for flake8
 *             return self.get().__long__()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__long__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

/* "cupy/core/core.pyx":1657
 *             return self.get().__long__()
 * 
 *     def __float__(self):             # <<<<<<<<<<<<<<
 *         return float(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_169__float__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_169__float__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__float__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_168__float__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

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

  /* "cupy/core/core.pyx":1658
 * 
 *     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, 1658, __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, 1658, __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":1657
 *             return self.get().__long__()
 * 
 *     def __float__(self):             # <<<<<<<<<<<<<<
 *         return float(self.get())
 * 
 */

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

/* "cupy/core/core.pyx":1660
 *         return float(self.get())
 * 
 *     def __complex__(self):             # <<<<<<<<<<<<<<
 *         return complex(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_171__complex__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_170__complex__[] = "ndarray.__complex__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_171__complex__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__complex__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_170__complex__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

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

  /* "cupy/core/core.pyx":1661
 * 
 *     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, 1661, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1661, __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_PyObject_Call(((PyObject *)(&PyComplex_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1661, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1660
 *         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":1663
 *         return complex(self.get())
 * 
 *     def __oct__(self):             # <<<<<<<<<<<<<<
 *         return oct(self.get())
 * 
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_173__oct__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_173__oct__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__oct__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_172__oct__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000))*/

#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_172__oct__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__oct__", 0);

  /* "cupy/core/core.pyx":1664
 * 
 *     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, 1664, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1664, __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_PyObject_Call(__pyx_builtin_oct, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1664, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1663
 *         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":1666
 *         return oct(self.get())
 * 
 *     def __hex__(self):             # <<<<<<<<<<<<<<
 *         return hex(self.get())
 * 
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_175__hex__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_175__hex__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__hex__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_174__hex__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000))*/

#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_174__hex__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__hex__", 0);

  /* "cupy/core/core.pyx":1667
 * 
 *     def __hex__(self):
 *         return hex(self.get())             # <<<<<<<<<<<<<<
 * 
 *     # String representations:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1667, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1667, __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_PyObject_Call(__pyx_builtin_hex, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1667, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1666
 *         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":1671
 *     # String representations:
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return repr(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_177__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_177__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_176__repr__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

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

  /* "cupy/core/core.pyx":1672
 * 
 *     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, 1672, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1672, __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":1671
 *     # 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":1674
 *         return repr(self.get())
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return str(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_179__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_179__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_178__str__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

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

  /* "cupy/core/core.pyx":1675
 * 
 *     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, 1675, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1675, __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_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1675, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1674
 *         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":1680
 *     # Methods outside of the ndarray main documentation
 *     # -------------------------------------------------------------------------
 *     def dot(self, ndarray b, ndarray out=None):             # <<<<<<<<<<<<<<
 *         """Returns the dot product with given array.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_181dot(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_180dot[] = "ndarray.dot(self, ndarray b, ndarray out=None)\nReturns the dot product with given array.\n\n        .. seealso::\n           :func:`cupy.dot` for full documentation,\n           :meth:`numpy.ndarray.dot`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_181dot(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dot (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_b,&__pyx_n_s_out,0};
    PyObject* values[2] = {0,0};
    values[1] = (PyObject *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__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 = PyDict_GetItem(__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, 1680, __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, 1680, __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, 1680, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(0, 1680, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_180dot(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_b, __pyx_v_out);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_180dot(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_dot __pyx_t_2;
  __Pyx_RefNannySetupContext("dot", 0);

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

  /* "cupy/core/core.pyx":1680
 *     # 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":1694
 *     # -------------------------------------------------------------------------
 *     @property
 *     def device(self):             # <<<<<<<<<<<<<<
 *         """CUDA device on which this array resides."""
 *         return self.data.device
 */

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

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

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

  /* "cupy/core/core.pyx":1696
 *     def device(self):
 *         """CUDA device on which this array resides."""
 *         return self.data.device             # <<<<<<<<<<<<<<
 * 
 *     cpdef get(self, stream=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->data->device));
  __pyx_r = ((PyObject *)__pyx_v_self->data->device);
  goto __pyx_L0;

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

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

/* "cupy/core/core.pyx":1698
 *         return self.data.device
 * 
 *     cpdef get(self, stream=None):             # <<<<<<<<<<<<<<
 *         """Returns a copy of the array on host memory.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_183get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_get(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_get *__pyx_optional_args) {
  PyObject *__pyx_v_stream = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a_gpu = NULL;
  PyObject *__pyx_v_a_cpu = NULL;
  PyObject *__pyx_v_ptr = NULL;
  PyObject *__pyx_v_stream_ptr = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  size_t __pyx_t_13;
  struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_to_host_async __pyx_t_14;
  __Pyx_RefNannySetupContext("get", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_stream = __pyx_optional_args->stream;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1698, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_183get)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_stream); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1698, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_stream};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1698, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_stream};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1698, __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, 1698, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
          __Pyx_INCREF(__pyx_v_stream);
          __Pyx_GIVEREF(__pyx_v_stream);
          PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_stream);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1698, __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":1710
 * 
 *         """
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return numpy.ndarray(self.shape, dtype=self.dtype)
 * 
 */
  __pyx_t_6 = ((__pyx_v_self->size == 0) != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":1711
 *         """
 *         if self.size == 0:
 *             return numpy.ndarray(self.shape, dtype=self.dtype)             # <<<<<<<<<<<<<<
 * 
 *         with self.device:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1711, __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, 1711, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1711, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1711, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1711, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_self->dtype) < 0) __PYX_ERR(0, 1711, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1711, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1710
 * 
 *         """
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return numpy.ndarray(self.shape, dtype=self.dtype)
 * 
 */
  }

  /* "cupy/core/core.pyx":1713
 *             return numpy.ndarray(self.shape, dtype=self.dtype)
 * 
 *         with self.device:             # <<<<<<<<<<<<<<
 *             a_gpu = ascontiguousarray(self)
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 */
  /*with:*/ {
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_device); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1713, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_5, __pyx_n_s_exit); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1713, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_5, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1713, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_2) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1713, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1713, __pyx_L4_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    /*try:*/ {
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
        __Pyx_XGOTREF(__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_9);
        __Pyx_XGOTREF(__pyx_t_10);
        /*try:*/ {

          /* "cupy/core/core.pyx":1714
 * 
 *         with self.device:
 *             a_gpu = ascontiguousarray(self)             # <<<<<<<<<<<<<<
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 *         ptr = a_cpu.ctypes.get_as_parameter()
 */
          __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_ascontiguousarray(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1714, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_v_a_gpu = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
          __pyx_t_5 = 0;

          /* "cupy/core/core.pyx":1713
 *             return numpy.ndarray(self.shape, dtype=self.dtype)
 * 
 *         with self.device:             # <<<<<<<<<<<<<<
 *             a_gpu = ascontiguousarray(self)
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 */
        }
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L13_try_end;
        __pyx_L8_error:;
        __Pyx_PyThreadState_assign
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        /*except:*/ {
          __Pyx_AddTraceback("cupy.core.core.ndarray.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 1713, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_2 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1713, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_2, NULL);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1713, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (__pyx_t_6 < 0) __PYX_ERR(0, 1713, __pyx_L10_except_error)
          __pyx_t_12 = ((!(__pyx_t_6 != 0)) != 0);
          if (__pyx_t_12) {
            __Pyx_GIVEREF(__pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_1);
            __Pyx_XGIVEREF(__pyx_t_3);
            __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_1, __pyx_t_3);
            __pyx_t_5 = 0; __pyx_t_1 = 0; __pyx_t_3 = 0; 
            __PYX_ERR(0, 1713, __pyx_L10_except_error)
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          goto __pyx_L9_exception_handled;
        }
        __pyx_L10_except_error:;
        __Pyx_PyThreadState_assign
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        goto __pyx_L1_error;
        __pyx_L9_exception_handled:;
        __Pyx_PyThreadState_assign
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        __pyx_L13_try_end:;
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_7) {
          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__54, NULL);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1713, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    goto __pyx_L17;
    __pyx_L4_error:;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L1_error;
    __pyx_L17:;
  }

  /* "cupy/core/core.pyx":1715
 *         with self.device:
 *             a_gpu = ascontiguousarray(self)
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)             # <<<<<<<<<<<<<<
 *         ptr = a_cpu.ctypes.get_as_parameter()
 *         if stream is None:
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_self->dtype) < 0) __PYX_ERR(0, 1715, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_a_cpu = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":1716
 *             a_gpu = ascontiguousarray(self)
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 *         ptr = a_cpu.ctypes.get_as_parameter()             # <<<<<<<<<<<<<<
 *         if stream is None:
 *             stream_ptr = stream_module.get_current_stream_ptr()
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_ctypes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1716, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_as_parameter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1716, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1716, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1716, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_ptr = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":1717
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 *         ptr = a_cpu.ctypes.get_as_parameter()
 *         if stream is None:             # <<<<<<<<<<<<<<
 *             stream_ptr = stream_module.get_current_stream_ptr()
 *         else:
 */
  __pyx_t_12 = (__pyx_v_stream == Py_None);
  __pyx_t_6 = (__pyx_t_12 != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":1718
 *         ptr = a_cpu.ctypes.get_as_parameter()
 *         if stream is None:
 *             stream_ptr = stream_module.get_current_stream_ptr()             # <<<<<<<<<<<<<<
 *         else:
 *             stream_ptr = stream.ptr
 */
    __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_f_4cupy_4cuda_6stream_get_current_stream_ptr()); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1718, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_stream_ptr = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":1717
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 *         ptr = a_cpu.ctypes.get_as_parameter()
 *         if stream is None:             # <<<<<<<<<<<<<<
 *             stream_ptr = stream_module.get_current_stream_ptr()
 *         else:
 */
    goto __pyx_L18;
  }

  /* "cupy/core/core.pyx":1720
 *             stream_ptr = stream_module.get_current_stream_ptr()
 *         else:
 *             stream_ptr = stream.ptr             # <<<<<<<<<<<<<<
 *         if stream_ptr == 0:
 *             a_gpu.data.copy_to_host(ptr, a_gpu.nbytes)
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_stream, __pyx_n_s_ptr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1720, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_stream_ptr = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_L18:;

  /* "cupy/core/core.pyx":1721
 *         else:
 *             stream_ptr = stream.ptr
 *         if stream_ptr == 0:             # <<<<<<<<<<<<<<
 *             a_gpu.data.copy_to_host(ptr, a_gpu.nbytes)
 *         else:
 */
  __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_v_stream_ptr, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":1722
 *             stream_ptr = 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, stream)
 */
    if (unlikely(!__pyx_v_a_gpu)) { __Pyx_RaiseUnboundLocalError("a_gpu"); __PYX_ERR(0, 1722, __pyx_L1_error) }
    if (unlikely(!__pyx_v_a_gpu)) { __Pyx_RaiseUnboundLocalError("a_gpu"); __PYX_ERR(0, 1722, __pyx_L1_error) }
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a_gpu), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1722, __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, 1722, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_a_gpu->data->__pyx_vtab)->copy_to_host(__pyx_v_a_gpu->data, __pyx_v_ptr, __pyx_t_13, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":1721
 *         else:
 *             stream_ptr = stream.ptr
 *         if stream_ptr == 0:             # <<<<<<<<<<<<<<
 *             a_gpu.data.copy_to_host(ptr, a_gpu.nbytes)
 *         else:
 */
    goto __pyx_L19;
  }

  /* "cupy/core/core.pyx":1724
 *             a_gpu.data.copy_to_host(ptr, a_gpu.nbytes)
 *         else:
 *             a_gpu.data.copy_to_host_async(ptr, a_gpu.nbytes, stream)             # <<<<<<<<<<<<<<
 *         return a_cpu
 * 
 */
  /*else*/ {
    if (unlikely(!__pyx_v_a_gpu)) { __Pyx_RaiseUnboundLocalError("a_gpu"); __PYX_ERR(0, 1724, __pyx_L1_error) }
    if (unlikely(!__pyx_v_a_gpu)) { __Pyx_RaiseUnboundLocalError("a_gpu"); __PYX_ERR(0, 1724, __pyx_L1_error) }
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a_gpu), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1724, __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, 1724, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_14.__pyx_n = 1;
    __pyx_t_14.stream = __pyx_v_stream;
    __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_a_gpu->data->__pyx_vtab)->copy_to_host_async(__pyx_v_a_gpu->data, __pyx_v_ptr, __pyx_t_13, 0, &__pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_L19:;

  /* "cupy/core/core.pyx":1725
 *         else:
 *             a_gpu.data.copy_to_host_async(ptr, a_gpu.nbytes, stream)
 *         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":1698
 *         return self.data.device
 * 
 *     cpdef get(self, stream=None):             # <<<<<<<<<<<<<<
 *         """Returns a copy of the array on host memory.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_a_gpu);
  __Pyx_XDECREF(__pyx_v_a_cpu);
  __Pyx_XDECREF(__pyx_v_ptr);
  __Pyx_XDECREF(__pyx_v_stream_ptr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_183get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_182get[] = "ndarray.get(self, stream=None)\nReturns a copy of the array on host memory.\n\n        Args:\n            stream (cupy.cuda.Stream): CUDA stream object. If it is given, the\n                copy runs asynchronously. Otherwise, the copy is synchronous.\n                The default uses CUDA stream object of the current context.\n\n        Returns:\n            numpy.ndarray: Copy of the array on host memory.\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_183get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_stream = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_stream,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stream);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(0, 1698, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_stream = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1698, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_182get(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_stream);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_182get(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_stream) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_get __pyx_t_2;
  __Pyx_RefNannySetupContext("get", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.stream = __pyx_v_stream;
  __pyx_t_1 = __pyx_vtabptr_4cupy_4core_4core_ndarray->get(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1698, __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":1727
 *         return a_cpu
 * 
 *     cpdef set(self, arr, stream=None):             # <<<<<<<<<<<<<<
 *         """Copies an array on the host memory to :class:`cupy.ndarray`.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_185set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_set(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_arr, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set *__pyx_optional_args) {
  PyObject *__pyx_v_stream = ((PyObject *)Py_None);
  PyObject *__pyx_v_ptr = NULL;
  PyObject *__pyx_v_stream_ptr = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  size_t __pyx_t_10;
  struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_host_async __pyx_t_11;
  __Pyx_RefNannySetupContext("set", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_stream = __pyx_optional_args->stream;
    }
  }
  __Pyx_INCREF(__pyx_v_arr);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1727, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_185set)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_arr, __pyx_v_stream};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1727, __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, 1727, __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, 1727, __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, 1727, __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":1737
 * 
 *         """
 *         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, 1737, __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, 1737, __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 == -1)) __PYX_ERR(0, 1737, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = ((!(__pyx_t_7 != 0)) != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1738
 *         """
 *         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__55, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1738, __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, 1738, __pyx_L1_error)

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

    /* "cupy/core/core.pyx":1740
 *             raise TypeError('Only numpy.ndarray can be set to cupy.ndarray')
 *         if self.dtype != arr.dtype:
 *             raise TypeError('{} array cannot be set to {} array'.format(             # <<<<<<<<<<<<<<
 *                 arr.dtype, self.dtype))
 *         if self.shape != arr.shape:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_array_cannot_be_set_to_array, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1740, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);

    /* "cupy/core/core.pyx":1741
 *         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, 1741, __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, 1740, __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, 1740, __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, 1740, __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, 1740, __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":1740
 *             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 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1740, __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_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1740, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 1740, __pyx_L1_error)

    /* "cupy/core/core.pyx":1739
 *         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":1742
 *             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_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1742, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 1742, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1744
 *         if self.shape != arr.shape:
 *             raise ValueError(
 *                 'Shape mismatch. Old shape: {}, new shape: {}'.format(             # <<<<<<<<<<<<<<
 *                     self.shape, arr.shape))
 *         if self._c_contiguous:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Shape_mismatch_Old_shape_new_sha, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1744, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);

    /* "cupy/core/core.pyx":1745
 *             raise ValueError(
 *                 'Shape mismatch. Old shape: {}, new shape: {}'.format(
 *                     self.shape, arr.shape))             # <<<<<<<<<<<<<<
 *         if self._c_contiguous:
 *             arr = numpy.ascontiguousarray(arr)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1745, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1745, __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_1, __pyx_t_3};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1744, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_1, __pyx_t_3};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1744, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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, 1744, __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_1);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_5, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_5, __pyx_t_3);
      __pyx_t_1 = 0;
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1744, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":1743
 *                 arr.dtype, self.dtype))
 *         if self.shape != arr.shape:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'Shape mismatch. Old shape: {}, new shape: {}'.format(
 *                     self.shape, arr.shape))
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 1743, __pyx_L1_error)

    /* "cupy/core/core.pyx":1742
 *             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":1746
 *                 '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":1747
 *                     self.shape, arr.shape))
 *         if self._c_contiguous:
 *             arr = numpy.ascontiguousarray(arr)             # <<<<<<<<<<<<<<
 *         elif self._f_contiguous:
 *             arr = numpy.asfortranarray(arr)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1747, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ascontiguousarray); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1747, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_2) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_arr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1747, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_arr};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1747, __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_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_arr};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1747, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1747, __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 = NULL;
        __Pyx_INCREF(__pyx_v_arr);
        __Pyx_GIVEREF(__pyx_v_arr);
        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_arr);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1747, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __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_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":1746
 *                 '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":1748
 *         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 (__pyx_t_8) {

    /* "cupy/core/core.pyx":1749
 *             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, 1749, __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, 1749, __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_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_arr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1749, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_arr};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1749, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } 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_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1749, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      {
        __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1749, __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_INCREF(__pyx_v_arr);
        __Pyx_GIVEREF(__pyx_v_arr);
        PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_arr);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1749, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_arr, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":1748
 *         if self._c_contiguous:
 *             arr = numpy.ascontiguousarray(arr)
 *         elif self._f_contiguous:             # <<<<<<<<<<<<<<
 *             arr = numpy.asfortranarray(arr)
 *         else:
 */
    goto __pyx_L6;
  }

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

  /* "cupy/core/core.pyx":1753
 *             raise RuntimeError('Cannot set to non-contiguous array')
 * 
 *         ptr = arr.ctypes.get_as_parameter()             # <<<<<<<<<<<<<<
 *         if stream is None:
 *             stream_ptr = stream_module.get_current_stream_ptr()
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_ctypes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1753, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_as_parameter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1753, __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 && 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, 1753, __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, 1753, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_ptr = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":1754
 * 
 *         ptr = arr.ctypes.get_as_parameter()
 *         if stream is None:             # <<<<<<<<<<<<<<
 *             stream_ptr = stream_module.get_current_stream_ptr()
 *         else:
 */
  __pyx_t_8 = (__pyx_v_stream == Py_None);
  __pyx_t_7 = (__pyx_t_8 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":1755
 *         ptr = arr.ctypes.get_as_parameter()
 *         if stream is None:
 *             stream_ptr = stream_module.get_current_stream_ptr()             # <<<<<<<<<<<<<<
 *         else:
 *             stream_ptr = stream.ptr
 */
    __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_f_4cupy_4cuda_6stream_get_current_stream_ptr()); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1755, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_stream_ptr = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":1754
 * 
 *         ptr = arr.ctypes.get_as_parameter()
 *         if stream is None:             # <<<<<<<<<<<<<<
 *             stream_ptr = stream_module.get_current_stream_ptr()
 *         else:
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":1757
 *             stream_ptr = stream_module.get_current_stream_ptr()
 *         else:
 *             stream_ptr = stream.ptr             # <<<<<<<<<<<<<<
 *         if stream_ptr == 0:
 *             self.data.copy_from_host(ptr, self.nbytes)
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_stream, __pyx_n_s_ptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1757, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_stream_ptr = __pyx_t_4;
    __pyx_t_4 = 0;
  }
  __pyx_L7:;

  /* "cupy/core/core.pyx":1758
 *         else:
 *             stream_ptr = stream.ptr
 *         if stream_ptr == 0:             # <<<<<<<<<<<<<<
 *             self.data.copy_from_host(ptr, self.nbytes)
 *         else:
 */
  __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_v_stream_ptr, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 1758, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":1759
 *             stream_ptr = stream.ptr
 *         if stream_ptr == 0:
 *             self.data.copy_from_host(ptr, self.nbytes)             # <<<<<<<<<<<<<<
 *         else:
 *             self.data.copy_from_host_async(ptr, self.nbytes, stream)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1759, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_10 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_10 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1759, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_self->data->__pyx_vtab)->copy_from_host(__pyx_v_self->data, __pyx_v_ptr, __pyx_t_10, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1759, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":1758
 *         else:
 *             stream_ptr = stream.ptr
 *         if stream_ptr == 0:             # <<<<<<<<<<<<<<
 *             self.data.copy_from_host(ptr, self.nbytes)
 *         else:
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":1761
 *             self.data.copy_from_host(ptr, self.nbytes)
 *         else:
 *             self.data.copy_from_host_async(ptr, self.nbytes, stream)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray reduced_view(self, dtype=None):
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1761, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_10 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_10 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1761, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_11.__pyx_n = 1;
    __pyx_t_11.stream = __pyx_v_stream;
    __pyx_t_4 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_self->data->__pyx_vtab)->copy_from_host_async(__pyx_v_self->data, __pyx_v_ptr, __pyx_t_10, 0, &__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1761, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L8:;

  /* "cupy/core/core.pyx":1727
 *         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_stream_ptr);
  __Pyx_XDECREF(__pyx_v_arr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_185set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_184set[] = "ndarray.set(self, arr, stream=None)\nCopies an array on the host memory to :class:`cupy.ndarray`.\n\n        Args:\n            arr (numpy.ndarray): The source array on the host memory.\n            stream (cupy.cuda.Stream): CUDA stream object. If it is given, the\n                copy runs asynchronously. Otherwise, the copy is synchronous.\n                The default uses CUDA stream object of the current context.\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_185set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_arr = 0;
  PyObject *__pyx_v_stream = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_stream,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__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 = PyDict_GetItem(__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, 1727, __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, 1727, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_184set(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_arr, __pyx_v_stream);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_184set(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_arr, PyObject *__pyx_v_stream) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set __pyx_t_2;
  __Pyx_RefNannySetupContext("set", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.stream = __pyx_v_stream;
  __pyx_t_1 = __pyx_vtabptr_4cupy_4core_4core_ndarray->set(__pyx_v_self, __pyx_v_arr, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1727, __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":1763
 *             self.data.copy_from_host_async(ptr, self.nbytes, stream)
 * 
 *     cpdef ndarray reduced_view(self, dtype=None):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array with minimum number of dimensions.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_187reduced_view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_reduced_view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_reduced_view *__pyx_optional_args) {
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  std::vector<Py_ssize_t>  __pyx_v_shape;
  std::vector<Py_ssize_t>  __pyx_v_strides;
  Py_ssize_t __pyx_v_ndim;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_view = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view __pyx_t_8;
  __Pyx_RefNannySetupContext("reduced_view", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_dtype = __pyx_optional_args->dtype;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reduced_view); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1763, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_187reduced_view)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1763, __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, 1763, __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, 1763, __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, 1763, __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, 1763, __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, 1763, __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":1776
 *         cdef vector.vector[Py_ssize_t] shape, strides
 *         cdef Py_ssize_t ndim
 *         ndim = self._shape.size()             # <<<<<<<<<<<<<<
 *         if ndim <= 1:
 *             return self
 */
  __pyx_v_ndim = __pyx_v_self->_shape.size();

  /* "cupy/core/core.pyx":1777
 *         cdef Py_ssize_t ndim
 *         ndim = self._shape.size()
 *         if ndim <= 1:             # <<<<<<<<<<<<<<
 *             return self
 *         internal.get_reduced_dims(
 */
  __pyx_t_6 = ((__pyx_v_ndim <= 1) != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":1778
 *         ndim = self._shape.size()
 *         if ndim <= 1:
 *             return self             # <<<<<<<<<<<<<<
 *         internal.get_reduced_dims(
 *             self._shape, self._strides, self.itemsize, shape, strides)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1777
 *         cdef Py_ssize_t ndim
 *         ndim = self._shape.size()
 *         if ndim <= 1:             # <<<<<<<<<<<<<<
 *             return self
 *         internal.get_reduced_dims(
 */
  }

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

  /* "cupy/core/core.pyx":1779
 *         if ndim <= 1:
 *             return self
 *         internal.get_reduced_dims(             # <<<<<<<<<<<<<<
 *             self._shape, self._strides, self.itemsize, shape, strides)
 *         if ndim == <Py_ssize_t>shape.size():
 */
  __pyx_f_4cupy_4core_8internal_get_reduced_dims(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_t_7, __pyx_v_shape, __pyx_v_strides);

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

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

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

  /* "cupy/core/core.pyx":1784
 *             return self
 * 
 *         view = self.view(dtype=dtype)             # <<<<<<<<<<<<<<
 *         view._set_shape_and_strides(shape, strides)
 *         return view
 */
  __pyx_t_8.__pyx_n = 1;
  __pyx_t_8.dtype = __pyx_v_dtype;
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->view(__pyx_v_self, 0, &__pyx_t_8)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1784, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_view = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1785
 * 
 *         view = self.view(dtype=dtype)
 *         view._set_shape_and_strides(shape, strides)             # <<<<<<<<<<<<<<
 *         return view
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_v_shape, __pyx_v_strides, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1786
 *         view = self.view(dtype=dtype)
 *         view._set_shape_and_strides(shape, strides)
 *         return view             # <<<<<<<<<<<<<<
 * 
 *     cpdef _update_c_contiguity(self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_view));
  __pyx_r = __pyx_v_view;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1763
 *             self.data.copy_from_host_async(ptr, self.nbytes, stream)
 * 
 *     cpdef ndarray reduced_view(self, dtype=None):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array with minimum number of dimensions.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.reduced_view", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_view);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_187reduced_view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_186reduced_view[] = "ndarray.reduced_view(self, dtype=None) -> ndarray\nReturns a view of the array with minimum number of dimensions.\n\n        Args:\n            dtype: Data type specifier. If it is given, then the memory\n                sequence is reinterpreted as the new type.\n\n        Returns:\n            cupy.ndarray: A view of the array with reduced dimensions.\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_187reduced_view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reduced_view (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dtype,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 1763, __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, 1763, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.reduced_view", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_186reduced_view(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_dtype);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_186reduced_view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_reduced_view __pyx_t_2;
  __Pyx_RefNannySetupContext("reduced_view", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->reduced_view(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1763, __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":1788
 *         return view
 * 
 *     cpdef _update_c_contiguity(self):             # <<<<<<<<<<<<<<
 *         if self.size == 0:
 *             self._c_contiguous = True
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_189_update_c_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__update_c_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("_update_c_contiguity", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_update_c_contiguity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1788, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_189_update_c_contiguity)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1788, __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, 1788, __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":1789
 * 
 *     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":1790
 *     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":1791
 *         if self.size == 0:
 *             self._c_contiguous = True
 *             return             # <<<<<<<<<<<<<<
 *         self._c_contiguous = internal.get_c_contiguity(
 *             self._shape, self._strides, self.itemsize)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

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

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

  /* "cupy/core/core.pyx":1792
 *             self._c_contiguous = True
 *             return
 *         self._c_contiguous = internal.get_c_contiguity(             # <<<<<<<<<<<<<<
 *             self._shape, self._strides, self.itemsize)
 * 
 */
  __pyx_t_5 = __pyx_f_4cupy_4core_8internal_get_c_contiguity(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_t_6, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1792, __pyx_L1_error)
  __pyx_v_self->_c_contiguous = __pyx_t_5;

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

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.ndarray._update_c_contiguity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_189_update_c_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_188_update_c_contiguity[] = "ndarray._update_c_contiguity(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_189_update_c_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_update_c_contiguity (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_188_update_c_contiguity(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_188_update_c_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_update_c_contiguity", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray__update_c_contiguity(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1788, __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":1795
 *             self._shape, self._strides, self.itemsize)
 * 
 *     cpdef _update_f_contiguity(self):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i, count
 *         cdef vector.vector[Py_ssize_t] rev_shape, rev_strides
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_191_update_f_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__update_f_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_count;
  std::vector<Py_ssize_t>  __pyx_v_rev_shape;
  std::vector<Py_ssize_t>  __pyx_v_rev_strides;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  std::vector<Py_ssize_t> ::iterator __pyx_t_6;
  std::vector<Py_ssize_t>  *__pyx_t_7;
  Py_ssize_t __pyx_t_8;
  __Pyx_RefNannySetupContext("_update_f_contiguity", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_update_f_contiguity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1795, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_191_update_f_contiguity)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1795, __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, 1795, __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":1798
 *         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":1799
 *         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":1800
 *         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":1798
 *         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":1801
 *             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":1802
 *             return
 *         if self._c_contiguous:
 *             count = 0             # <<<<<<<<<<<<<<
 *             for i in self._shape:
 *                 if i == 1:
 */
    __pyx_v_count = 0;

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

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

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

  /* "cupy/core/core.pyx":1809
 *             return
 *         rev_shape.assign(self._shape.rbegin(), self._shape.rend())
 *         rev_strides.assign(self._strides.rbegin(), self._strides.rend())             # <<<<<<<<<<<<<<
 *         self._f_contiguous = internal.get_c_contiguity(
 *             rev_shape, rev_strides, self.itemsize)
 */
  try {
    __pyx_v_rev_strides.assign(__pyx_v_self->_strides.rbegin(), __pyx_v_self->_strides.rend());
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 1809, __pyx_L1_error)
  }

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

  /* "cupy/core/core.pyx":1810
 *         rev_shape.assign(self._shape.rbegin(), self._shape.rend())
 *         rev_strides.assign(self._strides.rbegin(), self._strides.rend())
 *         self._f_contiguous = internal.get_c_contiguity(             # <<<<<<<<<<<<<<
 *             rev_shape, rev_strides, self.itemsize)
 * 
 */
  __pyx_t_5 = __pyx_f_4cupy_4core_8internal_get_c_contiguity(__pyx_v_rev_shape, __pyx_v_rev_strides, __pyx_t_8, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1810, __pyx_L1_error)
  __pyx_v_self->_f_contiguous = __pyx_t_5;

  /* "cupy/core/core.pyx":1795
 *             self._shape, self._strides, self.itemsize)
 * 
 *     cpdef _update_f_contiguity(self):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i, count
 *         cdef vector.vector[Py_ssize_t] rev_shape, rev_strides
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.ndarray._update_f_contiguity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_191_update_f_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_190_update_f_contiguity[] = "ndarray._update_f_contiguity(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_191_update_f_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_update_f_contiguity (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_190_update_f_contiguity(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_190_update_f_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_update_f_contiguity", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray__update_f_contiguity(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1795, __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":1813
 *             rev_shape, rev_strides, self.itemsize)
 * 
 *     cpdef _update_contiguity(self):             # <<<<<<<<<<<<<<
 *         self._update_c_contiguity()
 *         self._update_f_contiguity()
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_193_update_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__update_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("_update_contiguity", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_update_contiguity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1813, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_193_update_contiguity)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1813, __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, 1813, __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":1814
 * 
 *     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, 1814, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1815
 *     cpdef _update_contiguity(self):
 *         self._update_c_contiguity()
 *         self._update_f_contiguity()             # <<<<<<<<<<<<<<
 * 
 *     cpdef _set_shape_and_strides(self, vector.vector[Py_ssize_t] & shape,
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_update_f_contiguity(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1815, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1813
 *             rev_shape, rev_strides, self.itemsize)
 * 
 *     cpdef _update_contiguity(self):             # <<<<<<<<<<<<<<
 *         self._update_c_contiguity()
 *         self._update_f_contiguity()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.ndarray._update_contiguity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_193_update_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_192_update_contiguity[] = "ndarray._update_contiguity(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_193_update_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_update_contiguity (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_192_update_contiguity(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_192_update_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_update_contiguity", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray__update_contiguity(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1813, __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":1817
 *         self._update_f_contiguity()
 * 
 *     cpdef _set_shape_and_strides(self, vector.vector[Py_ssize_t] & shape,             # <<<<<<<<<<<<<<
 *                                  vector.vector[Py_ssize_t] & strides,
 *                                  bint update_c_contiguity=True):
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_195_set_shape_and_strides(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__set_shape_and_strides(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  &__pyx_v_shape, std::vector<Py_ssize_t>  &__pyx_v_strides, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides *__pyx_optional_args) {

  /* "cupy/core/core.pyx":1819
 *     cpdef _set_shape_and_strides(self, vector.vector[Py_ssize_t] & shape,
 *                                  vector.vector[Py_ssize_t] & strides,
 *                                  bint update_c_contiguity=True):             # <<<<<<<<<<<<<<
 *         if shape.size() != strides.size():
 *             raise ValueError('len(shape) != len(strides)')
 */
  int __pyx_v_update_c_contiguity = ((int)1);
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("_set_shape_and_strides", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_update_c_contiguity = __pyx_optional_args->update_c_contiguity;
    }
  }

  /* "cupy/core/core.pyx":1817
 *         self._update_f_contiguity()
 * 
 *     cpdef _set_shape_and_strides(self, vector.vector[Py_ssize_t] & shape,             # <<<<<<<<<<<<<<
 *                                  vector.vector[Py_ssize_t] & strides,
 *                                  bint update_c_contiguity=True):
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_shape_and_strides); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1817, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_195_set_shape_and_strides)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1817, __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, 1817, __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, 1817, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_6 = __pyx_t_1; __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_8 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1817, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1817, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1817, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (__pyx_t_7) {
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_5);
        __pyx_t_3 = 0;
        __pyx_t_4 = 0;
        __pyx_t_5 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1817, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1820
 *                                  vector.vector[Py_ssize_t] & strides,
 *                                  bint update_c_contiguity=True):
 *         if shape.size() != strides.size():             # <<<<<<<<<<<<<<
 *             raise ValueError('len(shape) != len(strides)')
 *         self._shape = shape
 */
  __pyx_t_10 = ((__pyx_v_shape.size() != __pyx_v_strides.size()) != 0);
  if (__pyx_t_10) {

    /* "cupy/core/core.pyx":1821
 *                                  bint update_c_contiguity=True):
 *         if shape.size() != strides.size():
 *             raise ValueError('len(shape) != len(strides)')             # <<<<<<<<<<<<<<
 *         self._shape = shape
 *         self._strides = strides
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__57, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1821, __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, 1821, __pyx_L1_error)

    /* "cupy/core/core.pyx":1820
 *                                  vector.vector[Py_ssize_t] & strides,
 *                                  bint update_c_contiguity=True):
 *         if shape.size() != strides.size():             # <<<<<<<<<<<<<<
 *             raise ValueError('len(shape) != len(strides)')
 *         self._shape = shape
 */
  }

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

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

  /* "cupy/core/core.pyx":1824
 *         self._shape = shape
 *         self._strides = strides
 *         self.size = internal.prod_ssize_t(shape)             # <<<<<<<<<<<<<<
 *         if update_c_contiguity:
 *             self._update_contiguity()
 */
  __pyx_v_self->size = __pyx_f_4cupy_4core_8internal_prod_ssize_t(__pyx_v_shape, 0, NULL);

  /* "cupy/core/core.pyx":1825
 *         self._strides = strides
 *         self.size = internal.prod_ssize_t(shape)
 *         if update_c_contiguity:             # <<<<<<<<<<<<<<
 *             self._update_contiguity()
 *         else:
 */
  __pyx_t_10 = (__pyx_v_update_c_contiguity != 0);
  if (__pyx_t_10) {

    /* "cupy/core/core.pyx":1826
 *         self.size = internal.prod_ssize_t(shape)
 *         if update_c_contiguity:
 *             self._update_contiguity()             # <<<<<<<<<<<<<<
 *         else:
 *             self._update_f_contiguity()
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_update_contiguity(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1826, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1825
 *         self._strides = strides
 *         self.size = internal.prod_ssize_t(shape)
 *         if update_c_contiguity:             # <<<<<<<<<<<<<<
 *             self._update_contiguity()
 *         else:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":1828
 *             self._update_contiguity()
 *         else:
 *             self._update_f_contiguity()             # <<<<<<<<<<<<<<
 * 
 *     cdef function.CPointer get_pointer(self):
 */
  /*else*/ {
    __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_update_f_contiguity(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1828, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":1817
 *         self._update_f_contiguity()
 * 
 *     cpdef _set_shape_and_strides(self, vector.vector[Py_ssize_t] & shape,             # <<<<<<<<<<<<<<
 *                                  vector.vector[Py_ssize_t] & strides,
 *                                  bint update_c_contiguity=True):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core.ndarray._set_shape_and_strides", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_195_set_shape_and_strides(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_194_set_shape_and_strides[] = "ndarray._set_shape_and_strides(self, vector[Py_ssize_t] shape, vector[Py_ssize_t] strides, bool update_c_contiguity=True)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_195_set_shape_and_strides(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  std::vector<Py_ssize_t>  __pyx_v_shape;
  std::vector<Py_ssize_t>  __pyx_v_strides;
  int __pyx_v_update_c_contiguity;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_set_shape_and_strides (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_strides,&__pyx_n_s_update_c_contiguity_2,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_strides)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_set_shape_and_strides", 0, 2, 3, 1); __PYX_ERR(0, 1817, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_update_c_contiguity_2);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_set_shape_and_strides") < 0)) __PYX_ERR(0, 1817, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_shape = __pyx_convert_vector_from_py_Py_ssize_t(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1817, __pyx_L3_error)
    __pyx_v_strides = __pyx_convert_vector_from_py_Py_ssize_t(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1818, __pyx_L3_error)
    if (values[2]) {
      __pyx_v_update_c_contiguity = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_update_c_contiguity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1819, __pyx_L3_error)
    } else {

      /* "cupy/core/core.pyx":1819
 *     cpdef _set_shape_and_strides(self, vector.vector[Py_ssize_t] & shape,
 *                                  vector.vector[Py_ssize_t] & strides,
 *                                  bint update_c_contiguity=True):             # <<<<<<<<<<<<<<
 *         if shape.size() != strides.size():
 *             raise ValueError('len(shape) != len(strides)')
 */
      __pyx_v_update_c_contiguity = ((int)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_set_shape_and_strides", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1817, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray._set_shape_and_strides", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_194_set_shape_and_strides(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_shape, __pyx_v_strides, __pyx_v_update_c_contiguity);

  /* "cupy/core/core.pyx":1817
 *         self._update_f_contiguity()
 * 
 *     cpdef _set_shape_and_strides(self, vector.vector[Py_ssize_t] & shape,             # <<<<<<<<<<<<<<
 *                                  vector.vector[Py_ssize_t] & strides,
 *                                  bint update_c_contiguity=True):
 */

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_194_set_shape_and_strides(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  __pyx_v_shape, std::vector<Py_ssize_t>  __pyx_v_strides, int __pyx_v_update_c_contiguity) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides __pyx_t_2;
  __Pyx_RefNannySetupContext("_set_shape_and_strides", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.update_c_contiguity = __pyx_v_update_c_contiguity;
  __pyx_t_1 = __pyx_vtabptr_4cupy_4core_4core_ndarray->_set_shape_and_strides(__pyx_v_self, __pyx_v_shape, __pyx_v_strides, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1817, __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":1830
 *             self._update_f_contiguity()
 * 
 *     cdef function.CPointer get_pointer(self):             # <<<<<<<<<<<<<<
 *         return CArray(self)
 * 
 */

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

  /* "cupy/core/core.pyx":1831
 * 
 *     cdef function.CPointer get_pointer(self):
 *         return CArray(self)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1831, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_CArray), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1831, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = ((struct __pyx_obj_4cupy_4cuda_8function_CPointer *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1830
 *             self._update_f_contiguity()
 * 
 *     cdef function.CPointer get_pointer(self):             # <<<<<<<<<<<<<<
 *         return CArray(self)
 * 
 */

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

/* "cupy/core/core.pxd":9
 * cdef class ndarray:
 *     cdef:
 *         readonly Py_ssize_t size             # <<<<<<<<<<<<<<
 *         public vector.vector[Py_ssize_t] _shape
 *         public vector.vector[Py_ssize_t] _strides
 */

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4size___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 9, __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":10
 *     cdef:
 *         readonly Py_ssize_t size
 *         public vector.vector[Py_ssize_t] _shape             # <<<<<<<<<<<<<<
 *         public vector.vector[Py_ssize_t] _strides
 *         readonly bint _c_contiguous
 */

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_6_shape___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 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._shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_6_shape_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_6_shape_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_6_shape_2__set__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4cupy_4core_4core_7ndarray_6_shape_2__set__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  std::vector<Py_ssize_t>  __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_value); if (unlikely(PyErr_Occurred())) __PYX_ERR(3, 10, __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":11
 *         readonly Py_ssize_t size
 *         public vector.vector[Py_ssize_t] _shape
 *         public vector.vector[Py_ssize_t] _strides             # <<<<<<<<<<<<<<
 *         readonly bint _c_contiguous
 *         readonly bint _f_contiguous
 */

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_8_strides___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_strides); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 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._strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_8_strides_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_8_strides_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_8_strides_2__set__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4cupy_4core_4core_7ndarray_8_strides_2__set__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  std::vector<Py_ssize_t>  __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_value); if (unlikely(PyErr_Occurred())) __PYX_ERR(3, 11, __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":12
 *         public vector.vector[Py_ssize_t] _shape
 *         public vector.vector[Py_ssize_t] _strides
 *         readonly bint _c_contiguous             # <<<<<<<<<<<<<<
 *         readonly bint _f_contiguous
 *         readonly object dtype
 */

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_13_c_contiguous___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_c_contiguous); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 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._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":13
 *         public vector.vector[Py_ssize_t] _strides
 *         readonly bint _c_contiguous
 *         readonly bint _f_contiguous             # <<<<<<<<<<<<<<
 *         readonly object dtype
 *         readonly memory.MemoryPointer data
 */

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_13_f_contiguous___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_f_contiguous); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 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._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":14
 *         readonly bint _c_contiguous
 *         readonly bint _f_contiguous
 *         readonly object dtype             # <<<<<<<<<<<<<<
 *         readonly memory.MemoryPointer data
 *         readonly ndarray base
 */

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_5dtype___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->dtype);
  __pyx_r = __pyx_v_self->dtype;
  goto __pyx_L0;

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

/* "cupy/core/core.pxd":15
 *         readonly bint _f_contiguous
 *         readonly object dtype
 *         readonly memory.MemoryPointer data             # <<<<<<<<<<<<<<
 *         readonly ndarray base
 * 
 */

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4data___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->data));
  __pyx_r = ((PyObject *)__pyx_v_self->data);
  goto __pyx_L0;

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

/* "cupy/core/core.pxd":16
 *         readonly object dtype
 *         readonly memory.MemoryPointer data
 *         readonly ndarray base             # <<<<<<<<<<<<<<
 * 
 *     cpdef tolist(self)
 */

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4base___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->base));
  __pyx_r = ((PyObject *)__pyx_v_self->base);
  goto __pyx_L0;

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

/* "cupy/core/core.pyx":1837
 * 
 * 
 * cpdef vector.vector[Py_ssize_t] _get_strides_for_nocopy_reshape(             # <<<<<<<<<<<<<<
 *         ndarray a, vector.vector[Py_ssize_t] & newshape) except *:
 *     cdef vector.vector[Py_ssize_t] newstrides
 */

static PyObject *__pyx_pw_4cupy_4core_4core_1_get_strides_for_nocopy_reshape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static std::vector<Py_ssize_t>  __pyx_f_4cupy_4core_4core__get_strides_for_nocopy_reshape(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, std::vector<Py_ssize_t>  &__pyx_v_newshape, CYTHON_UNUSED int __pyx_skip_dispatch) {
  std::vector<Py_ssize_t>  __pyx_v_newstrides;
  Py_ssize_t __pyx_v_size;
  Py_ssize_t __pyx_v_itemsize;
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_dim;
  Py_ssize_t __pyx_v_last_stride;
  std::vector<Py_ssize_t>  __pyx_v_shape;
  std::vector<Py_ssize_t>  __pyx_v_strides;
  CYTHON_UNUSED Py_ssize_t __pyx_v_sh;
  CYTHON_UNUSED Py_ssize_t __pyx_v_st;
  std::vector<Py_ssize_t>  __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  std::vector<Py_ssize_t> ::iterator __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("_get_strides_for_nocopy_reshape", 0);

  /* "cupy/core/core.pyx":1841
 *     cdef vector.vector[Py_ssize_t] newstrides
 *     cdef Py_ssize_t size, itemsize, ndim, dim, last_stride
 *     size = a.size             # <<<<<<<<<<<<<<
 *     if size != internal.prod_ssize_t(newshape):
 *         return newstrides
 */
  __pyx_t_1 = __pyx_v_a->size;
  __pyx_v_size = __pyx_t_1;

  /* "cupy/core/core.pyx":1842
 *     cdef Py_ssize_t size, itemsize, ndim, dim, last_stride
 *     size = a.size
 *     if size != internal.prod_ssize_t(newshape):             # <<<<<<<<<<<<<<
 *         return newstrides
 * 
 */
  __pyx_t_2 = ((__pyx_v_size != __pyx_f_4cupy_4core_8internal_prod_ssize_t(__pyx_v_newshape, 0, NULL)) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1843
 *     size = a.size
 *     if size != internal.prod_ssize_t(newshape):
 *         return newstrides             # <<<<<<<<<<<<<<
 * 
 *     itemsize = a.itemsize
 */
    __pyx_r = __pyx_v_newstrides;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1842
 *     cdef Py_ssize_t size, itemsize, ndim, dim, last_stride
 *     size = a.size
 *     if size != internal.prod_ssize_t(newshape):             # <<<<<<<<<<<<<<
 *         return newstrides
 * 
 */
  }

  /* "cupy/core/core.pyx":1845
 *         return newstrides
 * 
 *     itemsize = a.itemsize             # <<<<<<<<<<<<<<
 *     if size == 1:
 *         newstrides.assign(<Py_ssize_t>newshape.size(), itemsize)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1845, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_itemsize = __pyx_t_1;

  /* "cupy/core/core.pyx":1846
 * 
 *     itemsize = a.itemsize
 *     if size == 1:             # <<<<<<<<<<<<<<
 *         newstrides.assign(<Py_ssize_t>newshape.size(), itemsize)
 *         return newstrides
 */
  __pyx_t_2 = ((__pyx_v_size == 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1847
 *     itemsize = a.itemsize
 *     if size == 1:
 *         newstrides.assign(<Py_ssize_t>newshape.size(), itemsize)             # <<<<<<<<<<<<<<
 *         return newstrides
 * 
 */
    try {
      __pyx_v_newstrides.assign(((Py_ssize_t)__pyx_v_newshape.size()), __pyx_v_itemsize);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 1847, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":1848
 *     if size == 1:
 *         newstrides.assign(<Py_ssize_t>newshape.size(), itemsize)
 *         return newstrides             # <<<<<<<<<<<<<<
 * 
 *     cdef vector.vector[Py_ssize_t] shape, strides
 */
    __pyx_r = __pyx_v_newstrides;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1846
 * 
 *     itemsize = a.itemsize
 *     if size == 1:             # <<<<<<<<<<<<<<
 *         newstrides.assign(<Py_ssize_t>newshape.size(), itemsize)
 *         return newstrides
 */
  }

  /* "cupy/core/core.pyx":1851
 * 
 *     cdef vector.vector[Py_ssize_t] shape, strides
 *     internal.get_reduced_dims(a._shape, a._strides, itemsize, shape, strides)             # <<<<<<<<<<<<<<
 * 
 *     ndim = shape.size()
 */
  __pyx_f_4cupy_4core_8internal_get_reduced_dims(__pyx_v_a->_shape, __pyx_v_a->_strides, __pyx_v_itemsize, __pyx_v_shape, __pyx_v_strides);

  /* "cupy/core/core.pyx":1853
 *     internal.get_reduced_dims(a._shape, a._strides, itemsize, shape, strides)
 * 
 *     ndim = shape.size()             # <<<<<<<<<<<<<<
 *     dim = 0
 *     sh = shape[0]
 */
  __pyx_v_ndim = __pyx_v_shape.size();

  /* "cupy/core/core.pyx":1854
 * 
 *     ndim = shape.size()
 *     dim = 0             # <<<<<<<<<<<<<<
 *     sh = shape[0]
 *     st = strides[0]
 */
  __pyx_v_dim = 0;

  /* "cupy/core/core.pyx":1855
 *     ndim = shape.size()
 *     dim = 0
 *     sh = shape[0]             # <<<<<<<<<<<<<<
 *     st = strides[0]
 *     last_stride = shape[0] * strides[0]
 */
  __pyx_v_sh = (__pyx_v_shape[0]);

  /* "cupy/core/core.pyx":1856
 *     dim = 0
 *     sh = shape[0]
 *     st = strides[0]             # <<<<<<<<<<<<<<
 *     last_stride = shape[0] * strides[0]
 *     for size in newshape:
 */
  __pyx_v_st = (__pyx_v_strides[0]);

  /* "cupy/core/core.pyx":1857
 *     sh = shape[0]
 *     st = strides[0]
 *     last_stride = shape[0] * strides[0]             # <<<<<<<<<<<<<<
 *     for size in newshape:
 *         if size <= 1:
 */
  __pyx_v_last_stride = ((__pyx_v_shape[0]) * (__pyx_v_strides[0]));

  /* "cupy/core/core.pyx":1858
 *     st = strides[0]
 *     last_stride = shape[0] * strides[0]
 *     for size in newshape:             # <<<<<<<<<<<<<<
 *         if size <= 1:
 *             newstrides.push_back(last_stride)
 */
  __pyx_t_4 = __pyx_v_newshape.begin();
  for (;;) {
    if (!(__pyx_t_4 != __pyx_v_newshape.end())) break;
    __pyx_t_1 = *__pyx_t_4;
    ++__pyx_t_4;
    __pyx_v_size = __pyx_t_1;

    /* "cupy/core/core.pyx":1859
 *     last_stride = shape[0] * strides[0]
 *     for size in newshape:
 *         if size <= 1:             # <<<<<<<<<<<<<<
 *             newstrides.push_back(last_stride)
 *             continue
 */
    __pyx_t_2 = ((__pyx_v_size <= 1) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1860
 *     for size in newshape:
 *         if size <= 1:
 *             newstrides.push_back(last_stride)             # <<<<<<<<<<<<<<
 *             continue
 *         if dim >= ndim or shape[dim] % size != 0:
 */
      try {
        __pyx_v_newstrides.push_back(__pyx_v_last_stride);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 1860, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":1861
 *         if size <= 1:
 *             newstrides.push_back(last_stride)
 *             continue             # <<<<<<<<<<<<<<
 *         if dim >= ndim or shape[dim] % size != 0:
 *             newstrides.clear()
 */
      goto __pyx_L5_continue;

      /* "cupy/core/core.pyx":1859
 *     last_stride = shape[0] * strides[0]
 *     for size in newshape:
 *         if size <= 1:             # <<<<<<<<<<<<<<
 *             newstrides.push_back(last_stride)
 *             continue
 */
    }

    /* "cupy/core/core.pyx":1862
 *             newstrides.push_back(last_stride)
 *             continue
 *         if dim >= ndim or shape[dim] % size != 0:             # <<<<<<<<<<<<<<
 *             newstrides.clear()
 *             break
 */
    __pyx_t_5 = ((__pyx_v_dim >= __pyx_v_ndim) != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_2 = __pyx_t_5;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_1 = (__pyx_v_shape[__pyx_v_dim]);
    if (unlikely(__pyx_v_size == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(0, 1862, __pyx_L1_error)
    }
    __pyx_t_5 = ((__Pyx_mod_Py_ssize_t(__pyx_t_1, __pyx_v_size) != 0) != 0);
    __pyx_t_2 = __pyx_t_5;
    __pyx_L9_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1863
 *             continue
 *         if dim >= ndim or shape[dim] % size != 0:
 *             newstrides.clear()             # <<<<<<<<<<<<<<
 *             break
 *         shape[dim] //= size
 */
      __pyx_v_newstrides.clear();

      /* "cupy/core/core.pyx":1864
 *         if dim >= ndim or shape[dim] % size != 0:
 *             newstrides.clear()
 *             break             # <<<<<<<<<<<<<<
 *         shape[dim] //= size
 *         last_stride = shape[dim] * strides[dim]
 */
      goto __pyx_L6_break;

      /* "cupy/core/core.pyx":1862
 *             newstrides.push_back(last_stride)
 *             continue
 *         if dim >= ndim or shape[dim] % size != 0:             # <<<<<<<<<<<<<<
 *             newstrides.clear()
 *             break
 */
    }

    /* "cupy/core/core.pyx":1865
 *             newstrides.clear()
 *             break
 *         shape[dim] //= size             # <<<<<<<<<<<<<<
 *         last_stride = shape[dim] * strides[dim]
 *         newstrides.push_back(last_stride)
 */
    __pyx_t_1 = __pyx_v_dim;
    __pyx_t_6 = (__pyx_v_shape[__pyx_t_1]);
    if (unlikely(__pyx_v_size == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(0, 1865, __pyx_L1_error)
    }
    else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_size == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_6))) {
      PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
      __PYX_ERR(0, 1865, __pyx_L1_error)
    }
    (__pyx_v_shape[__pyx_t_1]) = __Pyx_div_Py_ssize_t(__pyx_t_6, __pyx_v_size);

    /* "cupy/core/core.pyx":1866
 *             break
 *         shape[dim] //= size
 *         last_stride = shape[dim] * strides[dim]             # <<<<<<<<<<<<<<
 *         newstrides.push_back(last_stride)
 *         if shape[dim] == 1:
 */
    __pyx_v_last_stride = ((__pyx_v_shape[__pyx_v_dim]) * (__pyx_v_strides[__pyx_v_dim]));

    /* "cupy/core/core.pyx":1867
 *         shape[dim] //= size
 *         last_stride = shape[dim] * strides[dim]
 *         newstrides.push_back(last_stride)             # <<<<<<<<<<<<<<
 *         if shape[dim] == 1:
 *             dim += 1
 */
    try {
      __pyx_v_newstrides.push_back(__pyx_v_last_stride);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 1867, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":1868
 *         last_stride = shape[dim] * strides[dim]
 *         newstrides.push_back(last_stride)
 *         if shape[dim] == 1:             # <<<<<<<<<<<<<<
 *             dim += 1
 *     return newstrides
 */
    __pyx_t_2 = (((__pyx_v_shape[__pyx_v_dim]) == 1) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1869
 *         newstrides.push_back(last_stride)
 *         if shape[dim] == 1:
 *             dim += 1             # <<<<<<<<<<<<<<
 *     return newstrides
 * 
 */
      __pyx_v_dim = (__pyx_v_dim + 1);

      /* "cupy/core/core.pyx":1868
 *         last_stride = shape[dim] * strides[dim]
 *         newstrides.push_back(last_stride)
 *         if shape[dim] == 1:             # <<<<<<<<<<<<<<
 *             dim += 1
 *     return newstrides
 */
    }

    /* "cupy/core/core.pyx":1858
 *     st = strides[0]
 *     last_stride = shape[0] * strides[0]
 *     for size in newshape:             # <<<<<<<<<<<<<<
 *         if size <= 1:
 *             newstrides.push_back(last_stride)
 */
    __pyx_L5_continue:;
  }
  __pyx_L6_break:;

  /* "cupy/core/core.pyx":1870
 *         if shape[dim] == 1:
 *             dim += 1
 *     return newstrides             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_newstrides;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1837
 * 
 * 
 * cpdef vector.vector[Py_ssize_t] _get_strides_for_nocopy_reshape(             # <<<<<<<<<<<<<<
 *         ndarray a, vector.vector[Py_ssize_t] & newshape) except *:
 *     cdef vector.vector[Py_ssize_t] newstrides
 */

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_1_get_strides_for_nocopy_reshape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core__get_strides_for_nocopy_reshape[] = "_get_strides_for_nocopy_reshape(ndarray a, vector[Py_ssize_t] newshape) -> vector[Py_ssize_t]";
static PyObject *__pyx_pw_4cupy_4core_4core_1_get_strides_for_nocopy_reshape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  std::vector<Py_ssize_t>  __pyx_v_newshape;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_strides_for_nocopy_reshape (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_newshape,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_newshape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_strides_for_nocopy_reshape", 1, 2, 2, 1); __PYX_ERR(0, 1837, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_strides_for_nocopy_reshape") < 0)) __PYX_ERR(0, 1837, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_newshape = __pyx_convert_vector_from_py_Py_ssize_t(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1838, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_strides_for_nocopy_reshape", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1837, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_strides_for_nocopy_reshape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 1838, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core__get_strides_for_nocopy_reshape(__pyx_self, __pyx_v_a, __pyx_v_newshape);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core__get_strides_for_nocopy_reshape(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, std::vector<Py_ssize_t>  __pyx_v_newshape) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  std::vector<Py_ssize_t>  __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("_get_strides_for_nocopy_reshape", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_strides_for_nocopy_reshape(__pyx_v_a, __pyx_v_newshape, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1837, __pyx_L1_error)
  __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1837, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

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

/* "cupy/core/carray.pxi":22
 *         _CArray val
 * 
 *     def __init__(self, ndarray arr):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i
 *         cdef int ndim = arr._shape.size()
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_6CArray_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_4core_4core_6CArray_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_arr)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(2, 22, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_arr = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 22, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.CArray.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arr), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "arr", 0))) __PYX_ERR(2, 22, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_6CArray___init__(((struct __pyx_obj_4cupy_4core_4core_CArray *)__pyx_v_self), __pyx_v_arr);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_6CArray___init__(struct __pyx_obj_4cupy_4core_4core_CArray *__pyx_v_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr) {
  Py_ssize_t __pyx_v_i;
  int __pyx_v_ndim;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/carray.pxi":24
 *     def __init__(self, ndarray arr):
 *         cdef Py_ssize_t i
 *         cdef int ndim = arr._shape.size()             # <<<<<<<<<<<<<<
 *         self.val.data = <void*>arr.data.ptr
 *         self.val.size = arr.size
 */
  __pyx_v_ndim = __pyx_v_arr->_shape.size();

  /* "cupy/core/carray.pxi":25
 *         cdef Py_ssize_t i
 *         cdef int ndim = arr._shape.size()
 *         self.val.data = <void*>arr.data.ptr             # <<<<<<<<<<<<<<
 *         self.val.size = arr.size
 *         for i in range(ndim):
 */
  __pyx_v_self->val.data = ((void *)__pyx_v_arr->data->ptr);

  /* "cupy/core/carray.pxi":26
 *         cdef int ndim = arr._shape.size()
 *         self.val.data = <void*>arr.data.ptr
 *         self.val.size = arr.size             # <<<<<<<<<<<<<<
 *         for i in range(ndim):
 *             self.val.shape_and_strides[i] = arr._shape[i]
 */
  __pyx_t_1 = __pyx_v_arr->size;
  __pyx_v_self->val.size = __pyx_t_1;

  /* "cupy/core/carray.pxi":27
 *         self.val.data = <void*>arr.data.ptr
 *         self.val.size = arr.size
 *         for i in range(ndim):             # <<<<<<<<<<<<<<
 *             self.val.shape_and_strides[i] = arr._shape[i]
 *             self.val.shape_and_strides[i + ndim] = arr._strides[i]
 */
  __pyx_t_2 = __pyx_v_ndim;
  for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_2; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "cupy/core/carray.pxi":28
 *         self.val.size = arr.size
 *         for i in range(ndim):
 *             self.val.shape_and_strides[i] = arr._shape[i]             # <<<<<<<<<<<<<<
 *             self.val.shape_and_strides[i + ndim] = arr._strides[i]
 *         self.ptr = <void*>&self.val
 */
    (__pyx_v_self->val.shape_and_strides[__pyx_v_i]) = (__pyx_v_arr->_shape[__pyx_v_i]);

    /* "cupy/core/carray.pxi":29
 *         for i in range(ndim):
 *             self.val.shape_and_strides[i] = arr._shape[i]
 *             self.val.shape_and_strides[i + ndim] = arr._strides[i]             # <<<<<<<<<<<<<<
 *         self.ptr = <void*>&self.val
 * 
 */
    (__pyx_v_self->val.shape_and_strides[(__pyx_v_i + __pyx_v_ndim)]) = (__pyx_v_arr->_strides[__pyx_v_i]);
  }

  /* "cupy/core/carray.pxi":30
 *             self.val.shape_and_strides[i] = arr._shape[i]
 *             self.val.shape_and_strides[i + ndim] = arr._strides[i]
 *         self.ptr = <void*>&self.val             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_self->__pyx_base.ptr = ((void *)(&__pyx_v_self->val));

  /* "cupy/core/carray.pxi":22
 *         _CArray val
 * 
 *     def __init__(self, ndarray arr):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i
 *         cdef int ndim = arr._shape.size()
 */

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

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_6CArray_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_6CArray_2__reduce_cython__[] = "CArray.__reduce_cython__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_6CArray_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_6CArray_2__reduce_cython__(((struct __pyx_obj_4cupy_4core_4core_CArray *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_6CArray_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4cupy_4core_4core_CArray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__58, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(4, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

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

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_6CArray_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4cupy_4core_4core_6CArray_4__setstate_cython__[] = "CArray.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4cupy_4core_4core_6CArray_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_6CArray_4__setstate_cython__(((struct __pyx_obj_4cupy_4core_4core_CArray *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4cupy_4core_4core_6CArray_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4cupy_4core_4core_CArray *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(4, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 */

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

/* "cupy/core/carray.pxi":42
 *         _CIndexer val
 * 
 *     def __init__(self, Py_ssize_t size, tuple shape):             # <<<<<<<<<<<<<<
 *         self.val.size = size
 *         cdef Py_ssize_t i
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_8CIndexer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_4core_4core_8CIndexer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  Py_ssize_t __pyx_v_size;
  PyObject *__pyx_v_shape = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_size,&__pyx_n_s_shape,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_size)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(2, 42, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(2, 42, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_size = __Pyx_PyIndex_AsSsize_t(values[0]); if (unlikely((__pyx_v_size == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 42, __pyx_L3_error)
    __pyx_v_shape = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 42, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.CIndexer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(2, 42, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_8CIndexer___init__(((struct __pyx_obj_4cupy_4core_4core_CIndexer *)__pyx_v_self), __pyx_v_size, __pyx_v_shape);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_8CIndexer___init__(struct __pyx_obj_4cupy_4core_4core_CIndexer *__pyx_v_self, Py_ssize_t __pyx_v_size, PyObject *__pyx_v_shape) {
  Py_ssize_t __pyx_v_i;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/carray.pxi":43
 * 
 *     def __init__(self, Py_ssize_t size, tuple shape):
 *         self.val.size = size             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i
 *         for i in range(len(shape)):
 */
  __pyx_v_self->val.size = __pyx_v_size;

  /* "cupy/core/carray.pxi":45
 *         self.val.size = size
 *         cdef Py_ssize_t i
 *         for i in range(len(shape)):             # <<<<<<<<<<<<<<
 *             self.val.shape_and_index[i] = shape[i]
 *         self.ptr = <void*>&self.val
 */
  if (unlikely(__pyx_v_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 45, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(2, 45, __pyx_L1_error)
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "cupy/core/carray.pxi":46
 *         cdef Py_ssize_t i
 *         for i in range(len(shape)):
 *             self.val.shape_and_index[i] = shape[i]             # <<<<<<<<<<<<<<
 *         self.ptr = <void*>&self.val
 * 
 */
    if (unlikely(__pyx_v_shape == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 46, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 46, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 46, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    (__pyx_v_self->val.shape_and_index[__pyx_v_i]) = __pyx_t_4;
  }

  /* "cupy/core/carray.pxi":47
 *         for i in range(len(shape)):
 *             self.val.shape_and_index[i] = shape[i]
 *         self.ptr = <void*>&self.val             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_self->__pyx_base.ptr = ((void *)(&__pyx_v_self->val));

  /* "cupy/core/carray.pxi":42
 *         _CIndexer val
 * 
 *     def __init__(self, Py_ssize_t size, tuple shape):             # <<<<<<<<<<<<<<
 *         self.val.size = size
 *         cdef Py_ssize_t i
 */

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

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_8CIndexer_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_8CIndexer_2__reduce_cython__[] = "CIndexer.__reduce_cython__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_8CIndexer_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_8CIndexer_2__reduce_cython__(((struct __pyx_obj_4cupy_4core_4core_CIndexer *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_8CIndexer_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4cupy_4core_4core_CIndexer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__60, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(4, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

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

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_8CIndexer_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4cupy_4core_4core_8CIndexer_4__setstate_cython__[] = "CIndexer.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4cupy_4core_4core_8CIndexer_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_8CIndexer_4__setstate_cython__(((struct __pyx_obj_4cupy_4core_4core_CIndexer *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4cupy_4core_4core_8CIndexer_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4cupy_4core_4core_CIndexer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__61, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(4, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */

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

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

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7Indexer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7Indexer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_shape = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(2, 51, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_shape = ((PyObject*)values[0]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 51, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.Indexer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(2, 51, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_7Indexer___init__(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v_self), __pyx_v_shape);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_7Indexer___init__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self, PyObject *__pyx_v_shape) {
  Py_ssize_t __pyx_v_size;
  PyObject *__pyx_v_s = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/carray.pxi":52
 * cdef class Indexer:
 *     def __init__(self, tuple shape):
 *         cdef Py_ssize_t size = 1             # <<<<<<<<<<<<<<
 *         for s in shape:
 *             size *= s
 */
  __pyx_v_size = 1;

  /* "cupy/core/carray.pxi":53
 *     def __init__(self, tuple shape):
 *         cdef Py_ssize_t size = 1
 *         for s in shape:             # <<<<<<<<<<<<<<
 *             size *= s
 *         self.shape = shape
 */
  if (unlikely(__pyx_v_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(2, 53, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(2, 53, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 53, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/carray.pxi":54
 *         cdef Py_ssize_t size = 1
 *         for s in shape:
 *             size *= s             # <<<<<<<<<<<<<<
 *         self.shape = shape
 *         self.size = size
 */
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 54, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_InPlaceMultiply(__pyx_t_3, __pyx_v_s); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 54, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 54, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_size = __pyx_t_5;

    /* "cupy/core/carray.pxi":53
 *     def __init__(self, tuple shape):
 *         cdef Py_ssize_t size = 1
 *         for s in shape:             # <<<<<<<<<<<<<<
 *             size *= s
 *         self.shape = shape
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/carray.pxi":55
 *         for s in shape:
 *             size *= s
 *         self.shape = shape             # <<<<<<<<<<<<<<
 *         self.size = size
 * 
 */
  __Pyx_INCREF(__pyx_v_shape);
  __Pyx_GIVEREF(__pyx_v_shape);
  __Pyx_GOTREF(__pyx_v_self->shape);
  __Pyx_DECREF(__pyx_v_self->shape);
  __pyx_v_self->shape = __pyx_v_shape;

  /* "cupy/core/carray.pxi":56
 *             size *= s
 *         self.shape = shape
 *         self.size = size             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_v_self->size = __pyx_v_size;

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

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

/* "cupy/core/carray.pxi":59
 * 
 *     @property
 *     def ndim(self):             # <<<<<<<<<<<<<<
 *         return len(self.shape)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_4ndim_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_4ndim_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7Indexer_4ndim___get__(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v_self));

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

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

  /* "cupy/core/carray.pxi":60
 *     @property
 *     def ndim(self):
 *         return len(self.shape)             # <<<<<<<<<<<<<<
 * 
 *     cdef CPointer get_pointer(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_v_self->shape;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 60, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(2, 60, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/carray.pxi":59
 * 
 *     @property
 *     def ndim(self):             # <<<<<<<<<<<<<<
 *         return len(self.shape)
 * 
 */

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

/* "cupy/core/carray.pxi":62
 *         return len(self.shape)
 * 
 *     cdef CPointer get_pointer(self):             # <<<<<<<<<<<<<<
 *         return CIndexer(self.size, self.shape)
 * 
 */

static struct __pyx_obj_4cupy_4cuda_8function_CPointer *__pyx_f_4cupy_4core_4core_7Indexer_get_pointer(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self) {
  struct __pyx_obj_4cupy_4cuda_8function_CPointer *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("get_pointer", 0);

  /* "cupy/core/carray.pxi":63
 * 
 *     cdef CPointer get_pointer(self):
 *         return CIndexer(self.size, self.shape)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 63, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 63, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->shape);
  __Pyx_GIVEREF(__pyx_v_self->shape);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->shape);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_CIndexer), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 63, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = ((struct __pyx_obj_4cupy_4cuda_8function_CPointer *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/carray.pxi":62
 *         return len(self.shape)
 * 
 *     cdef CPointer get_pointer(self):             # <<<<<<<<<<<<<<
 *         return CIndexer(self.size, self.shape)
 * 
 */

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

/* "cupy/core/core.pxd":71
 * cdef class Indexer:
 *     cdef:
 *         readonly Py_ssize_t size             # <<<<<<<<<<<<<<
 *         readonly tuple shape
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_4size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_4size_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7Indexer_4size___get__(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7Indexer_4size___get__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/core.pxd":72
 *     cdef:
 *         readonly Py_ssize_t size
 *         readonly tuple shape             # <<<<<<<<<<<<<<
 * 
 *     cdef CPointer get_pointer(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_5shape_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_5shape_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7Indexer_5shape___get__(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7Indexer_5shape___get__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->shape);
  __pyx_r = __pyx_v_self->shape;
  goto __pyx_L0;

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

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.shape, self.size)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7Indexer_2__reduce_cython__[] = "Indexer.__reduce_cython__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7Indexer_2__reduce_cython__(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7Indexer_2__reduce_cython__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.shape, self.size)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->shape);
  __Pyx_GIVEREF(__pyx_v_self->shape);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->shape);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.shape, self.size)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v__dict = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "(tree fragment)":5
 *     state = (self.shape, self.size)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_3 = (__pyx_v__dict != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__dict);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.shape is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.shape, self.size)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.shape is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, None), state
 */
  /*else*/ {
    __pyx_t_4 = (__pyx_v_self->shape != ((PyObject*)Py_None));
    __pyx_v_use_setstate = __pyx_t_4;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.shape is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, None), state
 *     else:
 */
  __pyx_t_4 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":11
 *         use_setstate = self.shape is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_Indexer); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_114586425);
    __Pyx_GIVEREF(__pyx_int_114586425);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_114586425);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.shape is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, None), state
 *     else:
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Indexer__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_Indexer); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_114586425);
    __Pyx_GIVEREF(__pyx_int_114586425);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_114586425);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_5 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.shape, self.size)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.Indexer.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Indexer__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7Indexer_4__setstate_cython__[] = "Indexer.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7Indexer_4__setstate_cython__(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7Indexer_4__setstate_cython__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Indexer__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(4, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core___pyx_unpickle_Indexer__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Indexer__set_state(self, __pyx_state)
 */

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

/* "cupy/core/carray.pxi":102
 * 
 * 
 * cpdef str _get_header_dir_path():             # <<<<<<<<<<<<<<
 *     global _header_path_cache
 *     if _header_path_cache is None:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_3_get_header_dir_path(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_header_dir_path(CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  __Pyx_RefNannySetupContext("_get_header_dir_path", 0);

  /* "cupy/core/carray.pxi":104
 * cpdef str _get_header_dir_path():
 *     global _header_path_cache
 *     if _header_path_cache is None:             # <<<<<<<<<<<<<<
 *         # Cython cannot use __file__ in global scope
 *         _header_path_cache = os.path.abspath(
 */
  __pyx_t_1 = (__pyx_v_4cupy_4core_4core__header_path_cache == ((PyObject*)Py_None));
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/carray.pxi":106
 *     if _header_path_cache is None:
 *         # Cython cannot use __file__ in global scope
 *         _header_path_cache = os.path.abspath(             # <<<<<<<<<<<<<<
 *             os.path.join(os.path.dirname(__file__), 'include'))
 *     return _header_path_cache
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 106, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_path); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 106, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_abspath); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 106, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/carray.pxi":107
 *         # Cython cannot use __file__ in global scope
 *         _header_path_cache = os.path.abspath(
 *             os.path.join(os.path.dirname(__file__), 'include'))             # <<<<<<<<<<<<<<
 *     return _header_path_cache
 * 
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_path); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_join); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_path); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dirname); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_file); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 107, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_7);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9};
        __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 107, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9};
        __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 107, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 107, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 107, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = NULL;
    __pyx_t_12 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_12 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_7, __pyx_n_s_include};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 107, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_7, __pyx_n_s_include};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 107, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 107, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_12, __pyx_t_7);
      __Pyx_INCREF(__pyx_n_s_include);
      __Pyx_GIVEREF(__pyx_n_s_include);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_12, __pyx_n_s_include);
      __pyx_t_7 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 107, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 106, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 106, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 106, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 106, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL;
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_5);
        __pyx_t_5 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 106, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/carray.pxi":106
 *     if _header_path_cache is None:
 *         # Cython cannot use __file__ in global scope
 *         _header_path_cache = os.path.abspath(             # <<<<<<<<<<<<<<
 *             os.path.join(os.path.dirname(__file__), 'include'))
 *     return _header_path_cache
 */
    if (!(likely(PyString_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(2, 106, __pyx_L1_error)
    __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__header_path_cache);
    __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__header_path_cache, ((PyObject*)__pyx_t_3));
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/carray.pxi":104
 * cpdef str _get_header_dir_path():
 *     global _header_path_cache
 *     if _header_path_cache is None:             # <<<<<<<<<<<<<<
 *         # Cython cannot use __file__ in global scope
 *         _header_path_cache = os.path.abspath(
 */
  }

  /* "cupy/core/carray.pxi":108
 *         _header_path_cache = os.path.abspath(
 *             os.path.join(os.path.dirname(__file__), 'include'))
 *     return _header_path_cache             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__header_path_cache);
  __pyx_r = __pyx_v_4cupy_4core_4core__header_path_cache;
  goto __pyx_L0;

  /* "cupy/core/carray.pxi":102
 * 
 * 
 * cpdef str _get_header_dir_path():             # <<<<<<<<<<<<<<
 *     global _header_path_cache
 *     if _header_path_cache is None:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core._get_header_dir_path", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_3_get_header_dir_path(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_2_get_header_dir_path[] = "_get_header_dir_path() -> str";
static PyObject *__pyx_pw_4cupy_4core_4core_3_get_header_dir_path(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_header_dir_path (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_2_get_header_dir_path(__pyx_self);

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

static PyObject *__pyx_pf_4cupy_4core_4core_2_get_header_dir_path(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_header_dir_path", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_header_dir_path(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 102, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/carray.pxi":111
 * 
 * 
 * cpdef str _get_header_source():             # <<<<<<<<<<<<<<
 *     global _header_source
 *     if _header_source is None:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_5_get_header_source(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_header_source(CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_source = NULL;
  PyObject *__pyx_v_base_path = NULL;
  PyObject *__pyx_v_file_path = NULL;
  PyObject *__pyx_v_header_path = NULL;
  PyObject *__pyx_v_header_file = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  __Pyx_RefNannySetupContext("_get_header_source", 0);

  /* "cupy/core/carray.pxi":113
 * cpdef str _get_header_source():
 *     global _header_source
 *     if _header_source is None:             # <<<<<<<<<<<<<<
 *         source = []
 *         base_path = _get_header_dir_path()
 */
  __pyx_t_1 = (__pyx_v_4cupy_4core_4core__header_source == ((PyObject*)Py_None));
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/carray.pxi":114
 *     global _header_source
 *     if _header_source is None:
 *         source = []             # <<<<<<<<<<<<<<
 *         base_path = _get_header_dir_path()
 *         for file_path in _cupy_header_list + _cupy_extra_header_list:
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 114, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_source = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/carray.pxi":115
 *     if _header_source is None:
 *         source = []
 *         base_path = _get_header_dir_path()             # <<<<<<<<<<<<<<
 *         for file_path in _cupy_header_list + _cupy_extra_header_list:
 *             header_path = os.path.join(base_path, file_path)
 */
    __pyx_t_3 = __pyx_f_4cupy_4core_4core__get_header_dir_path(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 115, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_base_path = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/carray.pxi":116
 *         source = []
 *         base_path = _get_header_dir_path()
 *         for file_path in _cupy_header_list + _cupy_extra_header_list:             # <<<<<<<<<<<<<<
 *             header_path = os.path.join(base_path, file_path)
 *             with open(header_path) as header_file:
 */
    __pyx_t_3 = PyNumber_Add(__pyx_v_4cupy_4core_4core__cupy_header_list, __pyx_v_4cupy_4core_4core__cupy_extra_header_list); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 116, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(2, 116, __pyx_L1_error)
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 116, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_file_path, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/carray.pxi":117
 *         base_path = _get_header_dir_path()
 *         for file_path in _cupy_header_list + _cupy_extra_header_list:
 *             header_path = os.path.join(base_path, file_path)             # <<<<<<<<<<<<<<
 *             with open(header_path) as header_file:
 *                 source.append(header_file.read())
 */
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 117, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_path); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 117, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_join); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 117, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_8 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_base_path, __pyx_v_file_path};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 117, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_base_path, __pyx_v_file_path};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 117, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 117, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (__pyx_t_7) {
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
        }
        __Pyx_INCREF(__pyx_v_base_path);
        __Pyx_GIVEREF(__pyx_v_base_path);
        PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_v_base_path);
        __Pyx_INCREF(__pyx_v_file_path);
        __Pyx_GIVEREF(__pyx_v_file_path);
        PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_file_path);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 117, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF_SET(__pyx_v_header_path, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/carray.pxi":118
 *         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 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 118, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_v_header_path);
        __Pyx_GIVEREF(__pyx_v_header_path);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_header_path);
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 118, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_n_s_exit); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 118, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_n_s_enter); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 118, __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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 118, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        } else {
          __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 118, __pyx_L6_error)
        }
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = __pyx_t_3;
        __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        /*try:*/ {
          {
            __Pyx_PyThreadState_declare
            __Pyx_PyThreadState_assign
            __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_13);
            /*try:*/ {
              __Pyx_XDECREF_SET(__pyx_v_header_file, __pyx_t_9);
              __pyx_t_9 = 0;

              /* "cupy/core/carray.pxi":119
 *             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_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_header_file, __pyx_n_s_read); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 119, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_3 = NULL;
              if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
                __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
                if (likely(__pyx_t_3)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
                  __Pyx_INCREF(__pyx_t_3);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_6, function);
                }
              }
              if (__pyx_t_3) {
                __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 119, __pyx_L12_error)
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              } else {
                __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 119, __pyx_L12_error)
              }
              __Pyx_GOTREF(__pyx_t_9);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_source, __pyx_t_9); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(2, 119, __pyx_L12_error)
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

              /* "cupy/core/carray.pxi":118
 *         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_PyThreadState_assign
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 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_6, &__pyx_t_3) < 0) __PYX_ERR(2, 118, __pyx_L14_except_error)
              __Pyx_GOTREF(__pyx_t_9);
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_7 = PyTuple_Pack(3, __pyx_t_9, __pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 118, __pyx_L14_except_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_7, NULL);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 118, __pyx_L14_except_error)
              __Pyx_GOTREF(__pyx_t_15);
              __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_15);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_t_2 < 0) __PYX_ERR(2, 118, __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_6);
                __Pyx_XGIVEREF(__pyx_t_3);
                __Pyx_ErrRestoreWithState(__pyx_t_9, __pyx_t_6, __pyx_t_3);
                __pyx_t_9 = 0; __pyx_t_6 = 0; __pyx_t_3 = 0; 
                __PYX_ERR(2, 118, __pyx_L14_except_error)
              }
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              goto __pyx_L13_exception_handled;
            }
            __pyx_L14_except_error:;
            __Pyx_PyThreadState_assign
            __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_PyThreadState_assign
            __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__62, NULL);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(2, 118, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            }
            goto __pyx_L11;
          }
          __pyx_L11:;
        }
        goto __pyx_L23;
        __pyx_L6_error:;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L1_error;
        __pyx_L23:;
      }

      /* "cupy/core/carray.pxi":116
 *         source = []
 *         base_path = _get_header_dir_path()
 *         for file_path in _cupy_header_list + _cupy_extra_header_list:             # <<<<<<<<<<<<<<
 *             header_path = os.path.join(base_path, file_path)
 *             with open(header_path) as header_file:
 */
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/carray.pxi":120
 *             with open(header_path) as header_file:
 *                 source.append(header_file.read())
 *         _header_source = '\n'.join(source)             # <<<<<<<<<<<<<<
 *     return _header_source
 * 
 */
    __pyx_t_4 = __Pyx_PyString_Join(__pyx_kp_s__63, __pyx_v_source); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 120, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (!(likely(PyString_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(2, 120, __pyx_L1_error)
    __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__header_source);
    __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__header_source, ((PyObject*)__pyx_t_4));
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/carray.pxi":113
 * cpdef str _get_header_source():
 *     global _header_source
 *     if _header_source is None:             # <<<<<<<<<<<<<<
 *         source = []
 *         base_path = _get_header_dir_path()
 */
  }

  /* "cupy/core/carray.pxi":121
 *                 source.append(header_file.read())
 *         _header_source = '\n'.join(source)
 *     return _header_source             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__header_source);
  __pyx_r = __pyx_v_4cupy_4core_4core__header_source;
  goto __pyx_L0;

  /* "cupy/core/carray.pxi":111
 * 
 * 
 * cpdef str _get_header_source():             # <<<<<<<<<<<<<<
 *     global _header_source
 *     if _header_source is None:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core._get_header_source", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_source);
  __Pyx_XDECREF(__pyx_v_base_path);
  __Pyx_XDECREF(__pyx_v_file_path);
  __Pyx_XDECREF(__pyx_v_header_path);
  __Pyx_XDECREF(__pyx_v_header_file);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_5_get_header_source(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_4_get_header_source[] = "_get_header_source() -> str";
static PyObject *__pyx_pw_4cupy_4core_4core_5_get_header_source(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_header_source (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_4_get_header_source(__pyx_self);

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

static PyObject *__pyx_pf_4cupy_4core_4core_4_get_header_source(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_header_source", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_header_source(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/carray.pxi":126
 * cdef str _cuda_path = None
 * 
 * cpdef str _get_cuda_path():             # <<<<<<<<<<<<<<
 *     global _cuda_path
 *     if _cuda_path is None:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7_get_cuda_path(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_cuda_path(CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_v_cmd = NULL;
  PyObject *__pyx_v_nvcc_path = NULL;
  PyObject *__pyx_v_nvcc_dir = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  __Pyx_RefNannySetupContext("_get_cuda_path", 0);

  /* "cupy/core/carray.pxi":128
 * cpdef str _get_cuda_path():
 *     global _cuda_path
 *     if _cuda_path is None:             # <<<<<<<<<<<<<<
 *         _cuda_path = os.getenv('CUDA_PATH', None)
 *         if _cuda_path is not None:
 */
  __pyx_t_1 = (__pyx_v_4cupy_4core_4core__cuda_path == ((PyObject*)Py_None));
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/carray.pxi":129
 *     global _cuda_path
 *     if _cuda_path is None:
 *         _cuda_path = os.getenv('CUDA_PATH', None)             # <<<<<<<<<<<<<<
 *         if _cuda_path is not None:
 *             return _cuda_path
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 129, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_getenv); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 129, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 129, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(PyString_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(2, 129, __pyx_L1_error)
    __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cuda_path);
    __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cuda_path, ((PyObject*)__pyx_t_3));
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/carray.pxi":130
 *     if _cuda_path is None:
 *         _cuda_path = os.getenv('CUDA_PATH', None)
 *         if _cuda_path is not None:             # <<<<<<<<<<<<<<
 *             return _cuda_path
 * 
 */
    __pyx_t_2 = (__pyx_v_4cupy_4core_4core__cuda_path != ((PyObject*)Py_None));
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/carray.pxi":131
 *         _cuda_path = os.getenv('CUDA_PATH', None)
 *         if _cuda_path is not None:
 *             return _cuda_path             # <<<<<<<<<<<<<<
 * 
 *         for p in os.getenv('PATH', '').split(os.pathsep):
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_4cupy_4core_4core__cuda_path);
      __pyx_r = __pyx_v_4cupy_4core_4core__cuda_path;
      goto __pyx_L0;

      /* "cupy/core/carray.pxi":130
 *     if _cuda_path is None:
 *         _cuda_path = os.getenv('CUDA_PATH', None)
 *         if _cuda_path is not None:             # <<<<<<<<<<<<<<
 *             return _cuda_path
 * 
 */
    }

    /* "cupy/core/carray.pxi":133
 *             return _cuda_path
 * 
 *         for p in os.getenv('PATH', '').split(os.pathsep):             # <<<<<<<<<<<<<<
 *             for cmd in ('nvcc', 'nvcc.exe'):
 *                 nvcc_path = os.path.join(p, cmd)
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_getenv); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__65, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_split); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_pathsep); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 133, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_6};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 133, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_6};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 133, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 133, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 133, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_5 = __pyx_t_3; __Pyx_INCREF(__pyx_t_5); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 133, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 133, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_5))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(2, 133, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 133, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(2, 133, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 133, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_9(__pyx_t_5);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(2, 133, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/carray.pxi":134
 * 
 *         for p in os.getenv('PATH', '').split(os.pathsep):
 *             for cmd in ('nvcc', 'nvcc.exe'):             # <<<<<<<<<<<<<<
 *                 nvcc_path = os.path.join(p, cmd)
 *                 if not os.path.exists(nvcc_path):
 */
      __pyx_t_3 = __pyx_tuple__66; __Pyx_INCREF(__pyx_t_3); __pyx_t_10 = 0;
      for (;;) {
        if (__pyx_t_10 >= 2) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_7); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(2, 134, __pyx_L1_error)
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 134, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
        __Pyx_XDECREF_SET(__pyx_v_cmd, __pyx_t_7);
        __pyx_t_7 = 0;

        /* "cupy/core/carray.pxi":135
 *         for p in os.getenv('PATH', '').split(os.pathsep):
 *             for cmd in ('nvcc', 'nvcc.exe'):
 *                 nvcc_path = os.path.join(p, cmd)             # <<<<<<<<<<<<<<
 *                 if not os.path.exists(nvcc_path):
 *                     continue
 */
        __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 135, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_path); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 135, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_join); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 135, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = NULL;
        __pyx_t_11 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
            __pyx_t_11 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_6)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_p, __pyx_v_cmd};
          __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 135, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_p, __pyx_v_cmd};
          __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 135, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else
        #endif
        {
          __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(2, 135, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_INCREF(__pyx_v_p);
          __Pyx_GIVEREF(__pyx_v_p);
          PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_v_p);
          __Pyx_INCREF(__pyx_v_cmd);
          __Pyx_GIVEREF(__pyx_v_cmd);
          PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_v_cmd);
          __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_12, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 135, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF_SET(__pyx_v_nvcc_path, __pyx_t_7);
        __pyx_t_7 = 0;

        /* "cupy/core/carray.pxi":136
 *             for cmd in ('nvcc', 'nvcc.exe'):
 *                 nvcc_path = os.path.join(p, cmd)
 *                 if not os.path.exists(nvcc_path):             # <<<<<<<<<<<<<<
 *                     continue
 *                 nvcc_dir = os.path.dirname(
 */
        __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 136, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_path); if (unlikely(!__pyx_t_12)) __PYX_ERR(2, 136, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_exists); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 136, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_12 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
          }
        }
        if (!__pyx_t_12) {
          __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_nvcc_path); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 136, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_nvcc_path};
            __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 136, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_GOTREF(__pyx_t_7);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_nvcc_path};
            __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 136, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_GOTREF(__pyx_t_7);
          } else
          #endif
          {
            __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 136, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_12); __pyx_t_12 = NULL;
            __Pyx_INCREF(__pyx_v_nvcc_path);
            __Pyx_GIVEREF(__pyx_v_nvcc_path);
            PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_nvcc_path);
            __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 136, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 136, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_2 = ((!__pyx_t_1) != 0);
        if (__pyx_t_2) {

          /* "cupy/core/carray.pxi":137
 *                 nvcc_path = os.path.join(p, cmd)
 *                 if not os.path.exists(nvcc_path):
 *                     continue             # <<<<<<<<<<<<<<
 *                 nvcc_dir = os.path.dirname(
 *                     os.path.abspath(nvcc_path))
 */
          goto __pyx_L7_continue;

          /* "cupy/core/carray.pxi":136
 *             for cmd in ('nvcc', 'nvcc.exe'):
 *                 nvcc_path = os.path.join(p, cmd)
 *                 if not os.path.exists(nvcc_path):             # <<<<<<<<<<<<<<
 *                     continue
 *                 nvcc_dir = os.path.dirname(
 */
        }

        /* "cupy/core/carray.pxi":138
 *                 if not os.path.exists(nvcc_path):
 *                     continue
 *                 nvcc_dir = os.path.dirname(             # <<<<<<<<<<<<<<
 *                     os.path.abspath(nvcc_path))
 *                 _cuda_path = os.path.normpath(
 */
        __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 138, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_path); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 138, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dirname); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 138, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "cupy/core/carray.pxi":139
 *                     continue
 *                 nvcc_dir = os.path.dirname(
 *                     os.path.abspath(nvcc_path))             # <<<<<<<<<<<<<<
 *                 _cuda_path = os.path.normpath(
 *                     os.path.join(nvcc_dir, '..'))
 */
        __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_12)) __PYX_ERR(2, 139, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_path); if (unlikely(!__pyx_t_13)) __PYX_ERR(2, 139, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_abspath); if (unlikely(!__pyx_t_12)) __PYX_ERR(2, 139, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_13 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
          if (likely(__pyx_t_13)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_12, function);
          }
        }
        if (!__pyx_t_13) {
          __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_nvcc_path); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 139, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_12)) {
            PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_v_nvcc_path};
            __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 139, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_GOTREF(__pyx_t_4);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
            PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_v_nvcc_path};
            __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 139, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_GOTREF(__pyx_t_4);
          } else
          #endif
          {
            __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 139, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
            __Pyx_INCREF(__pyx_v_nvcc_path);
            __Pyx_GIVEREF(__pyx_v_nvcc_path);
            PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_v_nvcc_path);
            __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_14, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 139, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_12 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
          }
        }
        if (!__pyx_t_12) {
          __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 138, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_4};
            __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 138, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_4};
            __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 138, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          } else
          #endif
          {
            __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 138, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); __pyx_t_12 = NULL;
            __Pyx_GIVEREF(__pyx_t_4);
            PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_4);
            __pyx_t_4 = 0;
            __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_14, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 138, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_v_nvcc_dir = __pyx_t_7;
        __pyx_t_7 = 0;

        /* "cupy/core/carray.pxi":140
 *                 nvcc_dir = os.path.dirname(
 *                     os.path.abspath(nvcc_path))
 *                 _cuda_path = os.path.normpath(             # <<<<<<<<<<<<<<
 *                     os.path.join(nvcc_dir, '..'))
 *                 return _cuda_path
 */
        __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 140, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_path); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 140, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_normpath); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 140, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

        /* "cupy/core/carray.pxi":141
 *                     os.path.abspath(nvcc_path))
 *                 _cuda_path = os.path.normpath(
 *                     os.path.join(nvcc_dir, '..'))             # <<<<<<<<<<<<<<
 *                 return _cuda_path
 * 
 */
        __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 141, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_path); if (unlikely(!__pyx_t_12)) __PYX_ERR(2, 141, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_join); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 141, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_12 = NULL;
        __pyx_t_11 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
            __pyx_t_11 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_nvcc_dir, __pyx_kp_s__67};
          __pyx_t_14 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 141, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_GOTREF(__pyx_t_14);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_nvcc_dir, __pyx_kp_s__67};
          __pyx_t_14 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 141, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_GOTREF(__pyx_t_14);
        } else
        #endif
        {
          __pyx_t_13 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_13)) __PYX_ERR(2, 141, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          if (__pyx_t_12) {
            __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __pyx_t_12 = NULL;
          }
          __Pyx_INCREF(__pyx_v_nvcc_dir);
          __Pyx_GIVEREF(__pyx_v_nvcc_dir);
          PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_11, __pyx_v_nvcc_dir);
          __Pyx_INCREF(__pyx_kp_s__67);
          __Pyx_GIVEREF(__pyx_kp_s__67);
          PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_11, __pyx_kp_s__67);
          __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_13, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 141, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
          }
        }
        if (!__pyx_t_4) {
          __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 140, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_14};
            __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 140, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_14};
            __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 140, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          } else
          #endif
          {
            __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(2, 140, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_4); __pyx_t_4 = NULL;
            __Pyx_GIVEREF(__pyx_t_14);
            PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_14);
            __pyx_t_14 = 0;
            __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_13, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 140, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "cupy/core/carray.pxi":140
 *                 nvcc_dir = os.path.dirname(
 *                     os.path.abspath(nvcc_path))
 *                 _cuda_path = os.path.normpath(             # <<<<<<<<<<<<<<
 *                     os.path.join(nvcc_dir, '..'))
 *                 return _cuda_path
 */
        if (!(likely(PyString_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_7)->tp_name), 0))) __PYX_ERR(2, 140, __pyx_L1_error)
        __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cuda_path);
        __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cuda_path, ((PyObject*)__pyx_t_7));
        __Pyx_GIVEREF(__pyx_t_7);
        __pyx_t_7 = 0;

        /* "cupy/core/carray.pxi":142
 *                 _cuda_path = os.path.normpath(
 *                     os.path.join(nvcc_dir, '..'))
 *                 return _cuda_path             # <<<<<<<<<<<<<<
 * 
 *         if os.path.exists('/usr/local/cuda'):
 */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_v_4cupy_4core_4core__cuda_path);
        __pyx_r = __pyx_v_4cupy_4core_4core__cuda_path;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L0;

        /* "cupy/core/carray.pxi":134
 * 
 *         for p in os.getenv('PATH', '').split(os.pathsep):
 *             for cmd in ('nvcc', 'nvcc.exe'):             # <<<<<<<<<<<<<<
 *                 nvcc_path = os.path.join(p, cmd)
 *                 if not os.path.exists(nvcc_path):
 */
        __pyx_L7_continue:;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/carray.pxi":133
 *             return _cuda_path
 * 
 *         for p in os.getenv('PATH', '').split(os.pathsep):             # <<<<<<<<<<<<<<
 *             for cmd in ('nvcc', 'nvcc.exe'):
 *                 nvcc_path = os.path.join(p, cmd)
 */
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/carray.pxi":144
 *                 return _cuda_path
 * 
 *         if os.path.exists('/usr/local/cuda'):             # <<<<<<<<<<<<<<
 *             _cuda_path = '/usr/local/cuda'
 * 
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 144, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 144, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_exists); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 144, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__68, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 144, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(2, 144, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/carray.pxi":145
 * 
 *         if os.path.exists('/usr/local/cuda'):
 *             _cuda_path = '/usr/local/cuda'             # <<<<<<<<<<<<<<
 * 
 *     return _cuda_path
 */
      __Pyx_INCREF(__pyx_kp_s_usr_local_cuda);
      __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cuda_path);
      __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cuda_path, __pyx_kp_s_usr_local_cuda);
      __Pyx_GIVEREF(__pyx_kp_s_usr_local_cuda);

      /* "cupy/core/carray.pxi":144
 *                 return _cuda_path
 * 
 *         if os.path.exists('/usr/local/cuda'):             # <<<<<<<<<<<<<<
 *             _cuda_path = '/usr/local/cuda'
 * 
 */
    }

    /* "cupy/core/carray.pxi":128
 * cpdef str _get_cuda_path():
 *     global _cuda_path
 *     if _cuda_path is None:             # <<<<<<<<<<<<<<
 *         _cuda_path = os.getenv('CUDA_PATH', None)
 *         if _cuda_path is not None:
 */
  }

  /* "cupy/core/carray.pxi":147
 *             _cuda_path = '/usr/local/cuda'
 * 
 *     return _cuda_path             # <<<<<<<<<<<<<<
 * 
 * cpdef function.Module compile_with_cache(
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__cuda_path);
  __pyx_r = __pyx_v_4cupy_4core_4core__cuda_path;
  goto __pyx_L0;

  /* "cupy/core/carray.pxi":126
 * cdef str _cuda_path = None
 * 
 * cpdef str _get_cuda_path():             # <<<<<<<<<<<<<<
 *     global _cuda_path
 *     if _cuda_path 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_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("cupy.core.core._get_cuda_path", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_cmd);
  __Pyx_XDECREF(__pyx_v_nvcc_path);
  __Pyx_XDECREF(__pyx_v_nvcc_dir);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7_get_cuda_path(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_6_get_cuda_path[] = "_get_cuda_path() -> str";
static PyObject *__pyx_pw_4cupy_4core_4core_7_get_cuda_path(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_cuda_path (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_6_get_cuda_path(__pyx_self);

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

static PyObject *__pyx_pf_4cupy_4core_4core_6_get_cuda_path(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_cuda_path", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_cuda_path(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/carray.pxi":149
 *     return _cuda_path
 * 
 * cpdef function.Module compile_with_cache(             # <<<<<<<<<<<<<<
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _cupy_header + source
 */

static PyObject *__pyx_pw_4cupy_4core_4core_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/carray.pxi":150
 * 
 * cpdef function.Module compile_with_cache(
 *         str source, tuple options=(), arch=None, cachd_dir=None):             # <<<<<<<<<<<<<<
 *     source = _cupy_header + source
 *     extra_source = _get_header_source()
 */
  PyObject *__pyx_v_options = ((PyObject*)__pyx_empty_tuple);
  PyObject *__pyx_v_arch = ((PyObject *)Py_None);
  PyObject *__pyx_v_cachd_dir = ((PyObject *)Py_None);
  PyObject *__pyx_v_extra_source = NULL;
  PyObject *__pyx_v_cuda_path = NULL;
  PyObject *__pyx_v_path = NULL;
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("compile_with_cache", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_options = __pyx_optional_args->options;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_arch = __pyx_optional_args->arch;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_cachd_dir = __pyx_optional_args->cachd_dir;
        }
      }
    }
  }
  __Pyx_INCREF(__pyx_v_source);
  __Pyx_INCREF(__pyx_v_options);

  /* "cupy/core/carray.pxi":151
 * cpdef function.Module compile_with_cache(
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _cupy_header + source             # <<<<<<<<<<<<<<
 *     extra_source = _get_header_source()
 *     options += ('-I%s' % _get_header_dir_path(),)
 */
  __pyx_t_1 = PyNumber_Add(__pyx_v_4cupy_4core_4core__cupy_header, __pyx_v_source); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_source, ((PyObject*)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/core/carray.pxi":152
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _cupy_header + source
 *     extra_source = _get_header_source()             # <<<<<<<<<<<<<<
 *     options += ('-I%s' % _get_header_dir_path(),)
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_header_source(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_extra_source = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/carray.pxi":153
 *     source = _cupy_header + source
 *     extra_source = _get_header_source()
 *     options += ('-I%s' % _get_header_dir_path(),)             # <<<<<<<<<<<<<<
 * 
 *     # The variable _cuda_runtime_version is declared in cupy/core/core.pyx,
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_header_dir_path(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_I_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_options, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_options, ((PyObject*)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/core/carray.pxi":158
 *     # but it might not have been set appropriately before coming here.
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  __pyx_t_3 = (__pyx_v_4cupy_4core_4core__cuda_runtime_version == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "cupy/core/carray.pxi":159
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:
 *         _cuda_runtime_version = runtime.runtimeGetVersion()             # <<<<<<<<<<<<<<
 * 
 *     if _cuda_runtime_version >= 9000:
 */
    __pyx_t_5 = __pyx_f_4cupy_4cuda_7runtime_runtimeGetVersion(0); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 159, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 159, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cuda_runtime_version);
    __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cuda_runtime_version, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/carray.pxi":158
 *     # but it might not have been set appropriately before coming here.
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  }

  /* "cupy/core/carray.pxi":161
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 *     if _cuda_runtime_version >= 9000:             # <<<<<<<<<<<<<<
 *         cuda_path = _get_cuda_path()
 *         if cuda_path is None:
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_4cupy_4core_4core__cuda_runtime_version, __pyx_int_9000, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 161, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(2, 161, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "cupy/core/carray.pxi":162
 * 
 *     if _cuda_runtime_version >= 9000:
 *         cuda_path = _get_cuda_path()             # <<<<<<<<<<<<<<
 *         if cuda_path is None:
 *             warnings.warn('Please set the CUDA path ' +
 */
    __pyx_t_2 = __pyx_f_4cupy_4core_4core__get_cuda_path(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 162, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_cuda_path = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "cupy/core/carray.pxi":163
 *     if _cuda_runtime_version >= 9000:
 *         cuda_path = _get_cuda_path()
 *         if cuda_path is None:             # <<<<<<<<<<<<<<
 *             warnings.warn('Please set the CUDA path ' +
 *                           'to environment variable `CUDA_PATH`')
 */
    __pyx_t_4 = (__pyx_v_cuda_path == Py_None);
    __pyx_t_3 = (__pyx_t_4 != 0);
    if (__pyx_t_3) {

      /* "cupy/core/carray.pxi":164
 *         cuda_path = _get_cuda_path()
 *         if cuda_path is None:
 *             warnings.warn('Please set the CUDA path ' +             # <<<<<<<<<<<<<<
 *                           'to environment variable `CUDA_PATH`')
 *         else:
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_warnings); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 164, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 164, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_Add(__pyx_kp_s_Please_set_the_CUDA_path, __pyx_kp_s_to_environment_variable_CUDA_PAT); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 164, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __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_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 164, __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_6)) {
          PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 164, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 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_6)) {
          PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 164, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        {
          __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 164, __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_1);
          PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_1);
          __pyx_t_1 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 164, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/core/carray.pxi":163
 *     if _cuda_runtime_version >= 9000:
 *         cuda_path = _get_cuda_path()
 *         if cuda_path is None:             # <<<<<<<<<<<<<<
 *             warnings.warn('Please set the CUDA path ' +
 *                           'to environment variable `CUDA_PATH`')
 */
      goto __pyx_L5;
    }

    /* "cupy/core/carray.pxi":167
 *                           'to environment variable `CUDA_PATH`')
 *         else:
 *             path = os.path.join(cuda_path, 'include')             # <<<<<<<<<<<<<<
 *             options += ('-I ' + path,)
 * 
 */
    /*else*/ {
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 167, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_path); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 167, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_join); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 167, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_cuda_path, __pyx_n_s_include};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 167, __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_6)) {
        PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_cuda_path, __pyx_n_s_include};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 167, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_1 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 167, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (__pyx_t_8) {
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8); __pyx_t_8 = NULL;
        }
        __Pyx_INCREF(__pyx_v_cuda_path);
        __Pyx_GIVEREF(__pyx_v_cuda_path);
        PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_5, __pyx_v_cuda_path);
        __Pyx_INCREF(__pyx_n_s_include);
        __Pyx_GIVEREF(__pyx_n_s_include);
        PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_5, __pyx_n_s_include);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 167, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_path = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "cupy/core/carray.pxi":168
 *         else:
 *             path = os.path.join(cuda_path, 'include')
 *             options += ('-I ' + path,)             # <<<<<<<<<<<<<<
 * 
 *     return cuda.compile_with_cache(source, options, arch, cachd_dir,
 */
      __pyx_t_2 = PyNumber_Add(__pyx_kp_s_I, __pyx_v_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 168, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 168, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_options, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 168, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF_SET(__pyx_v_options, ((PyObject*)__pyx_t_2));
      __pyx_t_2 = 0;
    }
    __pyx_L5:;

    /* "cupy/core/carray.pxi":161
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 *     if _cuda_runtime_version >= 9000:             # <<<<<<<<<<<<<<
 *         cuda_path = _get_cuda_path()
 *         if cuda_path is None:
 */
  }

  /* "cupy/core/carray.pxi":170
 *             options += ('-I ' + path,)
 * 
 *     return cuda.compile_with_cache(source, options, arch, cachd_dir,             # <<<<<<<<<<<<<<
 *                                    extra_source)
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_compile_with_cache); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/carray.pxi":171
 * 
 *     return cuda.compile_with_cache(source, options, arch, cachd_dir,
 *                                    extra_source)             # <<<<<<<<<<<<<<
 */
  __pyx_t_6 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[6] = {__pyx_t_6, __pyx_v_source, __pyx_v_options, __pyx_v_arch, __pyx_v_cachd_dir, __pyx_v_extra_source};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 170, __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_1)) {
    PyObject *__pyx_temp[6] = {__pyx_t_6, __pyx_v_source, __pyx_v_options, __pyx_v_arch, __pyx_v_cachd_dir, __pyx_v_extra_source};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 170, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 170, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_INCREF(__pyx_v_source);
    __Pyx_GIVEREF(__pyx_v_source);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_5, __pyx_v_source);
    __Pyx_INCREF(__pyx_v_options);
    __Pyx_GIVEREF(__pyx_v_options);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_5, __pyx_v_options);
    __Pyx_INCREF(__pyx_v_arch);
    __Pyx_GIVEREF(__pyx_v_arch);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_5, __pyx_v_arch);
    __Pyx_INCREF(__pyx_v_cachd_dir);
    __Pyx_GIVEREF(__pyx_v_cachd_dir);
    PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_5, __pyx_v_cachd_dir);
    __Pyx_INCREF(__pyx_v_extra_source);
    __Pyx_GIVEREF(__pyx_v_extra_source);
    PyTuple_SET_ITEM(__pyx_t_8, 4+__pyx_t_5, __pyx_v_extra_source);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 170, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/carray.pxi":170
 *             options += ('-I ' + path,)
 * 
 *     return cuda.compile_with_cache(source, options, arch, cachd_dir,             # <<<<<<<<<<<<<<
 *                                    extra_source)
 */
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4cuda_8function_Module))))) __PYX_ERR(2, 170, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4cuda_8function_Module *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/carray.pxi":149
 *     return _cuda_path
 * 
 * cpdef function.Module compile_with_cache(             # <<<<<<<<<<<<<<
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _cupy_header + source
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.core.core.compile_with_cache", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_extra_source);
  __Pyx_XDECREF(__pyx_v_cuda_path);
  __Pyx_XDECREF(__pyx_v_path);
  __Pyx_XDECREF(__pyx_v_source);
  __Pyx_XDECREF(__pyx_v_options);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_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(str source, tuple options=(), arch=None, cachd_dir=None) -> 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_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compile_with_cache (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_source,&__pyx_n_s_options,&__pyx_n_s_arch,&__pyx_n_s_cachd_dir,0};
    PyObject* values[4] = {0,0,0,0};

    /* "cupy/core/carray.pxi":150
 * 
 * cpdef function.Module compile_with_cache(
 *         str source, tuple options=(), arch=None, cachd_dir=None):             # <<<<<<<<<<<<<<
 *     source = _cupy_header + source
 *     extra_source = _get_header_source()
 */
    values[1] = ((PyObject*)__pyx_empty_tuple);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__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 = PyDict_GetItem(__pyx_kwds, __pyx_n_s_options);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_arch);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cachd_dir);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compile_with_cache") < 0)) __PYX_ERR(2, 149, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_source = ((PyObject*)values[0]);
    __pyx_v_options = ((PyObject*)values[1]);
    __pyx_v_arch = values[2];
    __pyx_v_cachd_dir = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("compile_with_cache", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 149, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.compile_with_cache", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_source), (&PyString_Type), 1, "source", 1))) __PYX_ERR(2, 150, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_options), (&PyTuple_Type), 1, "options", 1))) __PYX_ERR(2, 150, __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);

  /* "cupy/core/carray.pxi":149
 *     return _cuda_path
 * 
 * cpdef function.Module compile_with_cache(             # <<<<<<<<<<<<<<
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _cupy_header + source
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_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_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache __pyx_t_2;
  __Pyx_RefNannySetupContext("compile_with_cache", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.options = __pyx_v_options;
  __pyx_t_2.arch = __pyx_v_arch;
  __pyx_t_2.cachd_dir = __pyx_v_cachd_dir;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_compile_with_cache(__pyx_v_source, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":13
 * 
 * 
 * cpdef _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):
 */

static PyObject *__pyx_pw_4cupy_4core_4core_11_get_simple_elementwise_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_simple_elementwise_kernel(PyObject *__pyx_v_params, PyObject *__pyx_v_operation, PyObject *__pyx_v_name, PyObject *__pyx_v_preamble, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__get_simple_elementwise_kernel *__pyx_optional_args) {
  PyObject *__pyx_v_loop_prep = ((PyObject *)__pyx_kp_s__5);
  PyObject *__pyx_v_after_loop = ((PyObject *)__pyx_kp_s__5);

  /* "cupy/core/elementwise.pxi":15
 * cpdef _get_simple_elementwise_kernel(
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):             # <<<<<<<<<<<<<<
 *     module_code = string.Template('''
 *     ${preamble}
 */
  PyObject *__pyx_v_options = ((PyObject *)__pyx_empty_tuple);
  PyObject *__pyx_v_module_code = NULL;
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_v_module = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache __pyx_t_4;
  __Pyx_RefNannySetupContext("_get_simple_elementwise_kernel", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_loop_prep = __pyx_optional_args->loop_prep;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_after_loop = __pyx_optional_args->after_loop;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_options = __pyx_optional_args->options;
        }
      }
    }
  }

  /* "cupy/core/elementwise.pxi":16
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):
 *     module_code = string.Template('''             # <<<<<<<<<<<<<<
 *     ${preamble}
 *     extern "C" __global__ void ${name}(${params}) {
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Template); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__69, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":26
 *       ${after_loop};
 *     }
 *     ''').substitute(             # <<<<<<<<<<<<<<
 *         params=params,
 *         operation=operation,
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_substitute); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":27
 *     }
 *     ''').substitute(
 *         params=params,             # <<<<<<<<<<<<<<
 *         operation=operation,
 *         name=name,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_params, __pyx_v_params) < 0) __PYX_ERR(1, 27, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":28
 *     ''').substitute(
 *         params=params,
 *         operation=operation,             # <<<<<<<<<<<<<<
 *         name=name,
 *         preamble=preamble,
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_operation, __pyx_v_operation) < 0) __PYX_ERR(1, 27, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":29
 *         params=params,
 *         operation=operation,
 *         name=name,             # <<<<<<<<<<<<<<
 *         preamble=preamble,
 *         loop_prep=loop_prep,
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(1, 27, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":30
 *         operation=operation,
 *         name=name,
 *         preamble=preamble,             # <<<<<<<<<<<<<<
 *         loop_prep=loop_prep,
 *         after_loop=after_loop)
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_preamble, __pyx_v_preamble) < 0) __PYX_ERR(1, 27, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":31
 *         name=name,
 *         preamble=preamble,
 *         loop_prep=loop_prep,             # <<<<<<<<<<<<<<
 *         after_loop=after_loop)
 *     module = compile_with_cache(module_code, options)
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_loop_prep, __pyx_v_loop_prep) < 0) __PYX_ERR(1, 27, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":32
 *         preamble=preamble,
 *         loop_prep=loop_prep,
 *         after_loop=after_loop)             # <<<<<<<<<<<<<<
 *     module = compile_with_cache(module_code, options)
 *     return module.get_function(name)
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_after_loop, __pyx_v_after_loop) < 0) __PYX_ERR(1, 27, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":26
 *       ${after_loop};
 *     }
 *     ''').substitute(             # <<<<<<<<<<<<<<
 *         params=params,
 *         operation=operation,
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_module_code = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":33
 *         loop_prep=loop_prep,
 *         after_loop=after_loop)
 *     module = compile_with_cache(module_code, options)             # <<<<<<<<<<<<<<
 *     return module.get_function(name)
 * 
 */
  if (!(likely(PyString_CheckExact(__pyx_v_module_code))||((__pyx_v_module_code) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_module_code)->tp_name), 0))) __PYX_ERR(1, 33, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_options))||((__pyx_v_options) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_options)->tp_name), 0))) __PYX_ERR(1, 33, __pyx_L1_error)
  __pyx_t_4.__pyx_n = 1;
  __pyx_t_4.options = ((PyObject*)__pyx_v_options);
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_compile_with_cache(((PyObject*)__pyx_v_module_code), 0, &__pyx_t_4)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 33, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_module = ((struct __pyx_obj_4cupy_4cuda_8function_Module *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":34
 *         after_loop=after_loop)
 *     module = compile_with_cache(module_code, options)
 *     return module.get_function(name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyString_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(1, 34, __pyx_L1_error)
  __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Module *)__pyx_v_module->__pyx_vtab)->get_function(__pyx_v_module, ((PyObject*)__pyx_v_name), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 34, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":13
 * 
 * 
 * cpdef _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):
 */

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_11_get_simple_elementwise_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_10_get_simple_elementwise_kernel[] = "_get_simple_elementwise_kernel(params, operation, name, preamble, loop_prep='', after_loop='', options=())";
static PyObject *__pyx_pw_4cupy_4core_4core_11_get_simple_elementwise_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_operation = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_loop_prep = 0;
  PyObject *__pyx_v_after_loop = 0;
  PyObject *__pyx_v_options = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_simple_elementwise_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_params,&__pyx_n_s_operation,&__pyx_n_s_name,&__pyx_n_s_preamble,&__pyx_n_s_loop_prep,&__pyx_n_s_after_loop,&__pyx_n_s_options,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    values[4] = ((PyObject *)__pyx_kp_s__5);
    values[5] = ((PyObject *)__pyx_kp_s__5);

    /* "cupy/core/elementwise.pxi":15
 * cpdef _get_simple_elementwise_kernel(
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):             # <<<<<<<<<<<<<<
 *     module_code = string.Template('''
 *     ${preamble}
 */
    values[6] = ((PyObject *)__pyx_empty_tuple);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_params)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_operation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_elementwise_kernel", 0, 4, 7, 1); __PYX_ERR(1, 13, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_elementwise_kernel", 0, 4, 7, 2); __PYX_ERR(1, 13, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_preamble)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_elementwise_kernel", 0, 4, 7, 3); __PYX_ERR(1, 13, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop_prep);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_after_loop);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_options);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_simple_elementwise_kernel") < 0)) __PYX_ERR(1, 13, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_params = values[0];
    __pyx_v_operation = values[1];
    __pyx_v_name = values[2];
    __pyx_v_preamble = values[3];
    __pyx_v_loop_prep = values[4];
    __pyx_v_after_loop = values[5];
    __pyx_v_options = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_simple_elementwise_kernel", 0, 4, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 13, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_simple_elementwise_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_10_get_simple_elementwise_kernel(__pyx_self, __pyx_v_params, __pyx_v_operation, __pyx_v_name, __pyx_v_preamble, __pyx_v_loop_prep, __pyx_v_after_loop, __pyx_v_options);

  /* "cupy/core/elementwise.pxi":13
 * 
 * 
 * cpdef _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):
 */

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

static PyObject *__pyx_pf_4cupy_4core_4core_10_get_simple_elementwise_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_params, PyObject *__pyx_v_operation, PyObject *__pyx_v_name, PyObject *__pyx_v_preamble, PyObject *__pyx_v_loop_prep, PyObject *__pyx_v_after_loop, PyObject *__pyx_v_options) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__get_simple_elementwise_kernel __pyx_t_2;
  __Pyx_RefNannySetupContext("_get_simple_elementwise_kernel", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.loop_prep = __pyx_v_loop_prep;
  __pyx_t_2.after_loop = __pyx_v_after_loop;
  __pyx_t_2.options = __pyx_v_options;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_simple_elementwise_kernel(__pyx_v_params, __pyx_v_operation, __pyx_v_name, __pyx_v_preamble, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 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._get_simple_elementwise_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":101
 * 
 * 
 * cpdef _python_scalar_to_numpy_scalar(x):             # <<<<<<<<<<<<<<
 *     if isinstance(x, six.integer_types):
 *         numpy_type = numpy.uint64 if x >= 0x8000000000000000 else numpy.int64
 */

static PyObject *__pyx_pw_4cupy_4core_4core_13_python_scalar_to_numpy_scalar(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__python_scalar_to_numpy_scalar(PyObject *__pyx_v_x, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_numpy_type = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("_python_scalar_to_numpy_scalar", 0);

  /* "cupy/core/elementwise.pxi":102
 * 
 * cpdef _python_scalar_to_numpy_scalar(x):
 *     if isinstance(x, six.integer_types):             # <<<<<<<<<<<<<<
 *         numpy_type = numpy.uint64 if x >= 0x8000000000000000 else numpy.int64
 *     else:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 102, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_integer_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 102, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = PyObject_IsInstance(__pyx_v_x, __pyx_t_2); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(1, 102, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "cupy/core/elementwise.pxi":103
 * cpdef _python_scalar_to_numpy_scalar(x):
 *     if isinstance(x, six.integer_types):
 *         numpy_type = numpy.uint64 if x >= 0x8000000000000000 else numpy.int64             # <<<<<<<<<<<<<<
 *     else:
 *         numpy_type = _python_type_to_numpy_type[type(x)]
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_x, __pyx_int_9223372036854775808, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 103, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 103, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_4) {
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 103, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint64); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 103, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_2 = __pyx_t_5;
      __pyx_t_5 = 0;
    } else {
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 103, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int64); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 103, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_2 = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    __pyx_v_numpy_type = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":102
 * 
 * cpdef _python_scalar_to_numpy_scalar(x):
 *     if isinstance(x, six.integer_types):             # <<<<<<<<<<<<<<
 *         numpy_type = numpy.uint64 if x >= 0x8000000000000000 else numpy.int64
 *     else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/elementwise.pxi":105
 *         numpy_type = numpy.uint64 if x >= 0x8000000000000000 else numpy.int64
 *     else:
 *         numpy_type = _python_type_to_numpy_type[type(x)]             # <<<<<<<<<<<<<<
 *     return numpy_type(x)
 * 
 */
  /*else*/ {
    if (unlikely(__pyx_v_4cupy_4core_4core__python_type_to_numpy_type == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 105, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_4cupy_4core_4core__python_type_to_numpy_type, ((PyObject *)Py_TYPE(__pyx_v_x))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 105, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_numpy_type = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/elementwise.pxi":106
 *     else:
 *         numpy_type = _python_type_to_numpy_type[type(x)]
 *     return numpy_type(x)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_numpy_type);
  __pyx_t_1 = __pyx_v_numpy_type; __pyx_t_5 = NULL;
  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);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_x); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 106, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_x};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 106, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_x};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 106, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 106, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_x);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 106, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":101
 * 
 * 
 * cpdef _python_scalar_to_numpy_scalar(x):             # <<<<<<<<<<<<<<
 *     if isinstance(x, six.integer_types):
 *         numpy_type = numpy.uint64 if x >= 0x8000000000000000 else numpy.int64
 */

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_13_python_scalar_to_numpy_scalar(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/
static char __pyx_doc_4cupy_4core_4core_12_python_scalar_to_numpy_scalar[] = "_python_scalar_to_numpy_scalar(x)";
static PyObject *__pyx_pw_4cupy_4core_4core_13_python_scalar_to_numpy_scalar(PyObject *__pyx_self, PyObject *__pyx_v_x) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_python_scalar_to_numpy_scalar (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_12_python_scalar_to_numpy_scalar(__pyx_self, ((PyObject *)__pyx_v_x));

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

static PyObject *__pyx_pf_4cupy_4core_4core_12_python_scalar_to_numpy_scalar(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_python_scalar_to_numpy_scalar", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__python_scalar_to_numpy_scalar(__pyx_v_x, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":109
 * 
 * 
 * cpdef str _get_typename(dtype):             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         raise ValueError('dtype is None')
 */

static PyObject *__pyx_pw_4cupy_4core_4core_15_get_typename(PyObject *__pyx_self, PyObject *__pyx_v_dtype); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_typename(PyObject *__pyx_v_dtype, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("_get_typename", 0);
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/elementwise.pxi":110
 * 
 * cpdef str _get_typename(dtype):
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('dtype is None')
 *     if dtype not in _typenames:
 */
  __pyx_t_1 = (__pyx_v_dtype == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":111
 * cpdef str _get_typename(dtype):
 *     if dtype is None:
 *         raise ValueError('dtype is None')             # <<<<<<<<<<<<<<
 *     if dtype not in _typenames:
 *         dtype = numpy.dtype(dtype).type
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__70, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 111, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 111, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":110
 * 
 * cpdef str _get_typename(dtype):
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('dtype is None')
 *     if dtype not in _typenames:
 */
  }

  /* "cupy/core/elementwise.pxi":112
 *     if dtype is None:
 *         raise ValueError('dtype is None')
 *     if dtype not in _typenames:             # <<<<<<<<<<<<<<
 *         dtype = numpy.dtype(dtype).type
 *     return _typenames[dtype]
 */
  if (unlikely(__pyx_v_4cupy_4core_4core__typenames == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(1, 112, __pyx_L1_error)
  }
  __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_v_dtype, __pyx_v_4cupy_4core_4core__typenames, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 112, __pyx_L1_error)
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/elementwise.pxi":113
 *         raise ValueError('dtype is None')
 *     if dtype not in _typenames:
 *         dtype = numpy.dtype(dtype).type             # <<<<<<<<<<<<<<
 *     return _typenames[dtype]
 * 
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 113, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_dtype};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 113, __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_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_dtype};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 113, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 113, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_dtype);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 113, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_type); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":112
 *     if dtype is None:
 *         raise ValueError('dtype is None')
 *     if dtype not in _typenames:             # <<<<<<<<<<<<<<
 *         dtype = numpy.dtype(dtype).type
 *     return _typenames[dtype]
 */
  }

  /* "cupy/core/elementwise.pxi":114
 *     if dtype not in _typenames:
 *         dtype = numpy.dtype(dtype).type
 *     return _typenames[dtype]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_4cupy_4core_4core__typenames == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 114, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_4cupy_4core_4core__typenames, __pyx_v_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (!(likely(PyString_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(1, 114, __pyx_L1_error)
  __pyx_r = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":109
 * 
 * 
 * cpdef str _get_typename(dtype):             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         raise ValueError('dtype is None')
 */

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_15_get_typename(PyObject *__pyx_self, PyObject *__pyx_v_dtype); /*proto*/
static char __pyx_doc_4cupy_4core_4core_14_get_typename[] = "_get_typename(dtype) -> str";
static PyObject *__pyx_pw_4cupy_4core_4core_15_get_typename(PyObject *__pyx_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_typename (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_14_get_typename(__pyx_self, ((PyObject *)__pyx_v_dtype));

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

static PyObject *__pyx_pf_4cupy_4core_4core_14_get_typename(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_typename", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 109, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":117
 * 
 * 
 * cpdef list _preprocess_args(args):             # <<<<<<<<<<<<<<
 *     """Preprocesses arguments for kernel invocation
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_17_preprocess_args(PyObject *__pyx_self, PyObject *__pyx_v_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__preprocess_args(PyObject *__pyx_v_args, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_ret = 0;
  int __pyx_v_dev_id;
  PyTypeObject *__pyx_v_typ = 0;
  PyObject *__pyx_v_arg = NULL;
  struct __pyx_obj_4cupy_4cuda_6device_Device *__pyx_v_arr_dev = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  __Pyx_RefNannySetupContext("_preprocess_args", 0);

  /* "cupy/core/elementwise.pxi":123
 *     - Converts Python scalars into NumPy scalars
 *     """
 *     cdef list ret = []             # <<<<<<<<<<<<<<
 *     cdef int dev_id = device.get_device_id()
 *     cdef type typ
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":124
 *     """
 *     cdef list ret = []
 *     cdef int dev_id = device.get_device_id()             # <<<<<<<<<<<<<<
 *     cdef type typ
 * 
 */
  __pyx_t_2 = __pyx_f_4cupy_4cuda_6device_get_device_id(0); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 124, __pyx_L1_error)
  __pyx_v_dev_id = __pyx_t_2;

  /* "cupy/core/elementwise.pxi":127
 *     cdef type typ
 * 
 *     for arg in args:             # <<<<<<<<<<<<<<
 *         typ = type(arg)
 *         if typ is ndarray:
 */
  if (likely(PyList_CheckExact(__pyx_v_args)) || PyTuple_CheckExact(__pyx_v_args)) {
    __pyx_t_1 = __pyx_v_args; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 127, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 127, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 127, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 127, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 127, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 127, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 127, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":128
 * 
 *     for arg in args:
 *         typ = type(arg)             # <<<<<<<<<<<<<<
 *         if typ is ndarray:
 *             arr_dev = (<ndarray?>arg).data.device
 */
    __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_arg)));
    __Pyx_XDECREF_SET(__pyx_v_typ, ((PyTypeObject*)((PyObject *)Py_TYPE(__pyx_v_arg))));

    /* "cupy/core/elementwise.pxi":129
 *     for arg in args:
 *         typ = type(arg)
 *         if typ is ndarray:             # <<<<<<<<<<<<<<
 *             arr_dev = (<ndarray?>arg).data.device
 *             if arr_dev is not None and arr_dev.id != dev_id:
 */
    __pyx_t_6 = (__pyx_v_typ == __pyx_ptype_4cupy_4core_4core_ndarray);
    __pyx_t_7 = (__pyx_t_6 != 0);
    if (__pyx_t_7) {

      /* "cupy/core/elementwise.pxi":130
 *         typ = type(arg)
 *         if typ is ndarray:
 *             arr_dev = (<ndarray?>arg).data.device             # <<<<<<<<<<<<<<
 *             if arr_dev is not None and arr_dev.id != dev_id:
 *                 raise ValueError(
 */
      if (!(likely(__Pyx_TypeTest(__pyx_v_arg, __pyx_ptype_4cupy_4core_4core_ndarray)))) __PYX_ERR(1, 130, __pyx_L1_error)
      __pyx_t_5 = ((PyObject *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_arg)->data->device);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_XDECREF_SET(__pyx_v_arr_dev, ((struct __pyx_obj_4cupy_4cuda_6device_Device *)__pyx_t_5));
      __pyx_t_5 = 0;

      /* "cupy/core/elementwise.pxi":131
 *         if typ is ndarray:
 *             arr_dev = (<ndarray?>arg).data.device
 *             if arr_dev is not None and arr_dev.id != dev_id:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'Array device must be same as the current '
 */
      __pyx_t_6 = (((PyObject *)__pyx_v_arr_dev) != Py_None);
      __pyx_t_8 = (__pyx_t_6 != 0);
      if (__pyx_t_8) {
      } else {
        __pyx_t_7 = __pyx_t_8;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_8 = ((__pyx_v_arr_dev->id != __pyx_v_dev_id) != 0);
      __pyx_t_7 = __pyx_t_8;
      __pyx_L7_bool_binop_done:;
      if (__pyx_t_7) {

        /* "cupy/core/elementwise.pxi":135
 *                     'Array device must be same as the current '
 *                     'device: array device = %d while current = %d'
 *                     % (arr_dev.id, dev_id))             # <<<<<<<<<<<<<<
 *         elif typ in _python_scalar_type_set:
 *             arg = _python_scalar_to_numpy_scalar(arg)
 */
        __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_arr_dev->id); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 135, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_dev_id); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 135, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 135, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
        __pyx_t_5 = 0;
        __pyx_t_9 = 0;
        __pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_Array_device_must_be_same_as_the, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 135, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

        /* "cupy/core/elementwise.pxi":132
 *             arr_dev = (<ndarray?>arg).data.device
 *             if arr_dev is not None and arr_dev.id != dev_id:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'Array device must be same as the current '
 *                     'device: array device = %d while current = %d'
 */
        __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 132, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 132, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_Raise(__pyx_t_9, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __PYX_ERR(1, 132, __pyx_L1_error)

        /* "cupy/core/elementwise.pxi":131
 *         if typ is ndarray:
 *             arr_dev = (<ndarray?>arg).data.device
 *             if arr_dev is not None and arr_dev.id != dev_id:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'Array device must be same as the current '
 */
      }

      /* "cupy/core/elementwise.pxi":129
 *     for arg in args:
 *         typ = type(arg)
 *         if typ is ndarray:             # <<<<<<<<<<<<<<
 *             arr_dev = (<ndarray?>arg).data.device
 *             if arr_dev is not None and arr_dev.id != dev_id:
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":136
 *                     'device: array device = %d while current = %d'
 *                     % (arr_dev.id, dev_id))
 *         elif typ in _python_scalar_type_set:             # <<<<<<<<<<<<<<
 *             arg = _python_scalar_to_numpy_scalar(arg)
 *         elif typ in _numpy_scalar_type_set:
 */
    __pyx_t_7 = (__Pyx_PySequence_ContainsTF(((PyObject *)__pyx_v_typ), __pyx_v_4cupy_4core_4core__python_scalar_type_set, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(1, 136, __pyx_L1_error)
    __pyx_t_8 = (__pyx_t_7 != 0);
    if (__pyx_t_8) {

      /* "cupy/core/elementwise.pxi":137
 *                     % (arr_dev.id, dev_id))
 *         elif typ in _python_scalar_type_set:
 *             arg = _python_scalar_to_numpy_scalar(arg)             # <<<<<<<<<<<<<<
 *         elif typ in _numpy_scalar_type_set:
 *             pass
 */
      __pyx_t_9 = __pyx_f_4cupy_4core_4core__python_scalar_to_numpy_scalar(__pyx_v_arg, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 137, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF_SET(__pyx_v_arg, __pyx_t_9);
      __pyx_t_9 = 0;

      /* "cupy/core/elementwise.pxi":136
 *                     'device: array device = %d while current = %d'
 *                     % (arr_dev.id, dev_id))
 *         elif typ in _python_scalar_type_set:             # <<<<<<<<<<<<<<
 *             arg = _python_scalar_to_numpy_scalar(arg)
 *         elif typ in _numpy_scalar_type_set:
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":138
 *         elif typ in _python_scalar_type_set:
 *             arg = _python_scalar_to_numpy_scalar(arg)
 *         elif typ in _numpy_scalar_type_set:             # <<<<<<<<<<<<<<
 *             pass
 *         else:
 */
    __pyx_t_8 = (__Pyx_PySequence_ContainsTF(((PyObject *)__pyx_v_typ), __pyx_v_4cupy_4core_4core__numpy_scalar_type_set, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 138, __pyx_L1_error)
    __pyx_t_7 = (__pyx_t_8 != 0);
    if (__pyx_t_7) {
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":141
 *             pass
 *         else:
 *             raise TypeError('Unsupported type %s' % typ)             # <<<<<<<<<<<<<<
 *         ret.append(arg)
 *     return ret
 */
    /*else*/ {
      __pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_Unsupported_type_s, ((PyObject *)__pyx_v_typ)); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(1, 141, __pyx_L1_error)
    }
    __pyx_L5:;

    /* "cupy/core/elementwise.pxi":142
 *         else:
 *             raise TypeError('Unsupported type %s' % typ)
 *         ret.append(arg)             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
    __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_arg); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(1, 142, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":127
 *     cdef type typ
 * 
 *     for arg in args:             # <<<<<<<<<<<<<<
 *         typ = type(arg)
 *         if typ is ndarray:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":143
 *             raise TypeError('Unsupported type %s' % typ)
 *         ret.append(arg)
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ret);
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":117
 * 
 * 
 * cpdef list _preprocess_args(args):             # <<<<<<<<<<<<<<
 *     """Preprocesses arguments for kernel invocation
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cupy.core.core._preprocess_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_typ);
  __Pyx_XDECREF(__pyx_v_arg);
  __Pyx_XDECREF((PyObject *)__pyx_v_arr_dev);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17_preprocess_args(PyObject *__pyx_self, PyObject *__pyx_v_args); /*proto*/
static char __pyx_doc_4cupy_4core_4core_16_preprocess_args[] = "_preprocess_args(args) -> list\nPreprocesses arguments for kernel invocation\n\n    - Checks device compatibility for ndarrays\n    - Converts Python scalars into NumPy scalars\n    ";
static PyObject *__pyx_pw_4cupy_4core_4core_17_preprocess_args(PyObject *__pyx_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_preprocess_args (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_16_preprocess_args(__pyx_self, ((PyObject *)__pyx_v_args));

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

static PyObject *__pyx_pf_4cupy_4core_4core_16_preprocess_args(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_preprocess_args", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_v_args, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":146
 * 
 * 
 * cpdef tuple _get_args_info(list args):             # <<<<<<<<<<<<<<
 *     ret = []
 *     for a in args:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_19_get_args_info(PyObject *__pyx_self, PyObject *__pyx_v_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_args_info(PyObject *__pyx_v_args, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_ret = NULL;
  PyObject *__pyx_v_a = NULL;
  PyTypeObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("_get_args_info", 0);

  /* "cupy/core/elementwise.pxi":147
 * 
 * cpdef tuple _get_args_info(list args):
 *     ret = []             # <<<<<<<<<<<<<<
 *     for a in args:
 *         t = type(a)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":148
 * cpdef tuple _get_args_info(list args):
 *     ret = []
 *     for a in args:             # <<<<<<<<<<<<<<
 *         t = type(a)
 *         if t is Indexer:
 */
  if (unlikely(__pyx_v_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(1, 148, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_v_args; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 148, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 148, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":149
 *     ret = []
 *     for a in args:
 *         t = type(a)             # <<<<<<<<<<<<<<
 *         if t is Indexer:
 *             dtype = None
 */
    __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_a)));
    __Pyx_XDECREF_SET(__pyx_v_t, ((PyTypeObject*)((PyObject *)Py_TYPE(__pyx_v_a))));

    /* "cupy/core/elementwise.pxi":150
 *     for a in args:
 *         t = type(a)
 *         if t is Indexer:             # <<<<<<<<<<<<<<
 *             dtype = None
 *         else:
 */
    __pyx_t_4 = (__pyx_v_t == __pyx_ptype_4cupy_4core_4core_Indexer);
    __pyx_t_5 = (__pyx_t_4 != 0);
    if (__pyx_t_5) {

      /* "cupy/core/elementwise.pxi":151
 *         t = type(a)
 *         if t is Indexer:
 *             dtype = None             # <<<<<<<<<<<<<<
 *         else:
 *             dtype = a.dtype.type
 */
      __Pyx_INCREF(Py_None);
      __Pyx_XDECREF_SET(__pyx_v_dtype, Py_None);

      /* "cupy/core/elementwise.pxi":150
 *     for a in args:
 *         t = type(a)
 *         if t is Indexer:             # <<<<<<<<<<<<<<
 *             dtype = None
 *         else:
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":153
 *             dtype = None
 *         else:
 *             dtype = a.dtype.type             # <<<<<<<<<<<<<<
 *         ret.append((t, dtype, a.ndim))
 *     return tuple(ret)
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 153, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 153, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_dtype, __pyx_t_6);
      __pyx_t_6 = 0;
    }
    __pyx_L5:;

    /* "cupy/core/elementwise.pxi":154
 *         else:
 *             dtype = a.dtype.type
 *         ret.append((t, dtype, a.ndim))             # <<<<<<<<<<<<<<
 *     return tuple(ret)
 * 
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_t));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_t));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_t));
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_t_3); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(1, 154, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":148
 * cpdef tuple _get_args_info(list args):
 *     ret = []
 *     for a in args:             # <<<<<<<<<<<<<<
 *         t = type(a)
 *         if t is Indexer:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":155
 *             dtype = a.dtype.type
 *         ret.append((t, dtype, a.ndim))
 *     return tuple(ret)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_AsTuple(__pyx_v_ret); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":146
 * 
 * 
 * cpdef tuple _get_args_info(list args):             # <<<<<<<<<<<<<<
 *     ret = []
 *     for a in args:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core._get_args_info", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_19_get_args_info(PyObject *__pyx_self, PyObject *__pyx_v_args); /*proto*/
static char __pyx_doc_4cupy_4core_4core_18_get_args_info[] = "_get_args_info(list args) -> tuple";
static PyObject *__pyx_pw_4cupy_4core_4core_19_get_args_info(PyObject *__pyx_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_args_info (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args), (&PyList_Type), 1, "args", 1))) __PYX_ERR(1, 146, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_18_get_args_info(__pyx_self, ((PyObject*)__pyx_v_args));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_18_get_args_info(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_args_info", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_args_info(__pyx_v_args, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":158
 * 
 * 
 * cpdef str _get_kernel_params(tuple params, tuple args_info):             # <<<<<<<<<<<<<<
 *     cdef ParameterInfo p
 *     ret = []
 */

static PyObject *__pyx_pw_4cupy_4core_4core_21_get_kernel_params(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_kernel_params(PyObject *__pyx_v_params, PyObject *__pyx_v_args_info, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_p = 0;
  PyObject *__pyx_v_ret = NULL;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_v_type = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_ndim = NULL;
  PyObject *__pyx_v_is_array = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("_get_kernel_params", 0);

  /* "cupy/core/elementwise.pxi":160
 * cpdef str _get_kernel_params(tuple params, tuple args_info):
 *     cdef ParameterInfo p
 *     ret = []             # <<<<<<<<<<<<<<
 *     for i in range(len(params)):
 *         p = params[i]
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":161
 *     cdef ParameterInfo p
 *     ret = []
 *     for i in range(len(params)):             # <<<<<<<<<<<<<<
 *         p = params[i]
 *         type, dtype, ndim = <tuple>(args_info[i])
 */
  if (unlikely(__pyx_v_params == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 161, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v_params); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(1, 161, __pyx_L1_error)
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "cupy/core/elementwise.pxi":162
 *     ret = []
 *     for i in range(len(params)):
 *         p = params[i]             # <<<<<<<<<<<<<<
 *         type, dtype, ndim = <tuple>(args_info[i])
 *         is_array = type is ndarray
 */
    if (unlikely(__pyx_v_params == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 162, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_params, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 162, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ParameterInfo))))) __PYX_ERR(1, 162, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_p, ((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":163
 *     for i in range(len(params)):
 *         p = params[i]
 *         type, dtype, ndim = <tuple>(args_info[i])             # <<<<<<<<<<<<<<
 *         is_array = type is ndarray
 *         if type is Indexer:
 */
    if (unlikely(__pyx_v_args_info == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 163, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_args_info, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 163, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __pyx_t_1;
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(__pyx_t_4 != Py_None)) {
      PyObject* sequence = __pyx_t_4;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(1, 163, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); 
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 163, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 163, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 163, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 163, __pyx_L1_error)
    }
    __Pyx_XDECREF_SET(__pyx_v_type, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_dtype, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_ndim, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":164
 *         p = params[i]
 *         type, dtype, ndim = <tuple>(args_info[i])
 *         is_array = type is ndarray             # <<<<<<<<<<<<<<
 *         if type is Indexer:
 *             t = 'CIndexer<%d>' % ndim
 */
    __pyx_t_7 = (__pyx_v_type == ((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray));
    __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XDECREF_SET(__pyx_v_is_array, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/elementwise.pxi":165
 *         type, dtype, ndim = <tuple>(args_info[i])
 *         is_array = type is ndarray
 *         if type is Indexer:             # <<<<<<<<<<<<<<
 *             t = 'CIndexer<%d>' % ndim
 *         else:
 */
    __pyx_t_7 = (__pyx_v_type == ((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer));
    __pyx_t_8 = (__pyx_t_7 != 0);
    if (__pyx_t_8) {

      /* "cupy/core/elementwise.pxi":166
 *         is_array = type is ndarray
 *         if type is Indexer:
 *             t = 'CIndexer<%d>' % ndim             # <<<<<<<<<<<<<<
 *         else:
 *             t = _get_typename(dtype)
 */
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_CIndexer_d, __pyx_v_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 166, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/elementwise.pxi":165
 *         type, dtype, ndim = <tuple>(args_info[i])
 *         is_array = type is ndarray
 *         if type is Indexer:             # <<<<<<<<<<<<<<
 *             t = 'CIndexer<%d>' % ndim
 *         else:
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":168
 *             t = 'CIndexer<%d>' % ndim
 *         else:
 *             t = _get_typename(dtype)             # <<<<<<<<<<<<<<
 *             if is_array:
 *                 t = 'CArray<%s, %d>' % (t, ndim)
 */
    /*else*/ {
      __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 168, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/elementwise.pxi":169
 *         else:
 *             t = _get_typename(dtype)
 *             if is_array:             # <<<<<<<<<<<<<<
 *                 t = 'CArray<%s, %d>' % (t, ndim)
 *         ret.append('%s %s%s' % (t,
 */
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_is_array); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 169, __pyx_L1_error)
      if (__pyx_t_8) {

        /* "cupy/core/elementwise.pxi":170
 *             t = _get_typename(dtype)
 *             if is_array:
 *                 t = 'CArray<%s, %d>' % (t, ndim)             # <<<<<<<<<<<<<<
 *         ret.append('%s %s%s' % (t,
 *                                 '_raw_' if is_array and not p.raw else '',
 */
        __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 170, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_v_t);
        __Pyx_GIVEREF(__pyx_v_t);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_t);
        __Pyx_INCREF(__pyx_v_ndim);
        __Pyx_GIVEREF(__pyx_v_ndim);
        PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_ndim);
        __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_CArray_s_d, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 170, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_6);
        __pyx_t_6 = 0;

        /* "cupy/core/elementwise.pxi":169
 *         else:
 *             t = _get_typename(dtype)
 *             if is_array:             # <<<<<<<<<<<<<<
 *                 t = 'CArray<%s, %d>' % (t, ndim)
 *         ret.append('%s %s%s' % (t,
 */
      }
    }
    __pyx_L5:;

    /* "cupy/core/elementwise.pxi":172
 *                 t = 'CArray<%s, %d>' % (t, ndim)
 *         ret.append('%s %s%s' % (t,
 *                                 '_raw_' if is_array and not p.raw else '',             # <<<<<<<<<<<<<<
 *                                 p.name))
 *     return ', '.join(ret)
 */
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_is_array); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(1, 172, __pyx_L1_error)
    if (__pyx_t_7) {
    } else {
      __pyx_t_8 = __pyx_t_7;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_7 = ((!(__pyx_v_p->raw != 0)) != 0);
    __pyx_t_8 = __pyx_t_7;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_8) {
      __Pyx_INCREF(__pyx_n_s_raw);
      __pyx_t_6 = __pyx_n_s_raw;
    } else {
      __Pyx_INCREF(__pyx_kp_s__5);
      __pyx_t_6 = __pyx_kp_s__5;
    }

    /* "cupy/core/elementwise.pxi":171
 *             if is_array:
 *                 t = 'CArray<%s, %d>' % (t, ndim)
 *         ret.append('%s %s%s' % (t,             # <<<<<<<<<<<<<<
 *                                 '_raw_' if is_array and not p.raw else '',
 *                                 p.name))
 */
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 171, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_t);
    __Pyx_GIVEREF(__pyx_v_t);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_t);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6);
    __Pyx_INCREF(__pyx_v_p->name);
    __Pyx_GIVEREF(__pyx_v_p->name);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_p->name);
    __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s_s_s, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 171, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_t_6); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(1, 171, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }

  /* "cupy/core/elementwise.pxi":174
 *                                 '_raw_' if is_array and not p.raw else '',
 *                                 p.name))
 *     return ', '.join(ret)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = __Pyx_PyString_Join(__pyx_kp_s__71, __pyx_v_ret); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (!(likely(PyString_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_6)->tp_name), 0))) __PYX_ERR(1, 174, __pyx_L1_error)
  __pyx_r = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":158
 * 
 * 
 * cpdef str _get_kernel_params(tuple params, tuple args_info):             # <<<<<<<<<<<<<<
 *     cdef ParameterInfo p
 *     ret = []
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core._get_kernel_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_type);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_ndim);
  __Pyx_XDECREF(__pyx_v_is_array);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_21_get_kernel_params(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_20_get_kernel_params[] = "_get_kernel_params(tuple params, tuple args_info) -> str";
static PyObject *__pyx_pw_4cupy_4core_4core_21_get_kernel_params(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_args_info = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_kernel_params (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_params,&__pyx_n_s_args_info,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_params)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_args_info)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_kernel_params", 1, 2, 2, 1); __PYX_ERR(1, 158, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_kernel_params") < 0)) __PYX_ERR(1, 158, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_params = ((PyObject*)values[0]);
    __pyx_v_args_info = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_kernel_params", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 158, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_kernel_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_params), (&PyTuple_Type), 1, "params", 1))) __PYX_ERR(1, 158, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args_info), (&PyTuple_Type), 1, "args_info", 1))) __PYX_ERR(1, 158, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_20_get_kernel_params(__pyx_self, __pyx_v_params, __pyx_v_args_info);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_20_get_kernel_params(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_params, PyObject *__pyx_v_args_info) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_kernel_params", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_kernel_params(__pyx_v_params, __pyx_v_args_info, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":177
 * 
 * 
 * cpdef tuple _reduce_dims(list args, tuple params, tuple shape):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, j, n, ndim, cnt, axis, s
 *     cdef vector.vector[Py_ssize_t] vecshape, newshape, newstrides
 */

static PyObject *__pyx_pw_4cupy_4core_4core_23_reduce_dims(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__reduce_dims(PyObject *__pyx_v_args, PyObject *__pyx_v_params, PyObject *__pyx_v_shape, CYTHON_UNUSED int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_j;
  Py_ssize_t __pyx_v_n;
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_cnt;
  Py_ssize_t __pyx_v_axis;
  std::vector<Py_ssize_t>  __pyx_v_vecshape;
  std::vector<Py_ssize_t>  __pyx_v_newshape;
  std::vector<Py_ssize_t>  __pyx_v_newstrides;
  std::vector<int>  __pyx_v_is_array_flags;
  std::vector<std::vector<Py_ssize_t> >  __pyx_v_args_strides;
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_p = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr = 0;
  int __pyx_v_flag;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_ret = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  std::vector<Py_ssize_t>  __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides __pyx_t_11;
  int __pyx_t_12;
  __Pyx_RefNannySetupContext("_reduce_dims", 0);

  /* "cupy/core/elementwise.pxi":186
 *     cdef bint flag
 * 
 *     ndim = len(shape)             # <<<<<<<<<<<<<<
 *     if ndim <= 1:
 *         return args, shape
 */
  if (unlikely(__pyx_v_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 186, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 186, __pyx_L1_error)
  __pyx_v_ndim = __pyx_t_1;

  /* "cupy/core/elementwise.pxi":187
 * 
 *     ndim = len(shape)
 *     if ndim <= 1:             # <<<<<<<<<<<<<<
 *         return args, shape
 * 
 */
  __pyx_t_2 = ((__pyx_v_ndim <= 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":188
 *     ndim = len(shape)
 *     if ndim <= 1:
 *         return args, shape             # <<<<<<<<<<<<<<
 * 
 *     n = len(args)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 188, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_args);
    __Pyx_GIVEREF(__pyx_v_args);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_args);
    __Pyx_INCREF(__pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_shape);
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":187
 * 
 *     ndim = len(shape)
 *     if ndim <= 1:             # <<<<<<<<<<<<<<
 *         return args, shape
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":190
 *         return args, shape
 * 
 *     n = len(args)             # <<<<<<<<<<<<<<
 *     for i in range(n):
 *         p = params[i]
 */
  if (unlikely(__pyx_v_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 190, __pyx_L1_error)
  }
  __pyx_t_1 = PyList_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 190, __pyx_L1_error)
  __pyx_v_n = __pyx_t_1;

  /* "cupy/core/elementwise.pxi":191
 * 
 *     n = len(args)
 *     for i in range(n):             # <<<<<<<<<<<<<<
 *         p = params[i]
 *         a = args[i]
 */
  __pyx_t_1 = __pyx_v_n;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_1; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "cupy/core/elementwise.pxi":192
 *     n = len(args)
 *     for i in range(n):
 *         p = params[i]             # <<<<<<<<<<<<<<
 *         a = args[i]
 *         flag = not p.raw and isinstance(a, ndarray)
 */
    if (unlikely(__pyx_v_params == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 192, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_params, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 192, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ParameterInfo))))) __PYX_ERR(1, 192, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_p, ((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":193
 *     for i in range(n):
 *         p = params[i]
 *         a = args[i]             # <<<<<<<<<<<<<<
 *         flag = not p.raw and isinstance(a, ndarray)
 *         is_array_flags.push_back(flag)
 */
    if (unlikely(__pyx_v_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 193, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_args, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 193, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":194
 *         p = params[i]
 *         a = args[i]
 *         flag = not p.raw and isinstance(a, ndarray)             # <<<<<<<<<<<<<<
 *         is_array_flags.push_back(flag)
 *         if flag:
 */
    __pyx_t_5 = ((!(__pyx_v_p->raw != 0)) != 0);
    if (__pyx_t_5) {
    } else {
      __pyx_t_2 = __pyx_t_5;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_6 = (__pyx_t_5 != 0);
    __pyx_t_2 = __pyx_t_6;
    __pyx_L6_bool_binop_done:;
    __pyx_v_flag = __pyx_t_2;

    /* "cupy/core/elementwise.pxi":195
 *         a = args[i]
 *         flag = not p.raw and isinstance(a, ndarray)
 *         is_array_flags.push_back(flag)             # <<<<<<<<<<<<<<
 *         if flag:
 *             arr = a
 */
    try {
      __pyx_v_is_array_flags.push_back(__pyx_v_flag);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(1, 195, __pyx_L1_error)
    }

    /* "cupy/core/elementwise.pxi":196
 *         flag = not p.raw and isinstance(a, ndarray)
 *         is_array_flags.push_back(flag)
 *         if flag:             # <<<<<<<<<<<<<<
 *             arr = a
 *             args_strides.push_back(arr._strides)
 */
    __pyx_t_2 = (__pyx_v_flag != 0);
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":197
 *         is_array_flags.push_back(flag)
 *         if flag:
 *             arr = a             # <<<<<<<<<<<<<<
 *             args_strides.push_back(arr._strides)
 * 
 */
      if (!(likely(((__pyx_v_a) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 197, __pyx_L1_error)
      __pyx_t_3 = __pyx_v_a;
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_XDECREF_SET(__pyx_v_arr, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
      __pyx_t_3 = 0;

      /* "cupy/core/elementwise.pxi":198
 *         if flag:
 *             arr = a
 *             args_strides.push_back(arr._strides)             # <<<<<<<<<<<<<<
 * 
 *     vecshape = shape
 */
      try {
        __pyx_v_args_strides.push_back(__pyx_v_arr->_strides);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(1, 198, __pyx_L1_error)
      }

      /* "cupy/core/elementwise.pxi":196
 *         flag = not p.raw and isinstance(a, ndarray)
 *         is_array_flags.push_back(flag)
 *         if flag:             # <<<<<<<<<<<<<<
 *             arr = a
 *             args_strides.push_back(arr._strides)
 */
    }
  }

  /* "cupy/core/elementwise.pxi":200
 *             args_strides.push_back(arr._strides)
 * 
 *     vecshape = shape             # <<<<<<<<<<<<<<
 *     axis = -1
 *     cnt = 0
 */
  __pyx_t_7 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 200, __pyx_L1_error)
  __pyx_v_vecshape = __pyx_t_7;

  /* "cupy/core/elementwise.pxi":201
 * 
 *     vecshape = shape
 *     axis = -1             # <<<<<<<<<<<<<<
 *     cnt = 0
 *     for i in range(1, ndim):
 */
  __pyx_v_axis = -1L;

  /* "cupy/core/elementwise.pxi":202
 *     vecshape = shape
 *     axis = -1
 *     cnt = 0             # <<<<<<<<<<<<<<
 *     for i in range(1, ndim):
 *         if vecshape[i - 1] == 1:
 */
  __pyx_v_cnt = 0;

  /* "cupy/core/elementwise.pxi":203
 *     axis = -1
 *     cnt = 0
 *     for i in range(1, ndim):             # <<<<<<<<<<<<<<
 *         if vecshape[i - 1] == 1:
 *             continue
 */
  __pyx_t_1 = __pyx_v_ndim;
  for (__pyx_t_4 = 1; __pyx_t_4 < __pyx_t_1; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "cupy/core/elementwise.pxi":204
 *     cnt = 0
 *     for i in range(1, ndim):
 *         if vecshape[i - 1] == 1:             # <<<<<<<<<<<<<<
 *             continue
 *         for j in range(<Py_ssize_t>args_strides.size()):
 */
    __pyx_t_2 = (((__pyx_v_vecshape[(__pyx_v_i - 1)]) == 1) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":205
 *     for i in range(1, ndim):
 *         if vecshape[i - 1] == 1:
 *             continue             # <<<<<<<<<<<<<<
 *         for j in range(<Py_ssize_t>args_strides.size()):
 *             if args_strides[j][i] * vecshape[i] != args_strides[j][i - 1]:
 */
      goto __pyx_L9_continue;

      /* "cupy/core/elementwise.pxi":204
 *     cnt = 0
 *     for i in range(1, ndim):
 *         if vecshape[i - 1] == 1:             # <<<<<<<<<<<<<<
 *             continue
 *         for j in range(<Py_ssize_t>args_strides.size()):
 */
    }

    /* "cupy/core/elementwise.pxi":206
 *         if vecshape[i - 1] == 1:
 *             continue
 *         for j in range(<Py_ssize_t>args_strides.size()):             # <<<<<<<<<<<<<<
 *             if args_strides[j][i] * vecshape[i] != args_strides[j][i - 1]:
 *                 cnt += 1
 */
    __pyx_t_8 = ((Py_ssize_t)__pyx_v_args_strides.size());
    for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
      __pyx_v_j = __pyx_t_9;

      /* "cupy/core/elementwise.pxi":207
 *             continue
 *         for j in range(<Py_ssize_t>args_strides.size()):
 *             if args_strides[j][i] * vecshape[i] != args_strides[j][i - 1]:             # <<<<<<<<<<<<<<
 *                 cnt += 1
 *                 axis = i - 1
 */
      __pyx_t_2 = (((((__pyx_v_args_strides[__pyx_v_j])[__pyx_v_i]) * (__pyx_v_vecshape[__pyx_v_i])) != ((__pyx_v_args_strides[__pyx_v_j])[(__pyx_v_i - 1)])) != 0);
      if (__pyx_t_2) {

        /* "cupy/core/elementwise.pxi":208
 *         for j in range(<Py_ssize_t>args_strides.size()):
 *             if args_strides[j][i] * vecshape[i] != args_strides[j][i - 1]:
 *                 cnt += 1             # <<<<<<<<<<<<<<
 *                 axis = i - 1
 *                 break
 */
        __pyx_v_cnt = (__pyx_v_cnt + 1);

        /* "cupy/core/elementwise.pxi":209
 *             if args_strides[j][i] * vecshape[i] != args_strides[j][i - 1]:
 *                 cnt += 1
 *                 axis = i - 1             # <<<<<<<<<<<<<<
 *                 break
 *         else:
 */
        __pyx_v_axis = (__pyx_v_i - 1);

        /* "cupy/core/elementwise.pxi":210
 *                 cnt += 1
 *                 axis = i - 1
 *                 break             # <<<<<<<<<<<<<<
 *         else:
 *             vecshape[i] *= vecshape[i - 1]
 */
        goto __pyx_L13_break;

        /* "cupy/core/elementwise.pxi":207
 *             continue
 *         for j in range(<Py_ssize_t>args_strides.size()):
 *             if args_strides[j][i] * vecshape[i] != args_strides[j][i - 1]:             # <<<<<<<<<<<<<<
 *                 cnt += 1
 *                 axis = i - 1
 */
      }
    }
    /*else*/ {

      /* "cupy/core/elementwise.pxi":212
 *                 break
 *         else:
 *             vecshape[i] *= vecshape[i - 1]             # <<<<<<<<<<<<<<
 *             vecshape[i - 1] = 1
 *     if vecshape[ndim - 1] != 1:
 */
      __pyx_t_9 = __pyx_v_i;
      (__pyx_v_vecshape[__pyx_t_9]) = ((__pyx_v_vecshape[__pyx_t_9]) * (__pyx_v_vecshape[(__pyx_v_i - 1)]));

      /* "cupy/core/elementwise.pxi":213
 *         else:
 *             vecshape[i] *= vecshape[i - 1]
 *             vecshape[i - 1] = 1             # <<<<<<<<<<<<<<
 *     if vecshape[ndim - 1] != 1:
 *         cnt += 1
 */
      (__pyx_v_vecshape[(__pyx_v_i - 1)]) = 1;
    }
    __pyx_L13_break:;
    __pyx_L9_continue:;
  }

  /* "cupy/core/elementwise.pxi":214
 *             vecshape[i] *= vecshape[i - 1]
 *             vecshape[i - 1] = 1
 *     if vecshape[ndim - 1] != 1:             # <<<<<<<<<<<<<<
 *         cnt += 1
 *         axis = ndim - 1
 */
  __pyx_t_2 = (((__pyx_v_vecshape[(__pyx_v_ndim - 1)]) != 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":215
 *             vecshape[i - 1] = 1
 *     if vecshape[ndim - 1] != 1:
 *         cnt += 1             # <<<<<<<<<<<<<<
 *         axis = ndim - 1
 * 
 */
    __pyx_v_cnt = (__pyx_v_cnt + 1);

    /* "cupy/core/elementwise.pxi":216
 *     if vecshape[ndim - 1] != 1:
 *         cnt += 1
 *         axis = ndim - 1             # <<<<<<<<<<<<<<
 * 
 *     if cnt == ndim:
 */
    __pyx_v_axis = (__pyx_v_ndim - 1);

    /* "cupy/core/elementwise.pxi":214
 *             vecshape[i] *= vecshape[i - 1]
 *             vecshape[i - 1] = 1
 *     if vecshape[ndim - 1] != 1:             # <<<<<<<<<<<<<<
 *         cnt += 1
 *         axis = ndim - 1
 */
  }

  /* "cupy/core/elementwise.pxi":218
 *         axis = ndim - 1
 * 
 *     if cnt == ndim:             # <<<<<<<<<<<<<<
 *         return args, shape
 *     if cnt == 1:
 */
  __pyx_t_2 = ((__pyx_v_cnt == __pyx_v_ndim) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":219
 * 
 *     if cnt == ndim:
 *         return args, shape             # <<<<<<<<<<<<<<
 *     if cnt == 1:
 *         newshape.assign(<Py_ssize_t>1, <Py_ssize_t>vecshape[axis])
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 219, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_args);
    __Pyx_GIVEREF(__pyx_v_args);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_args);
    __Pyx_INCREF(__pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_shape);
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":218
 *         axis = ndim - 1
 * 
 *     if cnt == ndim:             # <<<<<<<<<<<<<<
 *         return args, shape
 *     if cnt == 1:
 */
  }

  /* "cupy/core/elementwise.pxi":220
 *     if cnt == ndim:
 *         return args, shape
 *     if cnt == 1:             # <<<<<<<<<<<<<<
 *         newshape.assign(<Py_ssize_t>1, <Py_ssize_t>vecshape[axis])
 *         ret = []
 */
  __pyx_t_2 = ((__pyx_v_cnt == 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":221
 *         return args, shape
 *     if cnt == 1:
 *         newshape.assign(<Py_ssize_t>1, <Py_ssize_t>vecshape[axis])             # <<<<<<<<<<<<<<
 *         ret = []
 *         for i, a in enumerate(args):
 */
    try {
      __pyx_v_newshape.assign(((Py_ssize_t)1), ((Py_ssize_t)(__pyx_v_vecshape[__pyx_v_axis])));
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(1, 221, __pyx_L1_error)
    }

    /* "cupy/core/elementwise.pxi":222
 *     if cnt == 1:
 *         newshape.assign(<Py_ssize_t>1, <Py_ssize_t>vecshape[axis])
 *         ret = []             # <<<<<<<<<<<<<<
 *         for i, a in enumerate(args):
 *             if is_array_flags[i]:
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 222, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_ret = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":223
 *         newshape.assign(<Py_ssize_t>1, <Py_ssize_t>vecshape[axis])
 *         ret = []
 *         for i, a in enumerate(args):             # <<<<<<<<<<<<<<
 *             if is_array_flags[i]:
 *                 arr = a
 */
    __pyx_t_1 = 0;
    __pyx_t_3 = __pyx_v_args; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_10 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_10); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 223, __pyx_L1_error)
      #else
      __pyx_t_10 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 223, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_10);
      __pyx_t_10 = 0;
      __pyx_v_i = __pyx_t_1;
      __pyx_t_1 = (__pyx_t_1 + 1);

      /* "cupy/core/elementwise.pxi":224
 *         ret = []
 *         for i, a in enumerate(args):
 *             if is_array_flags[i]:             # <<<<<<<<<<<<<<
 *                 arr = a
 *                 arr = arr.view()
 */
      __pyx_t_2 = ((__pyx_v_is_array_flags[__pyx_v_i]) != 0);
      if (__pyx_t_2) {

        /* "cupy/core/elementwise.pxi":225
 *         for i, a in enumerate(args):
 *             if is_array_flags[i]:
 *                 arr = a             # <<<<<<<<<<<<<<
 *                 arr = arr.view()
 *                 newstrides.assign(
 */
        if (!(likely(((__pyx_v_a) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 225, __pyx_L1_error)
        __pyx_t_10 = __pyx_v_a;
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_XDECREF_SET(__pyx_v_arr, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10));
        __pyx_t_10 = 0;

        /* "cupy/core/elementwise.pxi":226
 *             if is_array_flags[i]:
 *                 arr = a
 *                 arr = arr.view()             # <<<<<<<<<<<<<<
 *                 newstrides.assign(
 *                     <Py_ssize_t>1, <Py_ssize_t>arr._strides[axis])
 */
        __pyx_t_10 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_arr->__pyx_vtab)->view(__pyx_v_arr, 0, NULL)); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 226, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF_SET(__pyx_v_arr, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10));
        __pyx_t_10 = 0;

        /* "cupy/core/elementwise.pxi":227
 *                 arr = a
 *                 arr = arr.view()
 *                 newstrides.assign(             # <<<<<<<<<<<<<<
 *                     <Py_ssize_t>1, <Py_ssize_t>arr._strides[axis])
 *                 arr._set_shape_and_strides(newshape, newstrides, False)
 */
        try {
          __pyx_v_newstrides.assign(((Py_ssize_t)1), ((Py_ssize_t)(__pyx_v_arr->_strides[__pyx_v_axis])));
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(1, 227, __pyx_L1_error)
        }

        /* "cupy/core/elementwise.pxi":229
 *                 newstrides.assign(
 *                     <Py_ssize_t>1, <Py_ssize_t>arr._strides[axis])
 *                 arr._set_shape_and_strides(newshape, newstrides, False)             # <<<<<<<<<<<<<<
 *                 a = arr
 *             ret.append(a)
 */
        __pyx_t_11.__pyx_n = 1;
        __pyx_t_11.update_c_contiguity = 0;
        __pyx_t_10 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_arr->__pyx_vtab)->_set_shape_and_strides(__pyx_v_arr, __pyx_v_newshape, __pyx_v_newstrides, 0, &__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 229, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

        /* "cupy/core/elementwise.pxi":230
 *                     <Py_ssize_t>1, <Py_ssize_t>arr._strides[axis])
 *                 arr._set_shape_and_strides(newshape, newstrides, False)
 *                 a = arr             # <<<<<<<<<<<<<<
 *             ret.append(a)
 *         return ret, tuple(newshape)
 */
        __Pyx_INCREF(((PyObject *)__pyx_v_arr));
        __Pyx_DECREF_SET(__pyx_v_a, ((PyObject *)__pyx_v_arr));

        /* "cupy/core/elementwise.pxi":224
 *         ret = []
 *         for i, a in enumerate(args):
 *             if is_array_flags[i]:             # <<<<<<<<<<<<<<
 *                 arr = a
 *                 arr = arr.view()
 */
      }

      /* "cupy/core/elementwise.pxi":231
 *                 arr._set_shape_and_strides(newshape, newstrides, False)
 *                 a = arr
 *             ret.append(a)             # <<<<<<<<<<<<<<
 *         return ret, tuple(newshape)
 * 
 */
      __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_a); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(1, 231, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":223
 *         newshape.assign(<Py_ssize_t>1, <Py_ssize_t>vecshape[axis])
 *         ret = []
 *         for i, a in enumerate(args):             # <<<<<<<<<<<<<<
 *             if is_array_flags[i]:
 *                 arr = a
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":232
 *                 a = arr
 *             ret.append(a)
 *         return ret, tuple(newshape)             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_newshape); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 232, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 232, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 232, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_ret);
    __Pyx_GIVEREF(__pyx_v_ret);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_ret);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":220
 *     if cnt == ndim:
 *         return args, shape
 *     if cnt == 1:             # <<<<<<<<<<<<<<
 *         newshape.assign(<Py_ssize_t>1, <Py_ssize_t>vecshape[axis])
 *         ret = []
 */
  }

  /* "cupy/core/elementwise.pxi":234
 *         return ret, tuple(newshape)
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         if vecshape[i] != 1:
 *             newshape.push_back(vecshape[i])
 */
  __pyx_t_1 = __pyx_v_ndim;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_1; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "cupy/core/elementwise.pxi":235
 * 
 *     for i in range(ndim):
 *         if vecshape[i] != 1:             # <<<<<<<<<<<<<<
 *             newshape.push_back(vecshape[i])
 *     ret = []
 */
    __pyx_t_2 = (((__pyx_v_vecshape[__pyx_v_i]) != 1) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":236
 *     for i in range(ndim):
 *         if vecshape[i] != 1:
 *             newshape.push_back(vecshape[i])             # <<<<<<<<<<<<<<
 *     ret = []
 *     for i, a in enumerate(args):
 */
      try {
        __pyx_v_newshape.push_back((__pyx_v_vecshape[__pyx_v_i]));
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(1, 236, __pyx_L1_error)
      }

      /* "cupy/core/elementwise.pxi":235
 * 
 *     for i in range(ndim):
 *         if vecshape[i] != 1:             # <<<<<<<<<<<<<<
 *             newshape.push_back(vecshape[i])
 *     ret = []
 */
    }
  }

  /* "cupy/core/elementwise.pxi":237
 *         if vecshape[i] != 1:
 *             newshape.push_back(vecshape[i])
 *     ret = []             # <<<<<<<<<<<<<<
 *     for i, a in enumerate(args):
 *         if is_array_flags[i]:
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ret = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":238
 *             newshape.push_back(vecshape[i])
 *     ret = []
 *     for i, a in enumerate(args):             # <<<<<<<<<<<<<<
 *         if is_array_flags[i]:
 *             arr = a
 */
  __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_v_args; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_10 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_10); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 238, __pyx_L1_error)
    #else
    __pyx_t_10 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 238, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_v_i = __pyx_t_1;
    __pyx_t_1 = (__pyx_t_1 + 1);

    /* "cupy/core/elementwise.pxi":239
 *     ret = []
 *     for i, a in enumerate(args):
 *         if is_array_flags[i]:             # <<<<<<<<<<<<<<
 *             arr = a
 *             arr = arr.view()
 */
    __pyx_t_2 = ((__pyx_v_is_array_flags[__pyx_v_i]) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":240
 *     for i, a in enumerate(args):
 *         if is_array_flags[i]:
 *             arr = a             # <<<<<<<<<<<<<<
 *             arr = arr.view()
 *             newstrides.clear()
 */
      if (!(likely(((__pyx_v_a) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 240, __pyx_L1_error)
      __pyx_t_10 = __pyx_v_a;
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_XDECREF_SET(__pyx_v_arr, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10));
      __pyx_t_10 = 0;

      /* "cupy/core/elementwise.pxi":241
 *         if is_array_flags[i]:
 *             arr = a
 *             arr = arr.view()             # <<<<<<<<<<<<<<
 *             newstrides.clear()
 *             for j in range(ndim):
 */
      __pyx_t_10 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_arr->__pyx_vtab)->view(__pyx_v_arr, 0, NULL)); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 241, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF_SET(__pyx_v_arr, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10));
      __pyx_t_10 = 0;

      /* "cupy/core/elementwise.pxi":242
 *             arr = a
 *             arr = arr.view()
 *             newstrides.clear()             # <<<<<<<<<<<<<<
 *             for j in range(ndim):
 *                 if vecshape[j] != 1:
 */
      __pyx_v_newstrides.clear();

      /* "cupy/core/elementwise.pxi":243
 *             arr = arr.view()
 *             newstrides.clear()
 *             for j in range(ndim):             # <<<<<<<<<<<<<<
 *                 if vecshape[j] != 1:
 *                     newstrides.push_back(arr._strides[j])
 */
      __pyx_t_8 = __pyx_v_ndim;
      for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
        __pyx_v_j = __pyx_t_9;

        /* "cupy/core/elementwise.pxi":244
 *             newstrides.clear()
 *             for j in range(ndim):
 *                 if vecshape[j] != 1:             # <<<<<<<<<<<<<<
 *                     newstrides.push_back(arr._strides[j])
 *             arr._set_shape_and_strides(newshape, newstrides, False)
 */
        __pyx_t_2 = (((__pyx_v_vecshape[__pyx_v_j]) != 1) != 0);
        if (__pyx_t_2) {

          /* "cupy/core/elementwise.pxi":245
 *             for j in range(ndim):
 *                 if vecshape[j] != 1:
 *                     newstrides.push_back(arr._strides[j])             # <<<<<<<<<<<<<<
 *             arr._set_shape_and_strides(newshape, newstrides, False)
 *             a = arr
 */
          try {
            __pyx_v_newstrides.push_back((__pyx_v_arr->_strides[__pyx_v_j]));
          } catch(...) {
            __Pyx_CppExn2PyErr();
            __PYX_ERR(1, 245, __pyx_L1_error)
          }

          /* "cupy/core/elementwise.pxi":244
 *             newstrides.clear()
 *             for j in range(ndim):
 *                 if vecshape[j] != 1:             # <<<<<<<<<<<<<<
 *                     newstrides.push_back(arr._strides[j])
 *             arr._set_shape_and_strides(newshape, newstrides, False)
 */
        }
      }

      /* "cupy/core/elementwise.pxi":246
 *                 if vecshape[j] != 1:
 *                     newstrides.push_back(arr._strides[j])
 *             arr._set_shape_and_strides(newshape, newstrides, False)             # <<<<<<<<<<<<<<
 *             a = arr
 *         ret.append(a)
 */
      __pyx_t_11.__pyx_n = 1;
      __pyx_t_11.update_c_contiguity = 0;
      __pyx_t_10 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_arr->__pyx_vtab)->_set_shape_and_strides(__pyx_v_arr, __pyx_v_newshape, __pyx_v_newstrides, 0, &__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 246, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

      /* "cupy/core/elementwise.pxi":247
 *                     newstrides.push_back(arr._strides[j])
 *             arr._set_shape_and_strides(newshape, newstrides, False)
 *             a = arr             # <<<<<<<<<<<<<<
 *         ret.append(a)
 *     return ret, tuple(newshape)
 */
      __Pyx_INCREF(((PyObject *)__pyx_v_arr));
      __Pyx_DECREF_SET(__pyx_v_a, ((PyObject *)__pyx_v_arr));

      /* "cupy/core/elementwise.pxi":239
 *     ret = []
 *     for i, a in enumerate(args):
 *         if is_array_flags[i]:             # <<<<<<<<<<<<<<
 *             arr = a
 *             arr = arr.view()
 */
    }

    /* "cupy/core/elementwise.pxi":248
 *             arr._set_shape_and_strides(newshape, newstrides, False)
 *             a = arr
 *         ret.append(a)             # <<<<<<<<<<<<<<
 *     return ret, tuple(newshape)
 * 
 */
    __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_a); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(1, 248, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":238
 *             newshape.push_back(vecshape[i])
 *     ret = []
 *     for i, a in enumerate(args):             # <<<<<<<<<<<<<<
 *         if is_array_flags[i]:
 *             arr = a
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":249
 *             a = arr
 *         ret.append(a)
 *     return ret, tuple(newshape)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_newshape); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_10 = PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_ret);
  __Pyx_GIVEREF(__pyx_v_ret);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_ret);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_10);
  __pyx_t_10 = 0;
  __pyx_r = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":177
 * 
 * 
 * cpdef tuple _reduce_dims(list args, tuple params, tuple shape):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, j, n, ndim, cnt, axis, s
 *     cdef vector.vector[Py_ssize_t] vecshape, newshape, newstrides
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cupy.core.core._reduce_dims", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_p);
  __Pyx_XDECREF((PyObject *)__pyx_v_arr);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_23_reduce_dims(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_22_reduce_dims[] = "_reduce_dims(list args, tuple params, tuple shape) -> tuple";
static PyObject *__pyx_pw_4cupy_4core_4core_23_reduce_dims(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_reduce_dims (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_args,&__pyx_n_s_params,&__pyx_n_s_shape,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_reduce_dims", 1, 3, 3, 1); __PYX_ERR(1, 177, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_reduce_dims", 1, 3, 3, 2); __PYX_ERR(1, 177, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_reduce_dims") < 0)) __PYX_ERR(1, 177, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_args = ((PyObject*)values[0]);
    __pyx_v_params = ((PyObject*)values[1]);
    __pyx_v_shape = ((PyObject*)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_reduce_dims", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 177, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._reduce_dims", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args), (&PyList_Type), 1, "args", 1))) __PYX_ERR(1, 177, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_params), (&PyTuple_Type), 1, "params", 1))) __PYX_ERR(1, 177, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(1, 177, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_22_reduce_dims(__pyx_self, __pyx_v_args, __pyx_v_params, __pyx_v_shape);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_22_reduce_dims(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args, PyObject *__pyx_v_params, PyObject *__pyx_v_shape) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_reduce_dims", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__reduce_dims(__pyx_v_args, __pyx_v_params, __pyx_v_shape, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":260
 *         readonly bint is_const
 * 
 *     def __init__(self, str param, bint is_const):             # <<<<<<<<<<<<<<
 *         self.name = None
 *         self.dtype = None
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_13ParameterInfo_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_4core_4core_13ParameterInfo_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_param = 0;
  int __pyx_v_is_const;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_param,&__pyx_n_s_is_const,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_param)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_is_const)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(1, 260, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(1, 260, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_param = ((PyObject*)values[0]);
    __pyx_v_is_const = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_is_const == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 260, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 260, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ParameterInfo.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_param), (&PyString_Type), 1, "param", 1))) __PYX_ERR(1, 260, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_13ParameterInfo___init__(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v_self), __pyx_v_param, __pyx_v_is_const);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_13ParameterInfo___init__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self, PyObject *__pyx_v_param, int __pyx_v_is_const) {
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_i = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/elementwise.pxi":261
 * 
 *     def __init__(self, str param, bint is_const):
 *         self.name = None             # <<<<<<<<<<<<<<
 *         self.dtype = None
 *         self.ctype = None
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(__pyx_v_self->name);
  __pyx_v_self->name = ((PyObject*)Py_None);

  /* "cupy/core/elementwise.pxi":262
 *     def __init__(self, str param, bint is_const):
 *         self.name = None
 *         self.dtype = None             # <<<<<<<<<<<<<<
 *         self.ctype = None
 *         self.raw = False
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->dtype);
  __Pyx_DECREF(__pyx_v_self->dtype);
  __pyx_v_self->dtype = Py_None;

  /* "cupy/core/elementwise.pxi":263
 *         self.name = None
 *         self.dtype = None
 *         self.ctype = None             # <<<<<<<<<<<<<<
 *         self.raw = False
 *         self.is_const = is_const
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->ctype);
  __Pyx_DECREF(__pyx_v_self->ctype);
  __pyx_v_self->ctype = ((PyObject*)Py_None);

  /* "cupy/core/elementwise.pxi":264
 *         self.dtype = None
 *         self.ctype = None
 *         self.raw = False             # <<<<<<<<<<<<<<
 *         self.is_const = is_const
 *         s = tuple([i for i in param.split() if len(i) != 0])
 */
  __pyx_v_self->raw = 0;

  /* "cupy/core/elementwise.pxi":265
 *         self.ctype = None
 *         self.raw = False
 *         self.is_const = is_const             # <<<<<<<<<<<<<<
 *         s = tuple([i for i in param.split() if len(i) != 0])
 *         if len(s) < 2:
 */
  __pyx_v_self->is_const = __pyx_v_is_const;

  /* "cupy/core/elementwise.pxi":266
 *         self.raw = False
 *         self.is_const = is_const
 *         s = tuple([i for i in param.split() if len(i) != 0])             # <<<<<<<<<<<<<<
 *         if len(s) < 2:
 *             raise Exception('Syntax error: %s' % param)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_param, __pyx_n_s_split); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 266, __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_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 266, __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(1, 266, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 266, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 266, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 266, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 266, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 266, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 266, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_6(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 266, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_7 = PyObject_Length(__pyx_v_i); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(1, 266, __pyx_L1_error)
    __pyx_t_8 = ((__pyx_t_7 != 0) != 0);
    if (__pyx_t_8) {
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_v_i))) __PYX_ERR(1, 266, __pyx_L1_error)
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_s = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":267
 *         self.is_const = is_const
 *         s = tuple([i for i in param.split() if len(i) != 0])
 *         if len(s) < 2:             # <<<<<<<<<<<<<<
 *             raise Exception('Syntax error: %s' % param)
 * 
 */
  __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v_s); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(1, 267, __pyx_L1_error)
  __pyx_t_8 = ((__pyx_t_5 < 2) != 0);
  if (__pyx_t_8) {

    /* "cupy/core/elementwise.pxi":268
 *         s = tuple([i for i in param.split() if len(i) != 0])
 *         if len(s) < 2:
 *             raise Exception('Syntax error: %s' % param)             # <<<<<<<<<<<<<<
 * 
 *         t, self.name = s[-2:]
 */
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Syntax_error_s, __pyx_v_param); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 268, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":267
 *         self.is_const = is_const
 *         s = tuple([i for i in param.split() if len(i) != 0])
 *         if len(s) < 2:             # <<<<<<<<<<<<<<
 *             raise Exception('Syntax error: %s' % param)
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":270
 *             raise Exception('Syntax error: %s' % param)
 * 
 *         t, self.name = s[-2:]             # <<<<<<<<<<<<<<
 *         if t == 'CIndexer':
 *             pass
 */
  __pyx_t_3 = __Pyx_PyTuple_GetSlice(__pyx_v_s, -2L, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (1) {
    PyObject* sequence = __pyx_t_3;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(1, 270, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 270, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 270, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(1, 270, __pyx_L1_error)
  __pyx_v_t = __pyx_t_1;
  __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(__pyx_v_self->name);
  __pyx_v_self->name = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":271
 * 
 *         t, self.name = s[-2:]
 *         if t == 'CIndexer':             # <<<<<<<<<<<<<<
 *             pass
 *         elif len(t) == 1:
 */
  __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_t, __pyx_n_s_CIndexer, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 271, __pyx_L1_error)
  if (__pyx_t_8) {
    goto __pyx_L7;
  }

  /* "cupy/core/elementwise.pxi":273
 *         if t == 'CIndexer':
 *             pass
 *         elif len(t) == 1:             # <<<<<<<<<<<<<<
 *             self.ctype = t
 *         else:
 */
  __pyx_t_5 = PyObject_Length(__pyx_v_t); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(1, 273, __pyx_L1_error)
  __pyx_t_8 = ((__pyx_t_5 == 1) != 0);
  if (__pyx_t_8) {

    /* "cupy/core/elementwise.pxi":274
 *             pass
 *         elif len(t) == 1:
 *             self.ctype = t             # <<<<<<<<<<<<<<
 *         else:
 *             dtype = numpy.dtype(t)
 */
    if (!(likely(PyString_CheckExact(__pyx_v_t))||((__pyx_v_t) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_t)->tp_name), 0))) __PYX_ERR(1, 274, __pyx_L1_error)
    __pyx_t_3 = __pyx_v_t;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->ctype);
    __Pyx_DECREF(__pyx_v_self->ctype);
    __pyx_v_self->ctype = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":273
 *         if t == 'CIndexer':
 *             pass
 *         elif len(t) == 1:             # <<<<<<<<<<<<<<
 *             self.ctype = t
 *         else:
 */
    goto __pyx_L7;
  }

  /* "cupy/core/elementwise.pxi":276
 *             self.ctype = t
 *         else:
 *             dtype = numpy.dtype(t)             # <<<<<<<<<<<<<<
 *             self.dtype = dtype.type
 *             if dtype.name != t:
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    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);
      }
    }
    if (!__pyx_t_2) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 276, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_t};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 276, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_t};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 276, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 276, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
        __Pyx_INCREF(__pyx_v_t);
        __Pyx_GIVEREF(__pyx_v_t);
        PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_t);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 276, __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_v_dtype = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":277
 *         else:
 *             dtype = numpy.dtype(t)
 *             self.dtype = dtype.type             # <<<<<<<<<<<<<<
 *             if dtype.name != t:
 *                 raise ValueError('Wrong type %s' % t)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 277, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->dtype);
    __Pyx_DECREF(__pyx_v_self->dtype);
    __pyx_v_self->dtype = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":278
 *             dtype = numpy.dtype(t)
 *             self.dtype = dtype.type
 *             if dtype.name != t:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Wrong type %s' % t)
 *             self.ctype = _get_typename(self.dtype)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_v_t, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 278, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 278, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_8) {

      /* "cupy/core/elementwise.pxi":279
 *             self.dtype = dtype.type
 *             if dtype.name != t:
 *                 raise ValueError('Wrong type %s' % t)             # <<<<<<<<<<<<<<
 *             self.ctype = _get_typename(self.dtype)
 * 
 */
      __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_type_s, __pyx_v_t); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 279, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 279, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 279, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(1, 279, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":278
 *             dtype = numpy.dtype(t)
 *             self.dtype = dtype.type
 *             if dtype.name != t:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Wrong type %s' % t)
 *             self.ctype = _get_typename(self.dtype)
 */
    }

    /* "cupy/core/elementwise.pxi":280
 *             if dtype.name != t:
 *                 raise ValueError('Wrong type %s' % t)
 *             self.ctype = _get_typename(self.dtype)             # <<<<<<<<<<<<<<
 * 
 *         for i in s[:-2]:
 */
    __pyx_t_1 = __pyx_v_self->dtype;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_3 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_t_1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 280, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->ctype);
    __Pyx_DECREF(__pyx_v_self->ctype);
    __pyx_v_self->ctype = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L7:;

  /* "cupy/core/elementwise.pxi":282
 *             self.ctype = _get_typename(self.dtype)
 * 
 *         for i in s[:-2]:             # <<<<<<<<<<<<<<
 *             if i == 'raw':
 *                 self.raw = True
 */
  __pyx_t_3 = __Pyx_PyTuple_GetSlice(__pyx_v_s, 0, -2L); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 282, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 282, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":283
 * 
 *         for i in s[:-2]:
 *             if i == 'raw':             # <<<<<<<<<<<<<<
 *                 self.raw = True
 *             else:
 */
    __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_i, __pyx_n_s_raw_2, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 283, __pyx_L1_error)
    if (__pyx_t_8) {

      /* "cupy/core/elementwise.pxi":284
 *         for i in s[:-2]:
 *             if i == 'raw':
 *                 self.raw = True             # <<<<<<<<<<<<<<
 *             else:
 *                 raise Exception('Unknown keyword "%s"' % i)
 */
      __pyx_v_self->raw = 1;

      /* "cupy/core/elementwise.pxi":283
 * 
 *         for i in s[:-2]:
 *             if i == 'raw':             # <<<<<<<<<<<<<<
 *                 self.raw = True
 *             else:
 */
      goto __pyx_L11;
    }

    /* "cupy/core/elementwise.pxi":286
 *                 self.raw = True
 *             else:
 *                 raise Exception('Unknown keyword "%s"' % i)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Unknown_keyword_s, __pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 286, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 286, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 286, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(1, 286, __pyx_L1_error)
    }
    __pyx_L11:;

    /* "cupy/core/elementwise.pxi":282
 *             self.ctype = _get_typename(self.dtype)
 * 
 *         for i in s[:-2]:             # <<<<<<<<<<<<<<
 *             if i == 'raw':
 *                 self.raw = True
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":260
 *         readonly bint is_const
 * 
 *     def __init__(self, str param, bint is_const):             # <<<<<<<<<<<<<<
 *         self.name = None
 *         self.dtype = None
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.ParameterInfo.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":254
 * cdef class ParameterInfo:
 *     cdef:
 *         readonly str name             # <<<<<<<<<<<<<<
 *         readonly object dtype
 *         readonly str ctype
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_4name_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_4name_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_13ParameterInfo_4name___get__(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_4name___get__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->name);
  __pyx_r = __pyx_v_self->name;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":255
 *     cdef:
 *         readonly str name
 *         readonly object dtype             # <<<<<<<<<<<<<<
 *         readonly str ctype
 *         readonly bint raw
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_5dtype_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_5dtype_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_13ParameterInfo_5dtype___get__(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_5dtype___get__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->dtype);
  __pyx_r = __pyx_v_self->dtype;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":256
 *         readonly str name
 *         readonly object dtype
 *         readonly str ctype             # <<<<<<<<<<<<<<
 *         readonly bint raw
 *         readonly bint is_const
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_5ctype_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_5ctype_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_13ParameterInfo_5ctype___get__(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_5ctype___get__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->ctype);
  __pyx_r = __pyx_v_self->ctype;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":257
 *         readonly object dtype
 *         readonly str ctype
 *         readonly bint raw             # <<<<<<<<<<<<<<
 *         readonly bint is_const
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_3raw_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_3raw_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_13ParameterInfo_3raw___get__(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_3raw___get__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->raw); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":258
 *         readonly str ctype
 *         readonly bint raw
 *         readonly bint is_const             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, str param, bint is_const):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_8is_const_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_8is_const_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_13ParameterInfo_8is_const___get__(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_8is_const___get__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->is_const); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.ctype, self.dtype, self.is_const, self.name, self.raw)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_13ParameterInfo_2__reduce_cython__[] = "ParameterInfo.__reduce_cython__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_13ParameterInfo_2__reduce_cython__(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_2__reduce_cython__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.ctype, self.dtype, self.is_const, self.name, self.raw)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->is_const); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->raw); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_self->ctype);
  __Pyx_GIVEREF(__pyx_v_self->ctype);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->ctype);
  __Pyx_INCREF(__pyx_v_self->dtype);
  __Pyx_GIVEREF(__pyx_v_self->dtype);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->dtype);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->name);
  __Pyx_GIVEREF(__pyx_v_self->name);
  PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_self->name);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.ctype, self.dtype, self.is_const, self.name, self.raw)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v__dict = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":5
 *     state = (self.ctype, self.dtype, self.is_const, self.name, self.raw)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_4 = (__pyx_v__dict != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict);
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.ctype is not None or self.dtype is not None or self.name is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.ctype, self.dtype, self.is_const, self.name, self.raw)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.ctype is not None or self.dtype is not None or self.name is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, None), state
 */
  /*else*/ {
    __pyx_t_4 = (__pyx_v_self->ctype != ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->dtype != Py_None);
    __pyx_t_4 = (__pyx_t_6 != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_4 = (__pyx_v_self->name != ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_4 != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_5;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.ctype is not None or self.dtype is not None or self.name is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, None), state
 *     else:
 */
  __pyx_t_5 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":11
 *         use_setstate = self.ctype is not None or self.dtype is not None or self.name is not None
 *     if use_setstate:
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_ParameterInfo); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_121017544);
    __Pyx_GIVEREF(__pyx_int_121017544);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_121017544);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.ctype is not None or self.dtype is not None or self.name is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, None), state
 *     else:
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ParameterInfo__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_ParameterInfo); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_121017544);
    __Pyx_GIVEREF(__pyx_int_121017544);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_121017544);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.ctype, self.dtype, self.is_const, self.name, self.raw)
 */

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

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ParameterInfo__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4cupy_4core_4core_13ParameterInfo_4__setstate_cython__[] = "ParameterInfo.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_13ParameterInfo_4__setstate_cython__(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_4__setstate_cython__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":15
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ParameterInfo__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(4, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core___pyx_unpickle_ParameterInfo__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ParameterInfo__set_state(self, __pyx_state)
 */

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

/* "cupy/core/elementwise.pxi":290
 * 
 * @util.memoize()
 * def _get_param_info(s, is_const):             # <<<<<<<<<<<<<<
 *     if len(s) == 0:
 *         return ()
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_25_get_param_info(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_24_get_param_info[] = "_get_param_info(s, is_const)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_25_get_param_info = {"_get_param_info", (PyCFunction)__pyx_pw_4cupy_4core_4core_25_get_param_info, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_24_get_param_info};
static PyObject *__pyx_pw_4cupy_4core_4core_25_get_param_info(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_s = 0;
  PyObject *__pyx_v_is_const = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_param_info (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_s_2,&__pyx_n_s_is_const,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_s_2)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_is_const)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_param_info", 1, 2, 2, 1); __PYX_ERR(1, 290, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_param_info") < 0)) __PYX_ERR(1, 290, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_s = values[0];
    __pyx_v_is_const = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_param_info", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 290, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_param_info", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_24_get_param_info(__pyx_self, __pyx_v_s, __pyx_v_is_const);

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

static PyObject *__pyx_pf_4cupy_4core_4core_24_get_param_info(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_s, PyObject *__pyx_v_is_const) {
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  __Pyx_RefNannySetupContext("_get_param_info", 0);

  /* "cupy/core/elementwise.pxi":291
 * @util.memoize()
 * def _get_param_info(s, is_const):
 *     if len(s) == 0:             # <<<<<<<<<<<<<<
 *         return ()
 *     return tuple([ParameterInfo(i, is_const) for i in s.strip().split(',')])
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 291, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_1 == 0) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":292
 * def _get_param_info(s, is_const):
 *     if len(s) == 0:
 *         return ()             # <<<<<<<<<<<<<<
 *     return tuple([ParameterInfo(i, is_const) for i in s.strip().split(',')])
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_r = __pyx_empty_tuple;
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":291
 * @util.memoize()
 * def _get_param_info(s, is_const):
 *     if len(s) == 0:             # <<<<<<<<<<<<<<
 *         return ()
 *     return tuple([ParameterInfo(i, is_const) for i in s.strip().split(',')])
 */
  }

  /* "cupy/core/elementwise.pxi":293
 *     if len(s) == 0:
 *         return ()
 *     return tuple([ParameterInfo(i, is_const) for i in s.strip().split(',')])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_strip); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_6) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 293, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 293, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_split); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__73, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_1 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 293, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(1, 293, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 293, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(1, 293, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 293, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_7(__pyx_t_5);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 293, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_i);
    __Pyx_INCREF(__pyx_v_is_const);
    __Pyx_GIVEREF(__pyx_v_is_const);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_is_const);
    __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ParameterInfo), __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_6))) __PYX_ERR(1, 293, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":290
 * 
 * @util.memoize()
 * def _get_param_info(s, is_const):             # <<<<<<<<<<<<<<
 *     if len(s) == 0:
 *         return ()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core._get_param_info", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":297
 * 
 * @util.memoize()
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):             # <<<<<<<<<<<<<<
 *     type_dict = {}
 *     if out_args_dtype:
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_27_decide_params_type(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_26_decide_params_type[] = "_decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_27_decide_params_type = {"_decide_params_type", (PyCFunction)__pyx_pw_4cupy_4core_4core_27_decide_params_type, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_26_decide_params_type};
static PyObject *__pyx_pw_4cupy_4core_4core_27_decide_params_type(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_in_params = 0;
  PyObject *__pyx_v_out_params = 0;
  PyObject *__pyx_v_in_args_dtype = 0;
  PyObject *__pyx_v_out_args_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_decide_params_type (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_in_params,&__pyx_n_s_out_params,&__pyx_n_s_in_args_dtype,&__pyx_n_s_out_args_dtype,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_in_params)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_decide_params_type", 1, 4, 4, 1); __PYX_ERR(1, 297, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_in_args_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_decide_params_type", 1, 4, 4, 2); __PYX_ERR(1, 297, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out_args_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_decide_params_type", 1, 4, 4, 3); __PYX_ERR(1, 297, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_decide_params_type") < 0)) __PYX_ERR(1, 297, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_in_params = values[0];
    __pyx_v_out_params = values[1];
    __pyx_v_in_args_dtype = values[2];
    __pyx_v_out_args_dtype = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_decide_params_type", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 297, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._decide_params_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_26_decide_params_type(__pyx_self, __pyx_v_in_params, __pyx_v_out_params, __pyx_v_in_args_dtype, __pyx_v_out_args_dtype);

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

static PyObject *__pyx_pf_4cupy_4core_4core_26_decide_params_type(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_in_params, PyObject *__pyx_v_out_params, PyObject *__pyx_v_in_args_dtype, PyObject *__pyx_v_out_args_dtype) {
  PyObject *__pyx_v_type_dict = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_unknown_ctype = NULL;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  __Pyx_RefNannySetupContext("_decide_params_type", 0);

  /* "cupy/core/elementwise.pxi":298
 * @util.memoize()
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):
 *     type_dict = {}             # <<<<<<<<<<<<<<
 *     if out_args_dtype:
 *         assert len(out_params) == len(out_args_dtype)
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_type_dict = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":299
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):
 *     type_dict = {}
 *     if out_args_dtype:             # <<<<<<<<<<<<<<
 *         assert len(out_params) == len(out_args_dtype)
 *         for p, a in zip(out_params, out_args_dtype):
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_out_args_dtype); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 299, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":300
 *     type_dict = {}
 *     if out_args_dtype:
 *         assert len(out_params) == len(out_args_dtype)             # <<<<<<<<<<<<<<
 *         for p, a in zip(out_params, out_args_dtype):
 *             if a is None:
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_3 = PyObject_Length(__pyx_v_out_params); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(1, 300, __pyx_L1_error)
      __pyx_t_4 = PyObject_Length(__pyx_v_out_args_dtype); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 300, __pyx_L1_error)
      if (unlikely(!((__pyx_t_3 == __pyx_t_4) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        __PYX_ERR(1, 300, __pyx_L1_error)
      }
    }
    #endif

    /* "cupy/core/elementwise.pxi":301
 *     if out_args_dtype:
 *         assert len(out_params) == len(out_args_dtype)
 *         for p, a in zip(out_params, out_args_dtype):             # <<<<<<<<<<<<<<
 *             if a is None:
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 */
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 301, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_out_params);
    __Pyx_GIVEREF(__pyx_v_out_params);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_out_params);
    __Pyx_INCREF(__pyx_v_out_args_dtype);
    __Pyx_GIVEREF(__pyx_v_out_args_dtype);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_out_args_dtype);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 301, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
      __pyx_t_1 = __pyx_t_5; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 301, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 301, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 301, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 301, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 301, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 301, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        }
      } else {
        __pyx_t_5 = __pyx_t_6(__pyx_t_1);
        if (unlikely(!__pyx_t_5)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(1, 301, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
        PyObject* sequence = __pyx_t_5;
        #if !CYTHON_COMPILING_IN_PYPY
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(1, 301, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        #else
        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 301, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 301, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 301, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
        index = 0; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_8);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(1, 301, __pyx_L1_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(1, 301, __pyx_L1_error)
        __pyx_L7_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_7);
      __pyx_t_7 = 0;
      __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "cupy/core/elementwise.pxi":302
 *         assert len(out_params) == len(out_args_dtype)
 *         for p, a in zip(out_params, out_args_dtype):
 *             if a is None:             # <<<<<<<<<<<<<<
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 *             if p.dtype is not None:
 */
      __pyx_t_2 = (__pyx_v_a == Py_None);
      __pyx_t_11 = (__pyx_t_2 != 0);
      if (__pyx_t_11) {

        /* "cupy/core/elementwise.pxi":303
 *         for p, a in zip(out_params, out_args_dtype):
 *             if a is None:
 *                 raise TypeError('Output arguments must be cupy.ndarray')             # <<<<<<<<<<<<<<
 *             if p.dtype is not None:
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):
 */
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__74, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 303, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_Raise(__pyx_t_5, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __PYX_ERR(1, 303, __pyx_L1_error)

        /* "cupy/core/elementwise.pxi":302
 *         assert len(out_params) == len(out_args_dtype)
 *         for p, a in zip(out_params, out_args_dtype):
 *             if a is None:             # <<<<<<<<<<<<<<
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 *             if p.dtype is not None:
 */
      }

      /* "cupy/core/elementwise.pxi":304
 *             if a is None:
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 *             if p.dtype is not None:             # <<<<<<<<<<<<<<
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):
 *                     raise TypeError(
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 304, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_11 = (__pyx_t_5 != Py_None);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_2 = (__pyx_t_11 != 0);
      if (__pyx_t_2) {

        /* "cupy/core/elementwise.pxi":305
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 *             if p.dtype is not None:
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 */
        __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 305, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 305, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = NULL;
        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);
          }
        }
        if (!__pyx_t_8) {
          __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_a); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 305, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_7)) {
            PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_a};
            __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 305, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_GOTREF(__pyx_t_5);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
            PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_a};
            __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 305, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_GOTREF(__pyx_t_5);
          } else
          #endif
          {
            __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 305, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
            __Pyx_INCREF(__pyx_v_a);
            __Pyx_GIVEREF(__pyx_v_a);
            PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_a);
            __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 305, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 305, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 305, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 305, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_12 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
          }
        }
        if (!__pyx_t_12) {
          __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 305, __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_12, __pyx_t_9};
            __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 305, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 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_12, __pyx_t_9};
            __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 305, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          } else
          #endif
          {
            __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 305, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
            __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+1, __pyx_t_9);
            __pyx_t_9 = 0;
            __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_13, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 305, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, __pyx_t_7, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 305, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 305, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (__pyx_t_2) {

          /* "cupy/core/elementwise.pxi":307
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))             # <<<<<<<<<<<<<<
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]
 */
          __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 307, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 307, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 307, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8);
          __Pyx_INCREF(__pyx_v_a);
          __Pyx_GIVEREF(__pyx_v_a);
          PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_a);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_7);
          __pyx_t_8 = 0;
          __pyx_t_7 = 0;
          __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Type_is_mismatched_s_s_s, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 307, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "cupy/core/elementwise.pxi":306
 *             if p.dtype is not None:
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):
 *                     raise TypeError(             # <<<<<<<<<<<<<<
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:
 */
          __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 306, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7);
          __pyx_t_7 = 0;
          __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 306, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_Raise(__pyx_t_7, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __PYX_ERR(1, 306, __pyx_L1_error)

          /* "cupy/core/elementwise.pxi":305
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 *             if p.dtype is not None:
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 */
        }

        /* "cupy/core/elementwise.pxi":304
 *             if a is None:
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 *             if p.dtype is not None:             # <<<<<<<<<<<<<<
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):
 *                     raise TypeError(
 */
        goto __pyx_L9;
      }

      /* "cupy/core/elementwise.pxi":308
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:             # <<<<<<<<<<<<<<
 *                 t = type_dict[p.ctype]
 *                 if numpy.dtype(t) != numpy.dtype(a):
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 308, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_t_7, __pyx_v_type_dict, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 308, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_11 = (__pyx_t_2 != 0);
      if (__pyx_t_11) {

        /* "cupy/core/elementwise.pxi":309
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]             # <<<<<<<<<<<<<<
 *                 if numpy.dtype(t) != numpy.dtype(a):
 *                     raise TypeError(
 */
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 309, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_type_dict, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 309, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_5);
        __pyx_t_5 = 0;

        /* "cupy/core/elementwise.pxi":310
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]
 *                 if numpy.dtype(t) != numpy.dtype(a):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (
 */
        __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 310, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 310, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_7)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
          }
        }
        if (!__pyx_t_7) {
          __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_t); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 310, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_8)) {
            PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_t};
            __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 310, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_GOTREF(__pyx_t_5);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
            PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_t};
            __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 310, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_GOTREF(__pyx_t_5);
          } else
          #endif
          {
            __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 310, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_7); __pyx_t_7 = NULL;
            __Pyx_INCREF(__pyx_v_t);
            __Pyx_GIVEREF(__pyx_v_t);
            PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_v_t);
            __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_13, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 310, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 310, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 310, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_13 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_7);
          if (likely(__pyx_t_13)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_7, function);
          }
        }
        if (!__pyx_t_13) {
          __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_a); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 310, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_7)) {
            PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_v_a};
            __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 310, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_GOTREF(__pyx_t_8);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
            PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_v_a};
            __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 310, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_GOTREF(__pyx_t_8);
          } else
          #endif
          {
            __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 310, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_13); __pyx_t_13 = NULL;
            __Pyx_INCREF(__pyx_v_a);
            __Pyx_GIVEREF(__pyx_v_a);
            PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_a);
            __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 310, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = PyObject_RichCompare(__pyx_t_5, __pyx_t_8, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 310, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(1, 310, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (__pyx_t_11) {

          /* "cupy/core/elementwise.pxi":313
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (
 *                             p.name, a, t, p.ctype))             # <<<<<<<<<<<<<<
 *             else:
 *                 type_dict[p.ctype] = a
 */
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 313, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 313, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 313, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7);
          __Pyx_INCREF(__pyx_v_a);
          __Pyx_GIVEREF(__pyx_v_a);
          PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_a);
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_t);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_8);
          __pyx_t_7 = 0;
          __pyx_t_8 = 0;

          /* "cupy/core/elementwise.pxi":312
 *                 if numpy.dtype(t) != numpy.dtype(a):
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (             # <<<<<<<<<<<<<<
 *                             p.name, a, t, p.ctype))
 *             else:
 */
          __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_Type_is_mismatched_s_s_s_s, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 312, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "cupy/core/elementwise.pxi":311
 *                 t = type_dict[p.ctype]
 *                 if numpy.dtype(t) != numpy.dtype(a):
 *                     raise TypeError(             # <<<<<<<<<<<<<<
 *                         'Type is mismatched. %s %s %s %s' % (
 *                             p.name, a, t, p.ctype))
 */
          __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 311, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8);
          __pyx_t_8 = 0;
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 311, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_Raise(__pyx_t_8, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __PYX_ERR(1, 311, __pyx_L1_error)

          /* "cupy/core/elementwise.pxi":310
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]
 *                 if numpy.dtype(t) != numpy.dtype(a):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (
 */
        }

        /* "cupy/core/elementwise.pxi":308
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:             # <<<<<<<<<<<<<<
 *                 t = type_dict[p.ctype]
 *                 if numpy.dtype(t) != numpy.dtype(a):
 */
        goto __pyx_L9;
      }

      /* "cupy/core/elementwise.pxi":315
 *                             p.name, a, t, p.ctype))
 *             else:
 *                 type_dict[p.ctype] = a             # <<<<<<<<<<<<<<
 * 
 *     assert len(in_params) == len(in_args_dtype)
 */
      /*else*/ {
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 315, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        if (unlikely(PyDict_SetItem(__pyx_v_type_dict, __pyx_t_8, __pyx_v_a) < 0)) __PYX_ERR(1, 315, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __pyx_L9:;

      /* "cupy/core/elementwise.pxi":301
 *     if out_args_dtype:
 *         assert len(out_params) == len(out_args_dtype)
 *         for p, a in zip(out_params, out_args_dtype):             # <<<<<<<<<<<<<<
 *             if a is None:
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":299
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):
 *     type_dict = {}
 *     if out_args_dtype:             # <<<<<<<<<<<<<<
 *         assert len(out_params) == len(out_args_dtype)
 *         for p, a in zip(out_params, out_args_dtype):
 */
  }

  /* "cupy/core/elementwise.pxi":317
 *                 type_dict[p.ctype] = a
 * 
 *     assert len(in_params) == len(in_args_dtype)             # <<<<<<<<<<<<<<
 *     unknown_ctype = []
 *     for p, a in zip(in_params, in_args_dtype):
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_4 = PyObject_Length(__pyx_v_in_params); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 317, __pyx_L1_error)
    __pyx_t_3 = PyObject_Length(__pyx_v_in_args_dtype); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(1, 317, __pyx_L1_error)
    if (unlikely(!((__pyx_t_4 == __pyx_t_3) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(1, 317, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/core/elementwise.pxi":318
 * 
 *     assert len(in_params) == len(in_args_dtype)
 *     unknown_ctype = []             # <<<<<<<<<<<<<<
 *     for p, a in zip(in_params, in_args_dtype):
 *         if a is None:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_unknown_ctype = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":319
 *     assert len(in_params) == len(in_args_dtype)
 *     unknown_ctype = []
 *     for p, a in zip(in_params, in_args_dtype):             # <<<<<<<<<<<<<<
 *         if a is None:
 *             if p.dtype is None:
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_in_params);
  __Pyx_GIVEREF(__pyx_v_in_params);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_in_params);
  __Pyx_INCREF(__pyx_v_in_args_dtype);
  __Pyx_GIVEREF(__pyx_v_in_args_dtype);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_in_args_dtype);
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_8)) || PyTuple_CheckExact(__pyx_t_8)) {
    __pyx_t_1 = __pyx_t_8; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 319, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 319, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_8 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_8); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 319, __pyx_L1_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 319, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_8); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 319, __pyx_L1_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 319, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      }
    } else {
      __pyx_t_8 = __pyx_t_6(__pyx_t_1);
      if (unlikely(!__pyx_t_8)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 319, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_8);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
      PyObject* sequence = __pyx_t_8;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(1, 319, __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_7 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 319, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 319, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_9 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 319, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_5)) goto __pyx_L14_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L14_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(1, 319, __pyx_L1_error)
      __pyx_t_10 = NULL;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L15_unpacking_done;
      __pyx_L14_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_10 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(1, 319, __pyx_L1_error)
      __pyx_L15_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":320
 *     unknown_ctype = []
 *     for p, a in zip(in_params, in_args_dtype):
 *         if a is None:             # <<<<<<<<<<<<<<
 *             if p.dtype is None:
 *                 unknown_ctype.append(p.ctype)
 */
    __pyx_t_11 = (__pyx_v_a == Py_None);
    __pyx_t_2 = (__pyx_t_11 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":321
 *     for p, a in zip(in_params, in_args_dtype):
 *         if a is None:
 *             if p.dtype is None:             # <<<<<<<<<<<<<<
 *                 unknown_ctype.append(p.ctype)
 *         else:
 */
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 321, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_2 = (__pyx_t_8 == Py_None);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_11 = (__pyx_t_2 != 0);
      if (__pyx_t_11) {

        /* "cupy/core/elementwise.pxi":322
 *         if a is None:
 *             if p.dtype is None:
 *                 unknown_ctype.append(p.ctype)             # <<<<<<<<<<<<<<
 *         else:
 *             if p.dtype is not None:
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 322, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_unknown_ctype, __pyx_t_8); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(1, 322, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

        /* "cupy/core/elementwise.pxi":321
 *     for p, a in zip(in_params, in_args_dtype):
 *         if a is None:
 *             if p.dtype is None:             # <<<<<<<<<<<<<<
 *                 unknown_ctype.append(p.ctype)
 *         else:
 */
      }

      /* "cupy/core/elementwise.pxi":320
 *     unknown_ctype = []
 *     for p, a in zip(in_params, in_args_dtype):
 *         if a is None:             # <<<<<<<<<<<<<<
 *             if p.dtype is None:
 *                 unknown_ctype.append(p.ctype)
 */
      goto __pyx_L16;
    }

    /* "cupy/core/elementwise.pxi":324
 *                 unknown_ctype.append(p.ctype)
 *         else:
 *             if p.dtype is not None:             # <<<<<<<<<<<<<<
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):
 *                     raise TypeError(
 */
    /*else*/ {
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 324, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_11 = (__pyx_t_8 != Py_None);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_2 = (__pyx_t_11 != 0);
      if (__pyx_t_2) {

        /* "cupy/core/elementwise.pxi":325
 *         else:
 *             if p.dtype is not None:
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 */
        __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 325, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 325, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __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_8 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_a); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 325, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_5)) {
            PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_a};
            __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 325, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_GOTREF(__pyx_t_8);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
            PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_a};
            __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 325, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_GOTREF(__pyx_t_8);
          } else
          #endif
          {
            __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 325, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
            __Pyx_INCREF(__pyx_v_a);
            __Pyx_GIVEREF(__pyx_v_a);
            PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_a);
            __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 325, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 325, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 325, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 325, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_13 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_7);
          if (likely(__pyx_t_13)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_7, function);
          }
        }
        if (!__pyx_t_13) {
          __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 325, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_5);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_7)) {
            PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_9};
            __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 325, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
            PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_9};
            __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 325, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          } else
          #endif
          {
            __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 325, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = NULL;
            __Pyx_GIVEREF(__pyx_t_9);
            PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_9);
            __pyx_t_9 = 0;
            __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 325, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = PyObject_RichCompare(__pyx_t_8, __pyx_t_5, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 325, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 325, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (__pyx_t_2) {

          /* "cupy/core/elementwise.pxi":327
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))             # <<<<<<<<<<<<<<
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]
 */
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 327, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 327, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 327, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7);
          __Pyx_INCREF(__pyx_v_a);
          __Pyx_GIVEREF(__pyx_v_a);
          PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_a);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_5);
          __pyx_t_7 = 0;
          __pyx_t_5 = 0;
          __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Type_is_mismatched_s_s_s, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 327, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

          /* "cupy/core/elementwise.pxi":326
 *             if p.dtype is not None:
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):
 *                     raise TypeError(             # <<<<<<<<<<<<<<
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:
 */
          __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 326, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5);
          __pyx_t_5 = 0;
          __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 326, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_Raise(__pyx_t_5, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __PYX_ERR(1, 326, __pyx_L1_error)

          /* "cupy/core/elementwise.pxi":325
 *         else:
 *             if p.dtype is not None:
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 */
        }

        /* "cupy/core/elementwise.pxi":324
 *                 unknown_ctype.append(p.ctype)
 *         else:
 *             if p.dtype is not None:             # <<<<<<<<<<<<<<
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):
 *                     raise TypeError(
 */
        goto __pyx_L18;
      }

      /* "cupy/core/elementwise.pxi":328
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:             # <<<<<<<<<<<<<<
 *                 t = type_dict[p.ctype]
 *                 if numpy.dtype(t) != numpy.dtype(a):
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 328, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_t_5, __pyx_v_type_dict, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 328, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_11 = (__pyx_t_2 != 0);
      if (__pyx_t_11) {

        /* "cupy/core/elementwise.pxi":329
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]             # <<<<<<<<<<<<<<
 *                 if numpy.dtype(t) != numpy.dtype(a):
 *                     raise TypeError(
 */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 329, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_8 = __Pyx_PyDict_GetItem(__pyx_v_type_dict, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 329, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_8);
        __pyx_t_8 = 0;

        /* "cupy/core/elementwise.pxi":330
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]
 *                 if numpy.dtype(t) != numpy.dtype(a):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (
 */
        __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 330, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 330, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
          if (likely(__pyx_t_5)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_7, function);
          }
        }
        if (!__pyx_t_5) {
          __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_t); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 330, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_7)) {
            PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_t};
            __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 330, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_GOTREF(__pyx_t_8);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
            PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_t};
            __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 330, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_GOTREF(__pyx_t_8);
          } else
          #endif
          {
            __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 330, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5); __pyx_t_5 = NULL;
            __Pyx_INCREF(__pyx_v_t);
            __Pyx_GIVEREF(__pyx_v_t);
            PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_v_t);
            __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 330, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 330, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 330, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_12 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        if (!__pyx_t_12) {
          __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_a); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 330, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_5)) {
            PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_a};
            __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 330, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_GOTREF(__pyx_t_7);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
            PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_a};
            __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 330, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_GOTREF(__pyx_t_7);
          } else
          #endif
          {
            __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 330, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_12); __pyx_t_12 = NULL;
            __Pyx_INCREF(__pyx_v_a);
            __Pyx_GIVEREF(__pyx_v_a);
            PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_a);
            __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 330, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = PyObject_RichCompare(__pyx_t_8, __pyx_t_7, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 330, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(1, 330, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (__pyx_t_11) {

          /* "cupy/core/elementwise.pxi":333
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (
 *                             p.name, a, t, p.ctype))             # <<<<<<<<<<<<<<
 *             else:
 *                 type_dict[p.ctype] = a
 */
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 333, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 333, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 333, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5);
          __Pyx_INCREF(__pyx_v_a);
          __Pyx_GIVEREF(__pyx_v_a);
          PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_a);
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_v_t);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_7);
          __pyx_t_5 = 0;
          __pyx_t_7 = 0;

          /* "cupy/core/elementwise.pxi":332
 *                 if numpy.dtype(t) != numpy.dtype(a):
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (             # <<<<<<<<<<<<<<
 *                             p.name, a, t, p.ctype))
 *             else:
 */
          __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Type_is_mismatched_s_s_s_s, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 332, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

          /* "cupy/core/elementwise.pxi":331
 *                 t = type_dict[p.ctype]
 *                 if numpy.dtype(t) != numpy.dtype(a):
 *                     raise TypeError(             # <<<<<<<<<<<<<<
 *                         'Type is mismatched. %s %s %s %s' % (
 *                             p.name, a, t, p.ctype))
 */
          __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 331, __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_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 331, __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(1, 331, __pyx_L1_error)

          /* "cupy/core/elementwise.pxi":330
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]
 *                 if numpy.dtype(t) != numpy.dtype(a):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (
 */
        }

        /* "cupy/core/elementwise.pxi":328
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:             # <<<<<<<<<<<<<<
 *                 t = type_dict[p.ctype]
 *                 if numpy.dtype(t) != numpy.dtype(a):
 */
        goto __pyx_L18;
      }

      /* "cupy/core/elementwise.pxi":335
 *                             p.name, a, t, p.ctype))
 *             else:
 *                 type_dict[p.ctype] = a             # <<<<<<<<<<<<<<
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 */
      /*else*/ {
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 335, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (unlikely(PyDict_SetItem(__pyx_v_type_dict, __pyx_t_7, __pyx_v_a) < 0)) __PYX_ERR(1, 335, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __pyx_L18:;
    }
    __pyx_L16:;

    /* "cupy/core/elementwise.pxi":319
 *     assert len(in_params) == len(in_args_dtype)
 *     unknown_ctype = []
 *     for p, a in zip(in_params, in_args_dtype):             # <<<<<<<<<<<<<<
 *         if a is None:
 *             if p.dtype is None:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":337
 *                 type_dict[p.ctype] = a
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype             # <<<<<<<<<<<<<<
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":338
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                       for p in in_params])             # <<<<<<<<<<<<<<
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                        for p in out_params])
 */
  if (likely(PyList_CheckExact(__pyx_v_in_params)) || PyTuple_CheckExact(__pyx_v_in_params)) {
    __pyx_t_7 = __pyx_v_in_params; __Pyx_INCREF(__pyx_t_7); __pyx_t_3 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_in_params); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 338, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_7))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_7)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_8 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_3); __Pyx_INCREF(__pyx_t_8); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 338, __pyx_L1_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_7, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 338, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_3); __Pyx_INCREF(__pyx_t_8); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 338, __pyx_L1_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_7, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 338, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      }
    } else {
      __pyx_t_8 = __pyx_t_6(__pyx_t_7);
      if (unlikely(!__pyx_t_8)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 338, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_8);
    }
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/elementwise.pxi":337
 *                 type_dict[p.ctype] = a
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype             # <<<<<<<<<<<<<<
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 337, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_11 = (__pyx_t_5 == Py_None);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if ((__pyx_t_11 != 0)) {
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 337, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = __Pyx_PyDict_GetItem(__pyx_v_type_dict, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 337, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_8 = __pyx_t_9;
      __pyx_t_9 = 0;
    } else {
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 337, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_8 = __pyx_t_9;
      __pyx_t_9 = 0;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_8))) __PYX_ERR(1, 337, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/elementwise.pxi":338
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                       for p in in_params])             # <<<<<<<<<<<<<<
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                        for p in out_params])
 */
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":337
 *                 type_dict[p.ctype] = a
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype             # <<<<<<<<<<<<<<
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 */
  __pyx_t_7 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_in_types = ((PyObject*)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":339
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype             # <<<<<<<<<<<<<<
 *                        for p in out_params])
 *     return in_types, out_types, tuple(type_dict.items())
 */
  __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/elementwise.pxi":340
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                        for p in out_params])             # <<<<<<<<<<<<<<
 *     return in_types, out_types, tuple(type_dict.items())
 * 
 */
  if (likely(PyList_CheckExact(__pyx_v_out_params)) || PyTuple_CheckExact(__pyx_v_out_params)) {
    __pyx_t_1 = __pyx_v_out_params; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_out_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 340, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 340, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_8 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_8); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 340, __pyx_L1_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 340, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_8); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 340, __pyx_L1_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 340, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      }
    } else {
      __pyx_t_8 = __pyx_t_6(__pyx_t_1);
      if (unlikely(!__pyx_t_8)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 340, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_8);
    }
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/elementwise.pxi":339
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype             # <<<<<<<<<<<<<<
 *                        for p in out_params])
 *     return in_types, out_types, tuple(type_dict.items())
 */
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 339, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_11 = (__pyx_t_9 == Py_None);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if ((__pyx_t_11 != 0)) {
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 339, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_type_dict, __pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 339, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_8 = __pyx_t_5;
      __pyx_t_5 = 0;
    } else {
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 339, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = __pyx_t_5;
      __pyx_t_5 = 0;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_7, (PyObject*)__pyx_t_8))) __PYX_ERR(1, 339, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/elementwise.pxi":340
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                        for p in out_params])             # <<<<<<<<<<<<<<
 *     return in_types, out_types, tuple(type_dict.items())
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":339
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype             # <<<<<<<<<<<<<<
 *                        for p in out_params])
 *     return in_types, out_types, tuple(type_dict.items())
 */
  __pyx_t_1 = PyList_AsTuple(((PyObject*)__pyx_t_7)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_out_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":341
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                        for p in out_params])
 *     return in_types, out_types, tuple(type_dict.items())             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyDict_Items(__pyx_v_type_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_in_types);
  __Pyx_GIVEREF(__pyx_v_in_types);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_in_types);
  __Pyx_INCREF(__pyx_v_out_types);
  __Pyx_GIVEREF(__pyx_v_out_types);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_out_types);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":297
 * 
 * @util.memoize()
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):             # <<<<<<<<<<<<<<
 *     type_dict = {}
 *     if out_args_dtype:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("cupy.core.core._decide_params_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_type_dict);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_unknown_ctype);
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":344
 * 
 * 
 * cdef tuple _broadcast(list args, tuple params, bint use_size):             # <<<<<<<<<<<<<<
 *     cpdef Py_ssize_t i
 *     cpdef ParameterInfo p
 */

static PyObject *__pyx_f_4cupy_4core_4core__broadcast(PyObject *__pyx_v_args, PyObject *__pyx_v_params, int __pyx_v_use_size) {
  Py_ssize_t __pyx_v_i;
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_p = 0;
  int __pyx_v_is_none;
  int __pyx_v_is_not_none;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_v_a = NULL;
  struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_brod = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("_broadcast", 0);

  /* "cupy/core/elementwise.pxi":348
 *     cpdef ParameterInfo p
 *     cpdef bint is_none, is_not_none
 *     value = []             # <<<<<<<<<<<<<<
 *     is_none = False
 *     is_not_none = False
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_value = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":349
 *     cpdef bint is_none, is_not_none
 *     value = []
 *     is_none = False             # <<<<<<<<<<<<<<
 *     is_not_none = False
 *     for i in range(len(args)):
 */
  __pyx_v_is_none = 0;

  /* "cupy/core/elementwise.pxi":350
 *     value = []
 *     is_none = False
 *     is_not_none = False             # <<<<<<<<<<<<<<
 *     for i in range(len(args)):
 *         p = params[i]
 */
  __pyx_v_is_not_none = 0;

  /* "cupy/core/elementwise.pxi":351
 *     is_none = False
 *     is_not_none = False
 *     for i in range(len(args)):             # <<<<<<<<<<<<<<
 *         p = params[i]
 *         a = args[i]
 */
  if (unlikely(__pyx_v_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 351, __pyx_L1_error)
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(1, 351, __pyx_L1_error)
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "cupy/core/elementwise.pxi":352
 *     is_not_none = False
 *     for i in range(len(args)):
 *         p = params[i]             # <<<<<<<<<<<<<<
 *         a = args[i]
 *         if not p.raw and isinstance(a, ndarray):
 */
    if (unlikely(__pyx_v_params == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 352, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_params, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 352, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ParameterInfo))))) __PYX_ERR(1, 352, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_p, ((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":353
 *     for i in range(len(args)):
 *         p = params[i]
 *         a = args[i]             # <<<<<<<<<<<<<<
 *         if not p.raw and isinstance(a, ndarray):
 *             is_not_none = True
 */
    if (unlikely(__pyx_v_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 353, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_args, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 353, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":354
 *         p = params[i]
 *         a = args[i]
 *         if not p.raw and isinstance(a, ndarray):             # <<<<<<<<<<<<<<
 *             is_not_none = True
 *             value.append(a)
 */
    __pyx_t_5 = ((!(__pyx_v_p->raw != 0)) != 0);
    if (__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_6 = (__pyx_t_5 != 0);
    __pyx_t_4 = __pyx_t_6;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_4) {

      /* "cupy/core/elementwise.pxi":355
 *         a = args[i]
 *         if not p.raw and isinstance(a, ndarray):
 *             is_not_none = True             # <<<<<<<<<<<<<<
 *             value.append(a)
 *         else:
 */
      __pyx_v_is_not_none = 1;

      /* "cupy/core/elementwise.pxi":356
 *         if not p.raw and isinstance(a, ndarray):
 *             is_not_none = True
 *             value.append(a)             # <<<<<<<<<<<<<<
 *         else:
 *             is_none = True
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_value, __pyx_v_a); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(1, 356, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":354
 *         p = params[i]
 *         a = args[i]
 *         if not p.raw and isinstance(a, ndarray):             # <<<<<<<<<<<<<<
 *             is_not_none = True
 *             value.append(a)
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":358
 *             value.append(a)
 *         else:
 *             is_none = True             # <<<<<<<<<<<<<<
 *             value.append(None)
 * 
 */
    /*else*/ {
      __pyx_v_is_none = 1;

      /* "cupy/core/elementwise.pxi":359
 *         else:
 *             is_none = True
 *             value.append(None)             # <<<<<<<<<<<<<<
 * 
 *     if use_size:
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_value, Py_None); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(1, 359, __pyx_L1_error)
    }
    __pyx_L5:;
  }

  /* "cupy/core/elementwise.pxi":361
 *             value.append(None)
 * 
 *     if use_size:             # <<<<<<<<<<<<<<
 *         if not is_none:
 *             raise ValueError("Specified 'size' can be used only "
 */
  __pyx_t_4 = (__pyx_v_use_size != 0);
  if (__pyx_t_4) {

    /* "cupy/core/elementwise.pxi":362
 * 
 *     if use_size:
 *         if not is_none:             # <<<<<<<<<<<<<<
 *             raise ValueError("Specified 'size' can be used only "
 *                              "if all of the ndarray are 'raw'.")
 */
    __pyx_t_4 = ((!(__pyx_v_is_none != 0)) != 0);
    if (__pyx_t_4) {

      /* "cupy/core/elementwise.pxi":363
 *     if use_size:
 *         if not is_none:
 *             raise ValueError("Specified 'size' can be used only "             # <<<<<<<<<<<<<<
 *                              "if all of the ndarray are 'raw'.")
 *     else:
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__75, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 363, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(1, 363, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":362
 * 
 *     if use_size:
 *         if not is_none:             # <<<<<<<<<<<<<<
 *             raise ValueError("Specified 'size' can be used only "
 *                              "if all of the ndarray are 'raw'.")
 */
    }

    /* "cupy/core/elementwise.pxi":361
 *             value.append(None)
 * 
 *     if use_size:             # <<<<<<<<<<<<<<
 *         if not is_none:
 *             raise ValueError("Specified 'size' can be used only "
 */
    goto __pyx_L8;
  }

  /* "cupy/core/elementwise.pxi":366
 *                              "if all of the ndarray are 'raw'.")
 *     else:
 *         if not is_not_none:             # <<<<<<<<<<<<<<
 *             raise ValueError('Loop size is Undecided')
 *     brod = broadcast(*value)
 */
  /*else*/ {
    __pyx_t_4 = ((!(__pyx_v_is_not_none != 0)) != 0);
    if (__pyx_t_4) {

      /* "cupy/core/elementwise.pxi":367
 *     else:
 *         if not is_not_none:
 *             raise ValueError('Loop size is Undecided')             # <<<<<<<<<<<<<<
 *     brod = broadcast(*value)
 *     value = []
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 367, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(1, 367, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":366
 *                              "if all of the ndarray are 'raw'.")
 *     else:
 *         if not is_not_none:             # <<<<<<<<<<<<<<
 *             raise ValueError('Loop size is Undecided')
 *     brod = broadcast(*value)
 */
    }
  }
  __pyx_L8:;

  /* "cupy/core/elementwise.pxi":368
 *         if not is_not_none:
 *             raise ValueError('Loop size is Undecided')
 *     brod = broadcast(*value)             # <<<<<<<<<<<<<<
 *     value = []
 *     for i in range(len(args)):
 */
  __pyx_t_1 = PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 368, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_broadcast), __pyx_t_1, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 368, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_brod = ((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":369
 *             raise ValueError('Loop size is Undecided')
 *     brod = broadcast(*value)
 *     value = []             # <<<<<<<<<<<<<<
 *     for i in range(len(args)):
 *         a = brod.values[i]
 */
  __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 369, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF_SET(__pyx_v_value, ((PyObject*)__pyx_t_8));
  __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":370
 *     brod = broadcast(*value)
 *     value = []
 *     for i in range(len(args)):             # <<<<<<<<<<<<<<
 *         a = brod.values[i]
 *         if a is None:
 */
  if (unlikely(__pyx_v_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 370, __pyx_L1_error)
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(1, 370, __pyx_L1_error)
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "cupy/core/elementwise.pxi":371
 *     value = []
 *     for i in range(len(args)):
 *         a = brod.values[i]             # <<<<<<<<<<<<<<
 *         if a is None:
 *             a = args[i]
 */
    if (unlikely(__pyx_v_brod->values == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 371, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_GetItemInt_Tuple(__pyx_v_brod->values, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/elementwise.pxi":372
 *     for i in range(len(args)):
 *         a = brod.values[i]
 *         if a is None:             # <<<<<<<<<<<<<<
 *             a = args[i]
 *         value.append(a)
 */
    __pyx_t_4 = (__pyx_v_a == Py_None);
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (__pyx_t_6) {

      /* "cupy/core/elementwise.pxi":373
 *         a = brod.values[i]
 *         if a is None:
 *             a = args[i]             # <<<<<<<<<<<<<<
 *         value.append(a)
 *     return value, brod.shape
 */
      if (unlikely(__pyx_v_args == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(1, 373, __pyx_L1_error)
      }
      __pyx_t_8 = __Pyx_GetItemInt_List(__pyx_v_args, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 373, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF_SET(__pyx_v_a, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "cupy/core/elementwise.pxi":372
 *     for i in range(len(args)):
 *         a = brod.values[i]
 *         if a is None:             # <<<<<<<<<<<<<<
 *             a = args[i]
 *         value.append(a)
 */
    }

    /* "cupy/core/elementwise.pxi":374
 *         if a is None:
 *             a = args[i]
 *         value.append(a)             # <<<<<<<<<<<<<<
 *     return value, brod.shape
 * 
 */
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_value, __pyx_v_a); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(1, 374, __pyx_L1_error)
  }

  /* "cupy/core/elementwise.pxi":375
 *             a = args[i]
 *         value.append(a)
 *     return value, brod.shape             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_value);
  __Pyx_INCREF(__pyx_v_brod->shape);
  __Pyx_GIVEREF(__pyx_v_brod->shape);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_brod->shape);
  __pyx_r = ((PyObject*)__pyx_t_8);
  __pyx_t_8 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":344
 * 
 * 
 * cdef tuple _broadcast(list args, tuple params, bint use_size):             # <<<<<<<<<<<<<<
 *     cpdef Py_ssize_t i
 *     cpdef ParameterInfo p
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.core.core._broadcast", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF((PyObject *)__pyx_v_brod);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":378
 * 
 * 
 * cdef list _get_out_args(list out_args, tuple out_types, tuple out_shape,             # <<<<<<<<<<<<<<
 *                         str casting):
 *     if not out_args:
 */

static PyObject *__pyx_f_4cupy_4core_4core__get_out_args(PyObject *__pyx_v_out_args, PyObject *__pyx_v_out_types, PyObject *__pyx_v_out_shape, PyObject *__pyx_v_casting) {
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_out_type = NULL;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  __Pyx_RefNannySetupContext("_get_out_args", 0);

  /* "cupy/core/elementwise.pxi":380
 * cdef list _get_out_args(list out_args, tuple out_types, tuple out_shape,
 *                         str casting):
 *     if not out_args:             # <<<<<<<<<<<<<<
 *         return [ndarray(out_shape, t) for t in out_types]
 * 
 */
  __pyx_t_1 = (__pyx_v_out_args != Py_None) && (PyList_GET_SIZE(__pyx_v_out_args) != 0);
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":381
 *                         str casting):
 *     if not out_args:
 *         return [ndarray(out_shape, t) for t in out_types]             # <<<<<<<<<<<<<<
 * 
 *     for i, a in enumerate(out_args):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 381, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__pyx_v_out_types == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(1, 381, __pyx_L1_error)
    }
    __pyx_t_4 = __pyx_v_out_types; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    for (;;) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 381, __pyx_L1_error)
      #else
      __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 381, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 381, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_out_shape);
      __Pyx_GIVEREF(__pyx_v_out_shape);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_out_shape);
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_GIVEREF(__pyx_v_t);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_t);
      __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 381, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(1, 381, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":380
 * cdef list _get_out_args(list out_args, tuple out_types, tuple out_shape,
 *                         str casting):
 *     if not out_args:             # <<<<<<<<<<<<<<
 *         return [ndarray(out_shape, t) for t in out_types]
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":383
 *         return [ndarray(out_shape, t) for t in out_types]
 * 
 *     for i, a in enumerate(out_args):             # <<<<<<<<<<<<<<
 *         if not isinstance(a, ndarray):
 *             raise TypeError(
 */
  __pyx_t_5 = 0;
  __pyx_t_3 = __pyx_v_out_args; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0;
  for (;;) {
    if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 383, __pyx_L1_error)
    #else
    __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 383, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_v_i = __pyx_t_5;
    __pyx_t_5 = (__pyx_t_5 + 1);

    /* "cupy/core/elementwise.pxi":384
 * 
 *     for i, a in enumerate(out_args):
 *         if not isinstance(a, ndarray):             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 'Output arguments type must be cupy.ndarray')
 */
    __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
    if (__pyx_t_1) {

      /* "cupy/core/elementwise.pxi":385
 *     for i, a in enumerate(out_args):
 *         if not isinstance(a, ndarray):
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 'Output arguments type must be cupy.ndarray')
 *         if a.shape != out_shape:
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__77, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 385, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(1, 385, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":384
 * 
 *     for i, a in enumerate(out_args):
 *         if not isinstance(a, ndarray):             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 'Output arguments type must be cupy.ndarray')
 */
    }

    /* "cupy/core/elementwise.pxi":387
 *             raise TypeError(
 *                 'Output arguments type must be cupy.ndarray')
 *         if a.shape != out_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Out shape is mismatched')
 *         out_type = out_types[i]
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = PyObject_RichCompare(__pyx_t_4, __pyx_v_out_shape, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 387, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 387, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_1) {

      /* "cupy/core/elementwise.pxi":388
 *                 'Output arguments type must be cupy.ndarray')
 *         if a.shape != out_shape:
 *             raise ValueError('Out shape is mismatched')             # <<<<<<<<<<<<<<
 *         out_type = out_types[i]
 *         if not numpy.can_cast(out_type, a.dtype, casting=casting):
 */
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 388, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __PYX_ERR(1, 388, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":387
 *             raise TypeError(
 *                 'Output arguments type must be cupy.ndarray')
 *         if a.shape != out_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Out shape is mismatched')
 *         out_type = out_types[i]
 */
    }

    /* "cupy/core/elementwise.pxi":389
 *         if a.shape != out_shape:
 *             raise ValueError('Out shape is mismatched')
 *         out_type = out_types[i]             # <<<<<<<<<<<<<<
 *         if not numpy.can_cast(out_type, a.dtype, casting=casting):
 *             msg = 'output (typecode \'{}\') could not be coerced to ' \
 */
    if (unlikely(__pyx_v_out_types == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 389, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v_out_types, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 389, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_XDECREF_SET(__pyx_v_out_type, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":390
 *             raise ValueError('Out shape is mismatched')
 *         out_type = out_types[i]
 *         if not numpy.can_cast(out_type, a.dtype, casting=casting):             # <<<<<<<<<<<<<<
 *             msg = 'output (typecode \'{}\') could not be coerced to ' \
 *                   'provided output parameter (typecode \'{}\') according to ' \
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 390, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_can_cast); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 390, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 390, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 390, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_out_type);
    __Pyx_GIVEREF(__pyx_v_out_type);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_out_type);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 390, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_casting, __pyx_v_casting) < 0) __PYX_ERR(1, 390, __pyx_L1_error)
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 390, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 390, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_2 = ((!__pyx_t_1) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":393
 *             msg = 'output (typecode \'{}\') could not be coerced to ' \
 *                   'provided output parameter (typecode \'{}\') according to ' \
 *                   'the casting rule "{}"'.format(             # <<<<<<<<<<<<<<
 *                       numpy.dtype(out_type).char,
 *                       a.dtype.char,
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_output_typecode_could_not_be_coe, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 393, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);

      /* "cupy/core/elementwise.pxi":394
 *                   'provided output parameter (typecode \'{}\') according to ' \
 *                   'the casting rule "{}"'.format(
 *                       numpy.dtype(out_type).char,             # <<<<<<<<<<<<<<
 *                       a.dtype.char,
 *                       casting)
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 394, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dtype); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 394, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_out_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 394, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_10)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_out_type};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 394, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_out_type};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 394, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 394, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); __pyx_t_4 = NULL;
          __Pyx_INCREF(__pyx_v_out_type);
          __Pyx_GIVEREF(__pyx_v_out_type);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_out_type);
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 394, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_char); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 394, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/elementwise.pxi":395
 *                   'the casting rule "{}"'.format(
 *                       numpy.dtype(out_type).char,
 *                       a.dtype.char,             # <<<<<<<<<<<<<<
 *                       casting)
 *             raise TypeError(msg)
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 395, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_char); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 395, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/elementwise.pxi":396
 *                       numpy.dtype(out_type).char,
 *                       a.dtype.char,
 *                       casting)             # <<<<<<<<<<<<<<
 *             raise TypeError(msg)
 *     return out_args
 */
      __pyx_t_6 = NULL;
      __pyx_t_12 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_12 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_10, __pyx_t_11, __pyx_v_casting};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 393, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_10, __pyx_t_11, __pyx_v_casting};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 393, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(3+__pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 393, __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_10);
        PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_12, __pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_12, __pyx_t_11);
        __Pyx_INCREF(__pyx_v_casting);
        __Pyx_GIVEREF(__pyx_v_casting);
        PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_12, __pyx_v_casting);
        __pyx_t_10 = 0;
        __pyx_t_11 = 0;
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_4, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 393, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_msg = __pyx_t_9;
      __pyx_t_9 = 0;

      /* "cupy/core/elementwise.pxi":397
 *                       a.dtype.char,
 *                       casting)
 *             raise TypeError(msg)             # <<<<<<<<<<<<<<
 *     return out_args
 * 
 */
      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 397, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_v_msg);
      __Pyx_GIVEREF(__pyx_v_msg);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_msg);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 397, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __PYX_ERR(1, 397, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":390
 *             raise ValueError('Out shape is mismatched')
 *         out_type = out_types[i]
 *         if not numpy.can_cast(out_type, a.dtype, casting=casting):             # <<<<<<<<<<<<<<
 *             msg = 'output (typecode \'{}\') could not be coerced to ' \
 *                   'provided output parameter (typecode \'{}\') according to ' \
 */
    }

    /* "cupy/core/elementwise.pxi":383
 *         return [ndarray(out_shape, t) for t in out_types]
 * 
 *     for i, a in enumerate(out_args):             # <<<<<<<<<<<<<<
 *         if not isinstance(a, ndarray):
 *             raise TypeError(
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":398
 *                       casting)
 *             raise TypeError(msg)
 *     return out_args             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_out_args);
  __pyx_r = __pyx_v_out_args;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":378
 * 
 * 
 * cdef list _get_out_args(list out_args, tuple out_types, tuple out_shape,             # <<<<<<<<<<<<<<
 *                         str casting):
 *     if not out_args:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core._get_out_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_out_type);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":401
 * 
 * 
 * cdef list _get_out_args_with_params(             # <<<<<<<<<<<<<<
 *         list out_args, tuple out_types, tuple out_shape, tuple out_params,
 *         bint is_size_specified=False):
 */

static PyObject *__pyx_f_4cupy_4core_4core__get_out_args_with_params(PyObject *__pyx_v_out_args, PyObject *__pyx_v_out_types, PyObject *__pyx_v_out_shape, PyObject *__pyx_v_out_params, struct __pyx_opt_args_4cupy_4core_4core__get_out_args_with_params *__pyx_optional_args) {

  /* "cupy/core/elementwise.pxi":403
 * cdef list _get_out_args_with_params(
 *         list out_args, tuple out_types, tuple out_shape, tuple out_params,
 *         bint is_size_specified=False):             # <<<<<<<<<<<<<<
 *     cdef ParameterInfo p
 *     if not out_args:
 */
  int __pyx_v_is_size_specified = ((int)0);
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_p = 0;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  __Pyx_RefNannySetupContext("_get_out_args_with_params", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_is_size_specified = __pyx_optional_args->is_size_specified;
    }
  }

  /* "cupy/core/elementwise.pxi":405
 *         bint is_size_specified=False):
 *     cdef ParameterInfo p
 *     if not out_args:             # <<<<<<<<<<<<<<
 *         for p in out_params:
 *             if p.raw and is_size_specified is False:
 */
  __pyx_t_1 = (__pyx_v_out_args != Py_None) && (PyList_GET_SIZE(__pyx_v_out_args) != 0);
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":406
 *     cdef ParameterInfo p
 *     if not out_args:
 *         for p in out_params:             # <<<<<<<<<<<<<<
 *             if p.raw and is_size_specified is False:
 *                 raise ValueError('Output array size is Undecided')
 */
    if (unlikely(__pyx_v_out_params == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(1, 406, __pyx_L1_error)
    }
    __pyx_t_3 = __pyx_v_out_params; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 406, __pyx_L1_error)
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 406, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      #endif
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4core_4core_ParameterInfo))))) __PYX_ERR(1, 406, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_p, ((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_t_5));
      __pyx_t_5 = 0;

      /* "cupy/core/elementwise.pxi":407
 *     if not out_args:
 *         for p in out_params:
 *             if p.raw and is_size_specified is False:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Output array size is Undecided')
 *         return [ndarray(out_shape, t) for t in out_types]
 */
      __pyx_t_1 = (__pyx_v_p->raw != 0);
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_1 = ((__pyx_v_is_size_specified == 0) != 0);
      __pyx_t_2 = __pyx_t_1;
      __pyx_L7_bool_binop_done:;
      if (__pyx_t_2) {

        /* "cupy/core/elementwise.pxi":408
 *         for p in out_params:
 *             if p.raw and is_size_specified is False:
 *                 raise ValueError('Output array size is Undecided')             # <<<<<<<<<<<<<<
 *         return [ndarray(out_shape, t) for t in out_types]
 * 
 */
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 408, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_Raise(__pyx_t_5, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __PYX_ERR(1, 408, __pyx_L1_error)

        /* "cupy/core/elementwise.pxi":407
 *     if not out_args:
 *         for p in out_params:
 *             if p.raw and is_size_specified is False:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Output array size is Undecided')
 *         return [ndarray(out_shape, t) for t in out_types]
 */
      }

      /* "cupy/core/elementwise.pxi":406
 *     cdef ParameterInfo p
 *     if not out_args:
 *         for p in out_params:             # <<<<<<<<<<<<<<
 *             if p.raw and is_size_specified is False:
 *                 raise ValueError('Output array size is Undecided')
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":409
 *             if p.raw and is_size_specified is False:
 *                 raise ValueError('Output array size is Undecided')
 *         return [ndarray(out_shape, t) for t in out_types]             # <<<<<<<<<<<<<<
 * 
 *     for i in range(len(out_params)):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__pyx_v_out_types == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(1, 409, __pyx_L1_error)
    }
    __pyx_t_5 = __pyx_v_out_types; __Pyx_INCREF(__pyx_t_5); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 409, __pyx_L1_error)
      #else
      __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 409, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 409, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_out_shape);
      __Pyx_GIVEREF(__pyx_v_out_shape);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_out_shape);
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_GIVEREF(__pyx_v_t);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_t);
      __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 409, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(1, 409, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":405
 *         bint is_size_specified=False):
 *     cdef ParameterInfo p
 *     if not out_args:             # <<<<<<<<<<<<<<
 *         for p in out_params:
 *             if p.raw and is_size_specified is False:
 */
  }

  /* "cupy/core/elementwise.pxi":411
 *         return [ndarray(out_shape, t) for t in out_types]
 * 
 *     for i in range(len(out_params)):             # <<<<<<<<<<<<<<
 *         a = out_args[i]
 *         p = out_params[i]
 */
  if (unlikely(__pyx_v_out_params == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 411, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v_out_params); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 411, __pyx_L1_error)
  for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_4; __pyx_t_8+=1) {
    __pyx_v_i = __pyx_t_8;

    /* "cupy/core/elementwise.pxi":412
 * 
 *     for i in range(len(out_params)):
 *         a = out_args[i]             # <<<<<<<<<<<<<<
 *         p = out_params[i]
 *         if not isinstance(a, ndarray):
 */
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 412, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_out_args, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":413
 *     for i in range(len(out_params)):
 *         a = out_args[i]
 *         p = out_params[i]             # <<<<<<<<<<<<<<
 *         if not isinstance(a, ndarray):
 *             raise TypeError(
 */
    if (unlikely(__pyx_v_out_params == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 413, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_out_params, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 413, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ParameterInfo))))) __PYX_ERR(1, 413, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_p, ((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":414
 *         a = out_args[i]
 *         p = out_params[i]
 *         if not isinstance(a, ndarray):             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 'Output arguments type must be cupy.ndarray')
 */
    __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
    if (__pyx_t_1) {

      /* "cupy/core/elementwise.pxi":415
 *         p = out_params[i]
 *         if not isinstance(a, ndarray):
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 'Output arguments type must be cupy.ndarray')
 *         if not p.raw and a.shape != out_shape:
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 415, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(1, 415, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":414
 *         a = out_args[i]
 *         p = out_params[i]
 *         if not isinstance(a, ndarray):             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 'Output arguments type must be cupy.ndarray')
 */
    }

    /* "cupy/core/elementwise.pxi":417
 *             raise TypeError(
 *                 'Output arguments type must be cupy.ndarray')
 *         if not p.raw and a.shape != out_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Out shape is mismatched')
 *     return out_args
 */
    __pyx_t_2 = ((!(__pyx_v_p->raw != 0)) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L15_bool_binop_done;
    }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_v_out_shape, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 417, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 417, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_1 = __pyx_t_2;
    __pyx_L15_bool_binop_done:;
    if (__pyx_t_1) {

      /* "cupy/core/elementwise.pxi":418
 *                 'Output arguments type must be cupy.ndarray')
 *         if not p.raw and a.shape != out_shape:
 *             raise ValueError('Out shape is mismatched')             # <<<<<<<<<<<<<<
 *     return out_args
 * 
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 418, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(1, 418, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":417
 *             raise TypeError(
 *                 'Output arguments type must be cupy.ndarray')
 *         if not p.raw and a.shape != out_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Out shape is mismatched')
 *     return out_args
 */
    }
  }

  /* "cupy/core/elementwise.pxi":419
 *         if not p.raw and a.shape != out_shape:
 *             raise ValueError('Out shape is mismatched')
 *     return out_args             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_out_args);
  __pyx_r = __pyx_v_out_args;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":401
 * 
 * 
 * cdef list _get_out_args_with_params(             # <<<<<<<<<<<<<<
 *         list out_args, tuple out_types, tuple out_shape, tuple out_params,
 *         bint is_size_specified=False):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core._get_out_args_with_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":423
 * 
 * @util.memoize(for_each_device=True)
 * def _get_elementwise_kernel(args_info, types, params, operation, name,             # <<<<<<<<<<<<<<
 *                             preamble, kwargs):
 *     kernel_params = _get_kernel_params(params, args_info)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_29_get_elementwise_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_28_get_elementwise_kernel[] = "_get_elementwise_kernel(args_info, types, params, operation, name, preamble, kwargs)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_29_get_elementwise_kernel = {"_get_elementwise_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_29_get_elementwise_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_28_get_elementwise_kernel};
static PyObject *__pyx_pw_4cupy_4core_4core_29_get_elementwise_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args_info = 0;
  PyObject *__pyx_v_types = 0;
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_operation = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_elementwise_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_args_info,&__pyx_n_s_types,&__pyx_n_s_params,&__pyx_n_s_operation,&__pyx_n_s_name,&__pyx_n_s_preamble,&__pyx_n_s_kwargs,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_args_info)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_types)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_elementwise_kernel", 1, 7, 7, 1); __PYX_ERR(1, 423, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_elementwise_kernel", 1, 7, 7, 2); __PYX_ERR(1, 423, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_operation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_elementwise_kernel", 1, 7, 7, 3); __PYX_ERR(1, 423, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_elementwise_kernel", 1, 7, 7, 4); __PYX_ERR(1, 423, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_preamble)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_elementwise_kernel", 1, 7, 7, 5); __PYX_ERR(1, 423, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_elementwise_kernel", 1, 7, 7, 6); __PYX_ERR(1, 423, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_elementwise_kernel") < 0)) __PYX_ERR(1, 423, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
    }
    __pyx_v_args_info = values[0];
    __pyx_v_types = values[1];
    __pyx_v_params = values[2];
    __pyx_v_operation = values[3];
    __pyx_v_name = values[4];
    __pyx_v_preamble = values[5];
    __pyx_v_kwargs = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_elementwise_kernel", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 423, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_elementwise_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_28_get_elementwise_kernel(__pyx_self, __pyx_v_args_info, __pyx_v_types, __pyx_v_params, __pyx_v_operation, __pyx_v_name, __pyx_v_preamble, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_4cupy_4core_4core_23_get_elementwise_kernel_2generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "cupy/core/elementwise.pxi":427
 *     kernel_params = _get_kernel_params(params, args_info)
 *     types_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k) for k, v in types)             # <<<<<<<<<<<<<<
 *     preamble = types_preamble + '\n' + preamble
 * 
 */

static PyObject *__pyx_pf_4cupy_4core_4core_23_get_elementwise_kernel_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *)__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_1_genexpr(__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(1, 427, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4cupy_4core_4core_23_get_elementwise_kernel_2generator, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_get_elementwise_kernel_locals_g, __pyx_n_s_cupy_core_core); if (unlikely(!gen)) __PYX_ERR(1, 427, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

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

static PyObject *__pyx_gb_4cupy_4core_4core_23_get_elementwise_kernel_2generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *__pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L8_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(1, 427, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types)) { __Pyx_RaiseClosureNameError("types"); __PYX_ERR(1, 427, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_types; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 427, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 427, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 427, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 427, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 427, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 427, __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(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 427, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(1, 427, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 427, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 427, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 427, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(1, 427, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(1, 427, __pyx_L1_error)
      __pyx_L7_unpacking_done:;
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_k);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_k, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_cur_scope->__pyx_v_v, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 427, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 427, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_k);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_cur_scope->__pyx_v_k);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_typedef_s_s, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 427, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L8_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(1, 427, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":423
 * 
 * @util.memoize(for_each_device=True)
 * def _get_elementwise_kernel(args_info, types, params, operation, name,             # <<<<<<<<<<<<<<
 *                             preamble, kwargs):
 *     kernel_params = _get_kernel_params(params, args_info)
 */

static PyObject *__pyx_pf_4cupy_4core_4core_28_get_elementwise_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args_info, PyObject *__pyx_v_types, PyObject *__pyx_v_params, PyObject *__pyx_v_operation, PyObject *__pyx_v_name, PyObject *__pyx_v_preamble, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *__pyx_cur_scope;
  PyObject *__pyx_v_kernel_params = NULL;
  PyObject *__pyx_v_types_preamble = NULL;
  PyObject *__pyx_v_op = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_fmt = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  __Pyx_RefNannySetupContext("_get_elementwise_kernel", 0);
  __pyx_cur_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *)__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel(__pyx_ptype_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(1, 423, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_types = __pyx_v_types;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_types);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_types);
  __Pyx_INCREF(__pyx_v_operation);
  __Pyx_INCREF(__pyx_v_preamble);

  /* "cupy/core/elementwise.pxi":425
 * def _get_elementwise_kernel(args_info, types, params, operation, name,
 *                             preamble, kwargs):
 *     kernel_params = _get_kernel_params(params, args_info)             # <<<<<<<<<<<<<<
 *     types_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k) for k, v in types)
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_params))||((__pyx_v_params) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_params)->tp_name), 0))) __PYX_ERR(1, 425, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_args_info))||((__pyx_v_args_info) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args_info)->tp_name), 0))) __PYX_ERR(1, 425, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_kernel_params(((PyObject*)__pyx_v_params), ((PyObject*)__pyx_v_args_info), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_kernel_params = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":427
 *     kernel_params = _get_kernel_params(params, args_info)
 *     types_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k) for k, v in types)             # <<<<<<<<<<<<<<
 *     preamble = types_preamble + '\n' + preamble
 * 
 */
  __pyx_t_1 = __pyx_pf_4cupy_4core_4core_23_get_elementwise_kernel_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":426
 *                             preamble, kwargs):
 *     kernel_params = _get_kernel_params(params, args_info)
 *     types_preamble = '\n'.join(             # <<<<<<<<<<<<<<
 *         'typedef %s %s;' % (_get_typename(v), k) for k, v in types)
 *     preamble = types_preamble + '\n' + preamble
 */
  __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__63, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_types_preamble = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":428
 *     types_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k) for k, v in types)
 *     preamble = types_preamble + '\n' + preamble             # <<<<<<<<<<<<<<
 * 
 *     op = []
 */
  __pyx_t_2 = PyNumber_Add(__pyx_v_types_preamble, __pyx_kp_s__63); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Add(__pyx_t_2, __pyx_v_preamble); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_preamble, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":430
 *     preamble = types_preamble + '\n' + preamble
 * 
 *     op = []             # <<<<<<<<<<<<<<
 *     for p, a in zip(params, args_info):
 *         if not p.raw and a[0] == ndarray:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_op = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":431
 * 
 *     op = []
 *     for p, a in zip(params, args_info):             # <<<<<<<<<<<<<<
 *         if not p.raw and a[0] == ndarray:
 *             if p.is_const:
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_params);
  __Pyx_GIVEREF(__pyx_v_params);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_params);
  __Pyx_INCREF(__pyx_v_args_info);
  __Pyx_GIVEREF(__pyx_v_args_info);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_args_info);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 431, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 431, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 431, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 431, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 431, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 431, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 431, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(1, 431, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 431, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 431, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 431, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(1, 431, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(1, 431, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":432
 *     op = []
 *     for p, a in zip(params, args_info):
 *         if not p.raw and a[0] == ndarray:             # <<<<<<<<<<<<<<
 *             if p.is_const:
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_raw_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 432, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(1, 432, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_11 = ((!__pyx_t_10) != 0);
    if (__pyx_t_11) {
    } else {
      __pyx_t_9 = __pyx_t_11;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_a, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 432, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 432, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(1, 432, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_9 = __pyx_t_11;
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_9) {

      /* "cupy/core/elementwise.pxi":433
 *     for p, a in zip(params, args_info):
 *         if not p.raw and a[0] == ndarray:
 *             if p.is_const:             # <<<<<<<<<<<<<<
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 *             else:
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_is_const); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 433, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(1, 433, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__pyx_t_9) {

        /* "cupy/core/elementwise.pxi":434
 *         if not p.raw and a[0] == ndarray:
 *             if p.is_const:
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'             # <<<<<<<<<<<<<<
 *             else:
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 */
        __Pyx_INCREF(__pyx_kp_s_t_n__raw__n__ind_get);
        __Pyx_XDECREF_SET(__pyx_v_fmt, __pyx_kp_s_t_n__raw__n__ind_get);

        /* "cupy/core/elementwise.pxi":433
 *     for p, a in zip(params, args_info):
 *         if not p.raw and a[0] == ndarray:
 *             if p.is_const:             # <<<<<<<<<<<<<<
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 *             else:
 */
        goto __pyx_L10;
      }

      /* "cupy/core/elementwise.pxi":436
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 *             else:
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'             # <<<<<<<<<<<<<<
 *             op.append(fmt.format(t=p.ctype, n=p.name))
 *     op.append(operation)
 */
      /*else*/ {
        __Pyx_INCREF(__pyx_kp_s_t_n__raw__n__ind_get);
        __Pyx_XDECREF_SET(__pyx_v_fmt, __pyx_kp_s_t_n__raw__n__ind_get);
      }
      __pyx_L10:;

      /* "cupy/core/elementwise.pxi":437
 *             else:
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 *             op.append(fmt.format(t=p.ctype, n=p.name))             # <<<<<<<<<<<<<<
 *     op.append(operation)
 *     operation = '\n'.join(op)
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_fmt, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 437, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 437, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 437, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_t, __pyx_t_5) < 0) __PYX_ERR(1, 437, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 437, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_n, __pyx_t_5) < 0) __PYX_ERR(1, 437, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 437, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_op, __pyx_t_5); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(1, 437, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cupy/core/elementwise.pxi":432
 *     op = []
 *     for p, a in zip(params, args_info):
 *         if not p.raw and a[0] == ndarray:             # <<<<<<<<<<<<<<
 *             if p.is_const:
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 */
    }

    /* "cupy/core/elementwise.pxi":431
 * 
 *     op = []
 *     for p, a in zip(params, args_info):             # <<<<<<<<<<<<<<
 *         if not p.raw and a[0] == ndarray:
 *             if p.is_const:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":438
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 *             op.append(fmt.format(t=p.ctype, n=p.name))
 *     op.append(operation)             # <<<<<<<<<<<<<<
 *     operation = '\n'.join(op)
 *     return _get_simple_elementwise_kernel(
 */
  __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_op, __pyx_v_operation); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(1, 438, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":439
 *             op.append(fmt.format(t=p.ctype, n=p.name))
 *     op.append(operation)
 *     operation = '\n'.join(op)             # <<<<<<<<<<<<<<
 *     return _get_simple_elementwise_kernel(
 *         kernel_params, operation, name,
 */
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__63, __pyx_v_op); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_operation, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":440
 *     op.append(operation)
 *     operation = '\n'.join(op)
 *     return _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         kernel_params, operation, name,
 *         preamble, **dict(kwargs))
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_simple_elementwise_kernel); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":442
 *     return _get_simple_elementwise_kernel(
 *         kernel_params, operation, name,
 *         preamble, **dict(kwargs))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_kernel_params);
  __Pyx_GIVEREF(__pyx_v_kernel_params);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_kernel_params);
  __Pyx_INCREF(__pyx_v_operation);
  __Pyx_GIVEREF(__pyx_v_operation);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_operation);
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_name);
  __Pyx_INCREF(__pyx_v_preamble);
  __Pyx_GIVEREF(__pyx_v_preamble);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_preamble);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_kwargs);
  __Pyx_GIVEREF(__pyx_v_kwargs);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_kwargs);
  __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)(&PyDict_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":440
 *     op.append(operation)
 *     operation = '\n'.join(op)
 *     return _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         kernel_params, operation, name,
 *         preamble, **dict(kwargs))
 */
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":423
 * 
 * @util.memoize(for_each_device=True)
 * def _get_elementwise_kernel(args_info, types, params, operation, name,             # <<<<<<<<<<<<<<
 *                             preamble, kwargs):
 *     kernel_params = _get_kernel_params(params, args_info)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core._get_elementwise_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_kernel_params);
  __Pyx_XDECREF(__pyx_v_types_preamble);
  __Pyx_XDECREF(__pyx_v_op);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_fmt);
  __Pyx_XDECREF(__pyx_v_operation);
  __Pyx_XDECREF(__pyx_v_preamble);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":494
 *         readonly object kwargs
 * 
 *     def __init__(self, in_params, out_params, operation,             # <<<<<<<<<<<<<<
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         if not compiler.is_valid_kernel_name(name):
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_in_params = 0;
  PyObject *__pyx_v_out_params = 0;
  PyObject *__pyx_v_operation = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_reduce_dims = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
  __Pyx_GOTREF(__pyx_v_kwargs);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_in_params,&__pyx_n_s_out_params,&__pyx_n_s_operation,&__pyx_n_s_name,&__pyx_n_s_reduce_dims,&__pyx_n_s_preamble,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[3] = ((PyObject *)__pyx_n_s_kernel);

    /* "cupy/core/elementwise.pxi":495
 * 
 *     def __init__(self, in_params, out_params, operation,
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):             # <<<<<<<<<<<<<<
 *         if not compiler.is_valid_kernel_name(name):
 *             raise ValueError(
 */
    values[4] = ((PyObject *)Py_True);
    values[5] = ((PyObject *)__pyx_kp_s__5);
    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] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_in_params)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 6, 1); __PYX_ERR(1, 494, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_operation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 6, 2); __PYX_ERR(1, 494, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_reduce_dims);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_preamble);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "__init__") < 0)) __PYX_ERR(1, 494, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_in_params = values[0];
    __pyx_v_out_params = values[1];
    __pyx_v_operation = values[2];
    __pyx_v_name = values[3];
    __pyx_v_reduce_dims = values[4];
    __pyx_v_preamble = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 494, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("cupy.core.core.ElementwiseKernel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel___init__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self), __pyx_v_in_params, __pyx_v_out_params, __pyx_v_operation, __pyx_v_name, __pyx_v_reduce_dims, __pyx_v_preamble, __pyx_v_kwargs);

  /* "cupy/core/elementwise.pxi":494
 *         readonly object kwargs
 * 
 *     def __init__(self, in_params, out_params, operation,             # <<<<<<<<<<<<<<
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         if not compiler.is_valid_kernel_name(name):
 */

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

static int __pyx_pf_4cupy_4core_4core_17ElementwiseKernel___init__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self, PyObject *__pyx_v_in_params, PyObject *__pyx_v_out_params, PyObject *__pyx_v_operation, PyObject *__pyx_v_name, PyObject *__pyx_v_reduce_dims, PyObject *__pyx_v_preamble, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_param_rest = NULL;
  PyObject *__pyx_v_names = NULL;
  PyObject *__pyx_v_p = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/elementwise.pxi":496
 *     def __init__(self, in_params, out_params, operation,
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         if not compiler.is_valid_kernel_name(name):             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'Invalid kernel name: "%s"' % name)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_compiler); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 496, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_is_valid_kernel_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 496, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 496, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_name};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 496, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_name};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 496, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 496, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_INCREF(__pyx_v_name);
      __Pyx_GIVEREF(__pyx_v_name);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_name);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 496, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(1, 496, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = ((!__pyx_t_5) != 0);
  if (__pyx_t_6) {

    /* "cupy/core/elementwise.pxi":498
 *         if not compiler.is_valid_kernel_name(name):
 *             raise ValueError(
 *                 'Invalid kernel name: "%s"' % name)             # <<<<<<<<<<<<<<
 * 
 *         self.in_params = _get_param_info(in_params, True)
 */
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_kernel_name_s, __pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 498, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "cupy/core/elementwise.pxi":497
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         if not compiler.is_valid_kernel_name(name):
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'Invalid kernel name: "%s"' % name)
 * 
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 497, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 497, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(1, 497, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":496
 *     def __init__(self, in_params, out_params, operation,
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         if not compiler.is_valid_kernel_name(name):             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'Invalid kernel name: "%s"' % name)
 */
  }

  /* "cupy/core/elementwise.pxi":500
 *                 'Invalid kernel name: "%s"' % name)
 * 
 *         self.in_params = _get_param_info(in_params, True)             # <<<<<<<<<<<<<<
 *         self.out_params = _get_param_info(out_params, False)
 *         self.nin = len(self.in_params)
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_7 = 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_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_in_params, Py_True};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 500, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_in_params, Py_True};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 500, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_2 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 500, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_v_in_params);
    __Pyx_GIVEREF(__pyx_v_in_params);
    PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_7, __pyx_v_in_params);
    __Pyx_INCREF(Py_True);
    __Pyx_GIVEREF(Py_True);
    PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_7, Py_True);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 500, __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;
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 500, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->in_params);
  __Pyx_DECREF(__pyx_v_self->in_params);
  __pyx_v_self->in_params = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":501
 * 
 *         self.in_params = _get_param_info(in_params, True)
 *         self.out_params = _get_param_info(out_params, False)             # <<<<<<<<<<<<<<
 *         self.nin = len(self.in_params)
 *         self.nout = len(self.out_params)
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  __pyx_t_7 = 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_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_out_params, Py_False};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 501, __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, __pyx_v_out_params, Py_False};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 501, __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_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 501, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_v_out_params);
    __Pyx_GIVEREF(__pyx_v_out_params);
    PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_7, __pyx_v_out_params);
    __Pyx_INCREF(Py_False);
    __Pyx_GIVEREF(Py_False);
    PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_7, Py_False);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 501, __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(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 501, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->out_params);
  __Pyx_DECREF(__pyx_v_self->out_params);
  __pyx_v_self->out_params = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":502
 *         self.in_params = _get_param_info(in_params, True)
 *         self.out_params = _get_param_info(out_params, False)
 *         self.nin = len(self.in_params)             # <<<<<<<<<<<<<<
 *         self.nout = len(self.out_params)
 *         self.nargs = self.nin + self.nout
 */
  __pyx_t_1 = __pyx_v_self->in_params;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 502, __pyx_L1_error)
  }
  __pyx_t_8 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(1, 502, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->nin = __pyx_t_8;

  /* "cupy/core/elementwise.pxi":503
 *         self.out_params = _get_param_info(out_params, False)
 *         self.nin = len(self.in_params)
 *         self.nout = len(self.out_params)             # <<<<<<<<<<<<<<
 *         self.nargs = self.nin + self.nout
 *         param_rest = _get_param_info('CIndexer _ind', False)
 */
  __pyx_t_1 = __pyx_v_self->out_params;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 503, __pyx_L1_error)
  }
  __pyx_t_8 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(1, 503, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->nout = __pyx_t_8;

  /* "cupy/core/elementwise.pxi":504
 *         self.nin = len(self.in_params)
 *         self.nout = len(self.out_params)
 *         self.nargs = self.nin + self.nout             # <<<<<<<<<<<<<<
 *         param_rest = _get_param_info('CIndexer _ind', False)
 *         self.params = self.in_params + self.out_params + param_rest
 */
  __pyx_v_self->nargs = (__pyx_v_self->nin + __pyx_v_self->nout);

  /* "cupy/core/elementwise.pxi":505
 *         self.nout = len(self.out_params)
 *         self.nargs = self.nin + self.nout
 *         param_rest = _get_param_info('CIndexer _ind', False)             # <<<<<<<<<<<<<<
 *         self.params = self.in_params + self.out_params + param_rest
 *         self.operation = operation
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_param_rest = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":506
 *         self.nargs = self.nin + self.nout
 *         param_rest = _get_param_info('CIndexer _ind', False)
 *         self.params = self.in_params + self.out_params + param_rest             # <<<<<<<<<<<<<<
 *         self.operation = operation
 *         self.name = name
 */
  __pyx_t_3 = PyNumber_Add(__pyx_v_self->in_params, __pyx_v_self->out_params); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 506, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_v_param_rest); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 506, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 506, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->params);
  __Pyx_DECREF(__pyx_v_self->params);
  __pyx_v_self->params = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":507
 *         param_rest = _get_param_info('CIndexer _ind', False)
 *         self.params = self.in_params + self.out_params + param_rest
 *         self.operation = operation             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self.reduce_dims = reduce_dims
 */
  if (!(likely(PyString_CheckExact(__pyx_v_operation))||((__pyx_v_operation) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_operation)->tp_name), 0))) __PYX_ERR(1, 507, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_operation;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->operation);
  __Pyx_DECREF(__pyx_v_self->operation);
  __pyx_v_self->operation = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":508
 *         self.params = self.in_params + self.out_params + param_rest
 *         self.operation = operation
 *         self.name = name             # <<<<<<<<<<<<<<
 *         self.reduce_dims = reduce_dims
 *         self.preamble = preamble
 */
  if (!(likely(PyString_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(1, 508, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_name;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(__pyx_v_self->name);
  __pyx_v_self->name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":509
 *         self.operation = operation
 *         self.name = name
 *         self.reduce_dims = reduce_dims             # <<<<<<<<<<<<<<
 *         self.preamble = preamble
 *         self.kwargs = frozenset(kwargs.items())
 */
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_reduce_dims); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 509, __pyx_L1_error)
  __pyx_v_self->reduce_dims = __pyx_t_6;

  /* "cupy/core/elementwise.pxi":510
 *         self.name = name
 *         self.reduce_dims = reduce_dims
 *         self.preamble = preamble             # <<<<<<<<<<<<<<
 *         self.kwargs = frozenset(kwargs.items())
 *         names = [p.name for p in self.in_params + self.out_params]
 */
  if (!(likely(PyString_CheckExact(__pyx_v_preamble))||((__pyx_v_preamble) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_preamble)->tp_name), 0))) __PYX_ERR(1, 510, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_preamble;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->preamble);
  __Pyx_DECREF(__pyx_v_self->preamble);
  __pyx_v_self->preamble = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":511
 *         self.reduce_dims = reduce_dims
 *         self.preamble = preamble
 *         self.kwargs = frozenset(kwargs.items())             # <<<<<<<<<<<<<<
 *         names = [p.name for p in self.in_params + self.out_params]
 *         if 'i' in names:
 */
  __pyx_t_1 = __Pyx_PyDict_Items(__pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 511, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyFrozenSet_New(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 511, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->kwargs);
  __Pyx_DECREF(__pyx_v_self->kwargs);
  __pyx_v_self->kwargs = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":512
 *         self.preamble = preamble
 *         self.kwargs = frozenset(kwargs.items())
 *         names = [p.name for p in self.in_params + self.out_params]             # <<<<<<<<<<<<<<
 *         if 'i' in names:
 *             raise ValueError("Can not use 'i' as a parameter name")
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 512, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyNumber_Add(__pyx_v_self->in_params, __pyx_v_self->out_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 512, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 512, __pyx_L1_error)
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 512, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 512, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_1))) __PYX_ERR(1, 512, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_names = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":513
 *         self.kwargs = frozenset(kwargs.items())
 *         names = [p.name for p in self.in_params + self.out_params]
 *         if 'i' in names:             # <<<<<<<<<<<<<<
 *             raise ValueError("Can not use 'i' as a parameter name")
 * 
 */
  __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_n_s_i, __pyx_v_names, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 513, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_6 != 0);
  if (__pyx_t_5) {

    /* "cupy/core/elementwise.pxi":514
 *         names = [p.name for p in self.in_params + self.out_params]
 *         if 'i' in names:
 *             raise ValueError("Can not use 'i' as a parameter name")             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, *args, **kwargs):
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__83, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 514, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 514, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":513
 *         self.kwargs = frozenset(kwargs.items())
 *         names = [p.name for p in self.in_params + self.out_params]
 *         if 'i' in names:             # <<<<<<<<<<<<<<
 *             raise ValueError("Can not use 'i' as a parameter name")
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":494
 *         readonly object kwargs
 * 
 *     def __init__(self, in_params, out_params, operation,             # <<<<<<<<<<<<<<
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         if not compiler.is_valid_kernel_name(name):
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.ElementwiseKernel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_param_rest);
  __Pyx_XDECREF(__pyx_v_names);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":516
 *             raise ValueError("Can not use 'i' as a parameter name")
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Compiles and invokes the elementwise kernel.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_17ElementwiseKernel_2__call__[] = "Compiles and invokes the elementwise kernel.\n\n        The compilation runs only if the kernel is not cached. Note that the\n        kernels with different argument dtypes or dimensions are not\n        compatible. It means that single ElementwiseKernel object may be\n        compiled into multiple kernel binaries.\n\n        Args:\n            args: Arguments of the kernel.\n            size (int): Range size of the indices.  By default, the range size\n                is automatically determined from the result of broadcasting.\n                This parameter must be specified if and only if all ndarrays\n                are `raw` and the range size cannot be determined\n                automatically.\n\n        Returns:\n            Arrays are returned according to the ``out_params`` argument of the\n            ``__init__`` method.\n\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_4cupy_4core_4core_17ElementwiseKernel_2__call__;
#endif
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__call__", 1))) return NULL;
  __pyx_v_kwargs = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_2__call__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_2__call__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_4cupy_4cuda_8function_Function *__pyx_v_kern = 0;
  PyObject *__pyx_v_size = NULL;
  PyObject *__pyx_v_stream = NULL;
  Py_ssize_t __pyx_v_n_args;
  PyObject *__pyx_v_values = NULL;
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_in_args = NULL;
  PyObject *__pyx_v_out_args = NULL;
  PyObject *__pyx_v_in_ndarray_types = NULL;
  PyObject *__pyx_v_out_ndarray_types = NULL;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  PyObject *__pyx_v_types = NULL;
  int __pyx_v_is_size_specified;
  PyObject *__pyx_v_ret = NULL;
  PyObject *__pyx_v_inout_args = NULL;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_indexer = NULL;
  PyObject *__pyx_v_args_info = NULL;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  struct __pyx_opt_args_4cupy_4core_4core__get_out_args_with_params __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  struct __pyx_opt_args_4cupy_4cuda_8function_8Function_linear_launch __pyx_t_17;
  __Pyx_RefNannySetupContext("__call__", 0);
  __Pyx_INCREF(__pyx_v_args);

  /* "cupy/core/elementwise.pxi":540
 *         cdef function.Function kern
 * 
 *         size = kwargs.pop('size', None)             # <<<<<<<<<<<<<<
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 540, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 540, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_size = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":541
 * 
 *         size = kwargs.pop('size', None)
 *         stream = kwargs.pop('stream', None)             # <<<<<<<<<<<<<<
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 541, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__85, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 541, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_stream = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":542
 *         size = kwargs.pop('size', None)
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 542, __pyx_L1_error)
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":543
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)             # <<<<<<<<<<<<<<
 * 
 *         n_args = len(args)
 */
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_arguments_s, __pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 543, __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_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(1, 543, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":542
 *         size = kwargs.pop('size', None)
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":545
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 *         n_args = len(args)             # <<<<<<<<<<<<<<
 *         if n_args != self.nin and n_args != self.nargs:
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 545, __pyx_L1_error)
  __pyx_v_n_args = __pyx_t_4;

  /* "cupy/core/elementwise.pxi":546
 * 
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 *         args = _preprocess_args(args)
 */
  __pyx_t_5 = ((__pyx_v_n_args != __pyx_v_self->nin) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_v_n_args != __pyx_v_self->nargs) != 0);
  __pyx_t_3 = __pyx_t_5;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":547
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:
 *             raise TypeError('Wrong number of arguments for %s' % self.name)             # <<<<<<<<<<<<<<
 *         args = _preprocess_args(args)
 * 
 */
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_number_of_arguments_for_s, __pyx_v_self->name); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 547, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 547, __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_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 547, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(1, 547, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":546
 * 
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 *         args = _preprocess_args(args)
 */
  }

  /* "cupy/core/elementwise.pxi":548
 *         if n_args != self.nin and n_args != self.nargs:
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 *         args = _preprocess_args(args)             # <<<<<<<<<<<<<<
 * 
 *         values, shape = _broadcast(args, self.params, size is not None)
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_v_args, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 548, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":550
 *         args = _preprocess_args(args)
 * 
 *         values, shape = _broadcast(args, self.params, size is not None)             # <<<<<<<<<<<<<<
 *         in_args = values[:self.nin]
 *         out_args = values[self.nin:]
 */
  if (!(likely(PyList_CheckExact(__pyx_v_args))||((__pyx_v_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_args)->tp_name), 0))) __PYX_ERR(1, 550, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_self->params;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3 = (__pyx_v_size != Py_None);
  __pyx_t_2 = __pyx_f_4cupy_4core_4core__broadcast(((PyObject*)__pyx_v_args), ((PyObject*)__pyx_t_1), __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_2 != Py_None)) {
    PyObject* sequence = __pyx_t_2;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(1, 550, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_6);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 550, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 550, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 550, __pyx_L1_error)
  }
  __pyx_v_values = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_shape = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":551
 * 
 *         values, shape = _broadcast(args, self.params, size is not None)
 *         in_args = values[:self.nin]             # <<<<<<<<<<<<<<
 *         out_args = values[self.nin:]
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_values, 0, __pyx_v_self->nin, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_in_args = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":552
 *         values, shape = _broadcast(args, self.params, size is not None)
 *         in_args = values[:self.nin]
 *         out_args = values[self.nin:]             # <<<<<<<<<<<<<<
 * 
 *         in_ndarray_types = tuple(
 */
  __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_values, __pyx_v_self->nin, 0, NULL, NULL, NULL, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_out_args = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":555
 * 
 *         in_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None             # <<<<<<<<<<<<<<
 *              for a in in_args])
 *         out_ndarray_types = tuple([a.dtype.type for a in out_args])
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 555, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/elementwise.pxi":556
 *         in_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in in_args])             # <<<<<<<<<<<<<<
 *         out_ndarray_types = tuple([a.dtype.type for a in out_args])
 * 
 */
  if (likely(PyList_CheckExact(__pyx_v_in_args)) || PyTuple_CheckExact(__pyx_v_in_args)) {
    __pyx_t_6 = __pyx_v_in_args; __Pyx_INCREF(__pyx_t_6); __pyx_t_4 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_in_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 556, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_6))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 556, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 556, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 556, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 556, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_7(__pyx_t_6);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 556, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":555
 * 
 *         in_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None             # <<<<<<<<<<<<<<
 *              for a in in_args])
 *         out_ndarray_types = tuple([a.dtype.type for a in out_args])
 */
    __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
    if ((__pyx_t_3 != 0)) {
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 555, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 555, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_1 = __pyx_t_9;
      __pyx_t_9 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_t_1 = Py_None;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_1))) __PYX_ERR(1, 555, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":556
 *         in_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in in_args])             # <<<<<<<<<<<<<<
 *         out_ndarray_types = tuple([a.dtype.type for a in out_args])
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":554
 *         out_args = values[self.nin:]
 * 
 *         in_ndarray_types = tuple(             # <<<<<<<<<<<<<<
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in in_args])
 */
  __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 554, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_in_ndarray_types = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":557
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in in_args])
 *         out_ndarray_types = tuple([a.dtype.type for a in out_args])             # <<<<<<<<<<<<<<
 * 
 *         in_types, out_types, types = _decide_params_type(
 */
  __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (likely(PyList_CheckExact(__pyx_v_out_args)) || PyTuple_CheckExact(__pyx_v_out_args)) {
    __pyx_t_2 = __pyx_v_out_args; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_out_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 557, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 557, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      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_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 557, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 557, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 557, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 557, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_7(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 557, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 557, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 557, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_9))) __PYX_ERR(1, 557, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_6)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_out_ndarray_types = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":559
 *         out_ndarray_types = tuple([a.dtype.type for a in out_args])
 * 
 *         in_types, out_types, types = _decide_params_type(             # <<<<<<<<<<<<<<
 *             self.in_params, self.out_params,
 *             in_ndarray_types, out_ndarray_types)
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_decide_params_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 559, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "cupy/core/elementwise.pxi":561
 *         in_types, out_types, types = _decide_params_type(
 *             self.in_params, self.out_params,
 *             in_ndarray_types, out_ndarray_types)             # <<<<<<<<<<<<<<
 * 
 *         is_size_specified = False
 */
  __pyx_t_9 = NULL;
  __pyx_t_10 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_v_self->in_params, __pyx_v_self->out_params, __pyx_v_in_ndarray_types, __pyx_v_out_ndarray_types};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 559, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_v_self->in_params, __pyx_v_self->out_params, __pyx_v_in_ndarray_types, __pyx_v_out_ndarray_types};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 559, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  {
    __pyx_t_1 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 559, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (__pyx_t_9) {
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9); __pyx_t_9 = NULL;
    }
    __Pyx_INCREF(__pyx_v_self->in_params);
    __Pyx_GIVEREF(__pyx_v_self->in_params);
    PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_10, __pyx_v_self->in_params);
    __Pyx_INCREF(__pyx_v_self->out_params);
    __Pyx_GIVEREF(__pyx_v_self->out_params);
    PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_10, __pyx_v_self->out_params);
    __Pyx_INCREF(__pyx_v_in_ndarray_types);
    __Pyx_GIVEREF(__pyx_v_in_ndarray_types);
    PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_10, __pyx_v_in_ndarray_types);
    __Pyx_INCREF(__pyx_v_out_ndarray_types);
    __Pyx_GIVEREF(__pyx_v_out_ndarray_types);
    PyTuple_SET_ITEM(__pyx_t_1, 3+__pyx_t_10, __pyx_v_out_ndarray_types);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 559, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(1, 559, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_9 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_9);
    #else
    __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 559, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 559, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 559, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 559, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_11 = Py_TYPE(__pyx_t_8)->tp_iternext;
    index = 0; __pyx_t_6 = __pyx_t_11(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L11_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_6);
    index = 1; __pyx_t_1 = __pyx_t_11(__pyx_t_8); if (unlikely(!__pyx_t_1)) goto __pyx_L11_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 2; __pyx_t_9 = __pyx_t_11(__pyx_t_8); if (unlikely(!__pyx_t_9)) goto __pyx_L11_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_9);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_8), 3) < 0) __PYX_ERR(1, 559, __pyx_L1_error)
    __pyx_t_11 = NULL;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    goto __pyx_L12_unpacking_done;
    __pyx_L11_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_11 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(1, 559, __pyx_L1_error)
    __pyx_L12_unpacking_done:;
  }

  /* "cupy/core/elementwise.pxi":559
 *         out_ndarray_types = tuple([a.dtype.type for a in out_args])
 * 
 *         in_types, out_types, types = _decide_params_type(             # <<<<<<<<<<<<<<
 *             self.in_params, self.out_params,
 *             in_ndarray_types, out_ndarray_types)
 */
  __pyx_v_in_types = __pyx_t_6;
  __pyx_t_6 = 0;
  __pyx_v_out_types = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_types = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":563
 *             in_ndarray_types, out_ndarray_types)
 * 
 *         is_size_specified = False             # <<<<<<<<<<<<<<
 *         if size is not None:
 *             shape = size,
 */
  __pyx_v_is_size_specified = 0;

  /* "cupy/core/elementwise.pxi":564
 * 
 *         is_size_specified = False
 *         if size is not None:             # <<<<<<<<<<<<<<
 *             shape = size,
 *             is_size_specified = True
 */
  __pyx_t_3 = (__pyx_v_size != Py_None);
  __pyx_t_5 = (__pyx_t_3 != 0);
  if (__pyx_t_5) {

    /* "cupy/core/elementwise.pxi":565
 *         is_size_specified = False
 *         if size is not None:
 *             shape = size,             # <<<<<<<<<<<<<<
 *             is_size_specified = True
 * 
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_size);
    __Pyx_GIVEREF(__pyx_v_size);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_size);
    __Pyx_DECREF_SET(__pyx_v_shape, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":566
 *         if size is not None:
 *             shape = size,
 *             is_size_specified = True             # <<<<<<<<<<<<<<
 * 
 *         out_args = _get_out_args_with_params(
 */
    __pyx_v_is_size_specified = 1;

    /* "cupy/core/elementwise.pxi":564
 * 
 *         is_size_specified = False
 *         if size is not None:             # <<<<<<<<<<<<<<
 *             shape = size,
 *             is_size_specified = True
 */
  }

  /* "cupy/core/elementwise.pxi":569
 * 
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, shape, self.out_params, is_size_specified)             # <<<<<<<<<<<<<<
 *         if self.nout == 1:
 *             ret = out_args[0]
 */
  if (!(likely(PyList_CheckExact(__pyx_v_out_args))||((__pyx_v_out_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_out_args)->tp_name), 0))) __PYX_ERR(1, 569, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_out_types))||((__pyx_v_out_types) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_out_types)->tp_name), 0))) __PYX_ERR(1, 569, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_shape))||((__pyx_v_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_shape)->tp_name), 0))) __PYX_ERR(1, 569, __pyx_L1_error)
  __pyx_t_2 = __pyx_v_self->out_params;
  __Pyx_INCREF(__pyx_t_2);

  /* "cupy/core/elementwise.pxi":568
 *             is_size_specified = True
 * 
 *         out_args = _get_out_args_with_params(             # <<<<<<<<<<<<<<
 *             out_args, out_types, shape, self.out_params, is_size_specified)
 *         if self.nout == 1:
 */
  __pyx_t_12.__pyx_n = 1;
  __pyx_t_12.is_size_specified = __pyx_v_is_size_specified;
  __pyx_t_9 = __pyx_f_4cupy_4core_4core__get_out_args_with_params(((PyObject*)__pyx_v_out_args), ((PyObject*)__pyx_v_out_types), ((PyObject*)__pyx_v_shape), ((PyObject*)__pyx_t_2), &__pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_out_args, __pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":570
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, shape, self.out_params, is_size_specified)
 *         if self.nout == 1:             # <<<<<<<<<<<<<<
 *             ret = out_args[0]
 *         else:
 */
  __pyx_t_5 = ((__pyx_v_self->nout == 1) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/elementwise.pxi":571
 *             out_args, out_types, shape, self.out_params, is_size_specified)
 *         if self.nout == 1:
 *             ret = out_args[0]             # <<<<<<<<<<<<<<
 *         else:
 *             ret = tuple(out_args)
 */
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 571, __pyx_L1_error)
    }
    __pyx_t_9 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 571, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_v_ret = __pyx_t_9;
    __pyx_t_9 = 0;

    /* "cupy/core/elementwise.pxi":570
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, shape, self.out_params, is_size_specified)
 *         if self.nout == 1:             # <<<<<<<<<<<<<<
 *             ret = out_args[0]
 *         else:
 */
    goto __pyx_L14;
  }

  /* "cupy/core/elementwise.pxi":573
 *             ret = out_args[0]
 *         else:
 *             ret = tuple(out_args)             # <<<<<<<<<<<<<<
 * 
 *         if 0 in shape:
 */
  /*else*/ {
    __pyx_t_9 = PySequence_Tuple(__pyx_v_out_args); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 573, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_v_ret = __pyx_t_9;
    __pyx_t_9 = 0;
  }
  __pyx_L14:;

  /* "cupy/core/elementwise.pxi":575
 *             ret = tuple(out_args)
 * 
 *         if 0 in shape:             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
  __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_int_0, __pyx_v_shape, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(1, 575, __pyx_L1_error)
  __pyx_t_3 = (__pyx_t_5 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":576
 * 
 *         if 0 in shape:
 *             return ret             # <<<<<<<<<<<<<<
 * 
 *         inout_args = [x if isinstance(x, ndarray) else in_types[i](x)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_ret);
    __pyx_r = __pyx_v_ret;
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":575
 *             ret = tuple(out_args)
 * 
 *         if 0 in shape:             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":578
 *             return ret
 * 
 *         inout_args = [x if isinstance(x, ndarray) else in_types[i](x)             # <<<<<<<<<<<<<<
 *                       for i, x in enumerate(in_args)]
 *         inout_args += out_args
 */
  __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 578, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_2 = __pyx_int_0;

  /* "cupy/core/elementwise.pxi":579
 * 
 *         inout_args = [x if isinstance(x, ndarray) else in_types[i](x)
 *                       for i, x in enumerate(in_args)]             # <<<<<<<<<<<<<<
 *         inout_args += out_args
 * 
 */
  if (likely(PyList_CheckExact(__pyx_v_in_args)) || PyTuple_CheckExact(__pyx_v_in_args)) {
    __pyx_t_1 = __pyx_v_in_args; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_in_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 579, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 579, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 579, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 579, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 579, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 579, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 579, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2);
    __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 579, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2);
    __pyx_t_2 = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":578
 *             return ret
 * 
 *         inout_args = [x if isinstance(x, ndarray) else in_types[i](x)             # <<<<<<<<<<<<<<
 *                       for i, x in enumerate(in_args)]
 *         inout_args += out_args
 */
    __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_x, __pyx_ptype_4cupy_4core_4core_ndarray); 
    if ((__pyx_t_3 != 0)) {
      __Pyx_INCREF(__pyx_v_x);
      __pyx_t_6 = __pyx_v_x;
    } else {
      __pyx_t_13 = PyObject_GetItem(__pyx_v_in_types, __pyx_v_i); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 578, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
        __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
        if (likely(__pyx_t_14)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_13, function);
        }
      }
      if (!__pyx_t_14) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_v_x); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 578, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_13)) {
          PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_v_x};
          __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 578, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GOTREF(__pyx_t_8);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
          PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_v_x};
          __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 578, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GOTREF(__pyx_t_8);
        } else
        #endif
        {
          __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 578, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
          __Pyx_INCREF(__pyx_v_x);
          __Pyx_GIVEREF(__pyx_v_x);
          PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_v_x);
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_15, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 578, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_6 = __pyx_t_8;
      __pyx_t_8 = 0;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_9, (PyObject*)__pyx_t_6))) __PYX_ERR(1, 578, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":579
 * 
 *         inout_args = [x if isinstance(x, ndarray) else in_types[i](x)
 *                       for i, x in enumerate(in_args)]             # <<<<<<<<<<<<<<
 *         inout_args += out_args
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_inout_args = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":580
 *         inout_args = [x if isinstance(x, ndarray) else in_types[i](x)
 *                       for i, x in enumerate(in_args)]
 *         inout_args += out_args             # <<<<<<<<<<<<<<
 * 
 *         if self.reduce_dims:
 */
  __pyx_t_9 = PyNumber_InPlaceAdd(__pyx_v_inout_args, __pyx_v_out_args); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF_SET(__pyx_v_inout_args, __pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":582
 *         inout_args += out_args
 * 
 *         if self.reduce_dims:             # <<<<<<<<<<<<<<
 *             inout_args, shape = _reduce_dims(
 *                 inout_args, self.params, shape)
 */
  __pyx_t_3 = (__pyx_v_self->reduce_dims != 0);
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":584
 *         if self.reduce_dims:
 *             inout_args, shape = _reduce_dims(
 *                 inout_args, self.params, shape)             # <<<<<<<<<<<<<<
 *         indexer = Indexer(shape)
 *         inout_args.append(indexer)
 */
    if (!(likely(PyList_CheckExact(__pyx_v_inout_args))||((__pyx_v_inout_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_inout_args)->tp_name), 0))) __PYX_ERR(1, 584, __pyx_L1_error)
    __pyx_t_9 = __pyx_v_self->params;
    __Pyx_INCREF(__pyx_t_9);
    if (!(likely(PyTuple_CheckExact(__pyx_v_shape))||((__pyx_v_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_shape)->tp_name), 0))) __PYX_ERR(1, 584, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":583
 * 
 *         if self.reduce_dims:
 *             inout_args, shape = _reduce_dims(             # <<<<<<<<<<<<<<
 *                 inout_args, self.params, shape)
 *         indexer = Indexer(shape)
 */
    __pyx_t_2 = __pyx_f_4cupy_4core_4core__reduce_dims(((PyObject*)__pyx_v_inout_args), ((PyObject*)__pyx_t_9), ((PyObject*)__pyx_v_shape), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 583, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (likely(__pyx_t_2 != Py_None)) {
      PyObject* sequence = __pyx_t_2;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(1, 583, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_1);
      #else
      __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 583, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 583, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 583, __pyx_L1_error)
    }
    __Pyx_DECREF_SET(__pyx_v_inout_args, __pyx_t_9);
    __pyx_t_9 = 0;
    __Pyx_DECREF_SET(__pyx_v_shape, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":582
 *         inout_args += out_args
 * 
 *         if self.reduce_dims:             # <<<<<<<<<<<<<<
 *             inout_args, shape = _reduce_dims(
 *                 inout_args, self.params, shape)
 */
  }

  /* "cupy/core/elementwise.pxi":585
 *             inout_args, shape = _reduce_dims(
 *                 inout_args, self.params, shape)
 *         indexer = Indexer(shape)             # <<<<<<<<<<<<<<
 *         inout_args.append(indexer)
 * 
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 585, __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_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 585, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":586
 *                 inout_args, self.params, shape)
 *         indexer = Indexer(shape)
 *         inout_args.append(indexer)             # <<<<<<<<<<<<<<
 * 
 *         args_info = _get_args_info(inout_args)
 */
  __pyx_t_16 = __Pyx_PyObject_Append(__pyx_v_inout_args, ((PyObject *)__pyx_v_indexer)); if (unlikely(__pyx_t_16 == -1)) __PYX_ERR(1, 586, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":588
 *         inout_args.append(indexer)
 * 
 *         args_info = _get_args_info(inout_args)             # <<<<<<<<<<<<<<
 *         kern = _get_elementwise_kernel(
 *             args_info, types, self.params, self.operation,
 */
  if (!(likely(PyList_CheckExact(__pyx_v_inout_args))||((__pyx_v_inout_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_inout_args)->tp_name), 0))) __PYX_ERR(1, 588, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_args_info(((PyObject*)__pyx_v_inout_args), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_args_info = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":589
 * 
 *         args_info = _get_args_info(inout_args)
 *         kern = _get_elementwise_kernel(             # <<<<<<<<<<<<<<
 *             args_info, types, self.params, self.operation,
 *             self.name, self.preamble, self.kwargs)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_elementwise_kernel); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/elementwise.pxi":591
 *         kern = _get_elementwise_kernel(
 *             args_info, types, self.params, self.operation,
 *             self.name, self.preamble, self.kwargs)             # <<<<<<<<<<<<<<
 *         kern.linear_launch(indexer.size, inout_args, shared_mem=0,
 *                            block_max_size=128, stream=stream)
 */
  __pyx_t_9 = NULL;
  __pyx_t_10 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_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);
      __pyx_t_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[8] = {__pyx_t_9, __pyx_v_args_info, __pyx_v_types, __pyx_v_self->params, __pyx_v_self->operation, __pyx_v_self->name, __pyx_v_self->preamble, __pyx_v_self->kwargs};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 7+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 589, __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_2)) {
    PyObject *__pyx_temp[8] = {__pyx_t_9, __pyx_v_args_info, __pyx_v_types, __pyx_v_self->params, __pyx_v_self->operation, __pyx_v_self->name, __pyx_v_self->preamble, __pyx_v_self->kwargs};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 7+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 589, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(7+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 589, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_9) {
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = NULL;
    }
    __Pyx_INCREF(__pyx_v_args_info);
    __Pyx_GIVEREF(__pyx_v_args_info);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_10, __pyx_v_args_info);
    __Pyx_INCREF(__pyx_v_types);
    __Pyx_GIVEREF(__pyx_v_types);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_10, __pyx_v_types);
    __Pyx_INCREF(__pyx_v_self->params);
    __Pyx_GIVEREF(__pyx_v_self->params);
    PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_10, __pyx_v_self->params);
    __Pyx_INCREF(__pyx_v_self->operation);
    __Pyx_GIVEREF(__pyx_v_self->operation);
    PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_10, __pyx_v_self->operation);
    __Pyx_INCREF(__pyx_v_self->name);
    __Pyx_GIVEREF(__pyx_v_self->name);
    PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_10, __pyx_v_self->name);
    __Pyx_INCREF(__pyx_v_self->preamble);
    __Pyx_GIVEREF(__pyx_v_self->preamble);
    PyTuple_SET_ITEM(__pyx_t_6, 5+__pyx_t_10, __pyx_v_self->preamble);
    __Pyx_INCREF(__pyx_v_self->kwargs);
    __Pyx_GIVEREF(__pyx_v_self->kwargs);
    PyTuple_SET_ITEM(__pyx_t_6, 6+__pyx_t_10, __pyx_v_self->kwargs);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 589, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":589
 * 
 *         args_info = _get_args_info(inout_args)
 *         kern = _get_elementwise_kernel(             # <<<<<<<<<<<<<<
 *             args_info, types, self.params, self.operation,
 *             self.name, self.preamble, self.kwargs)
 */
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4cuda_8function_Function))))) __PYX_ERR(1, 589, __pyx_L1_error)
  __pyx_v_kern = ((struct __pyx_obj_4cupy_4cuda_8function_Function *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":592
 *             args_info, types, self.params, self.operation,
 *             self.name, self.preamble, self.kwargs)
 *         kern.linear_launch(indexer.size, inout_args, shared_mem=0,             # <<<<<<<<<<<<<<
 *                            block_max_size=128, stream=stream)
 *         return ret
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.shared_mem = 0;
  __pyx_t_17.block_max_size = 0x80;
  __pyx_t_17.stream = __pyx_v_stream;
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Function *)__pyx_v_kern->__pyx_vtab)->linear_launch(__pyx_v_kern, __pyx_v_indexer->size, __pyx_v_inout_args, 0, &__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 592, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":594
 *         kern.linear_launch(indexer.size, inout_args, shared_mem=0,
 *                            block_max_size=128, stream=stream)
 *         return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ret);
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":516
 *             raise ValueError("Can not use 'i' as a parameter name")
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Compiles and invokes the elementwise kernel.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("cupy.core.core.ElementwiseKernel.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF((PyObject *)__pyx_v_kern);
  __Pyx_XDECREF(__pyx_v_size);
  __Pyx_XDECREF(__pyx_v_stream);
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_in_args);
  __Pyx_XDECREF(__pyx_v_out_args);
  __Pyx_XDECREF(__pyx_v_in_ndarray_types);
  __Pyx_XDECREF(__pyx_v_out_ndarray_types);
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XDECREF(__pyx_v_types);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_inout_args);
  __Pyx_XDECREF((PyObject *)__pyx_v_indexer);
  __Pyx_XDECREF(__pyx_v_args_info);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":482
 * 
 *     cdef:
 *         readonly tuple in_params             # <<<<<<<<<<<<<<
 *         readonly tuple out_params
 *         readonly Py_ssize_t nin
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_9in_params_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_9in_params_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_9in_params___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_9in_params___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->in_params);
  __pyx_r = __pyx_v_self->in_params;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":483
 *     cdef:
 *         readonly tuple in_params
 *         readonly tuple out_params             # <<<<<<<<<<<<<<
 *         readonly Py_ssize_t nin
 *         readonly Py_ssize_t nout
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_10out_params_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_10out_params_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_10out_params___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_10out_params___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->out_params);
  __pyx_r = __pyx_v_self->out_params;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":484
 *         readonly tuple in_params
 *         readonly tuple out_params
 *         readonly Py_ssize_t nin             # <<<<<<<<<<<<<<
 *         readonly Py_ssize_t nout
 *         readonly Py_ssize_t nargs
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_3nin_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_3nin_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_3nin___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_3nin___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->nin); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":485
 *         readonly tuple out_params
 *         readonly Py_ssize_t nin
 *         readonly Py_ssize_t nout             # <<<<<<<<<<<<<<
 *         readonly Py_ssize_t nargs
 *         readonly tuple params
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_4nout_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_4nout_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_4nout___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_4nout___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->nout); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":486
 *         readonly Py_ssize_t nin
 *         readonly Py_ssize_t nout
 *         readonly Py_ssize_t nargs             # <<<<<<<<<<<<<<
 *         readonly tuple params
 *         readonly str operation
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_5nargs_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_5nargs_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_5nargs___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_5nargs___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->nargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 486, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":487
 *         readonly Py_ssize_t nout
 *         readonly Py_ssize_t nargs
 *         readonly tuple params             # <<<<<<<<<<<<<<
 *         readonly str operation
 *         readonly str name
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_6params_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_6params_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_6params___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_6params___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->params);
  __pyx_r = __pyx_v_self->params;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":488
 *         readonly Py_ssize_t nargs
 *         readonly tuple params
 *         readonly str operation             # <<<<<<<<<<<<<<
 *         readonly str name
 *         readonly bint reduce_dims
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_9operation_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_9operation_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_9operation___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_9operation___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->operation);
  __pyx_r = __pyx_v_self->operation;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":489
 *         readonly tuple params
 *         readonly str operation
 *         readonly str name             # <<<<<<<<<<<<<<
 *         readonly bint reduce_dims
 *         readonly str preamble
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_4name_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_4name_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_4name___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_4name___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->name);
  __pyx_r = __pyx_v_self->name;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":490
 *         readonly str operation
 *         readonly str name
 *         readonly bint reduce_dims             # <<<<<<<<<<<<<<
 *         readonly str preamble
 *         readonly object kwargs
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_11reduce_dims_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_11reduce_dims_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_11reduce_dims___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_11reduce_dims___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->reduce_dims); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 490, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":491
 *         readonly str name
 *         readonly bint reduce_dims
 *         readonly str preamble             # <<<<<<<<<<<<<<
 *         readonly object kwargs
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_8preamble_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_8preamble_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_8preamble___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_8preamble___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->preamble);
  __pyx_r = __pyx_v_self->preamble;
  goto __pyx_L0;

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

/* "cupy/core/elementwise.pxi":492
 *         readonly bint reduce_dims
 *         readonly str preamble
 *         readonly object kwargs             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, in_params, out_params, operation,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_6kwargs_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_6kwargs_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_6kwargs___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_6kwargs___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->kwargs);
  __pyx_r = __pyx_v_self->kwargs;
  goto __pyx_L0;

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

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.in_params, self.kwargs, self.name, self.nargs, self.nin, self.nout, self.operation, self.out_params, self.params, self.preamble, self.reduce_dims)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_17ElementwiseKernel_4__reduce_cython__[] = "ElementwiseKernel.__reduce_cython__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_4__reduce_cython__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_4__reduce_cython__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.in_params, self.kwargs, self.name, self.nargs, self.nin, self.nout, self.operation, self.out_params, self.params, self.preamble, self.reduce_dims)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->nargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->nin); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_self->nout); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_self->reduce_dims); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(11); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_self->in_params);
  __Pyx_GIVEREF(__pyx_v_self->in_params);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self->in_params);
  __Pyx_INCREF(__pyx_v_self->kwargs);
  __Pyx_GIVEREF(__pyx_v_self->kwargs);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_self->kwargs);
  __Pyx_INCREF(__pyx_v_self->name);
  __Pyx_GIVEREF(__pyx_v_self->name);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_self->name);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 5, __pyx_t_3);
  __Pyx_INCREF(__pyx_v_self->operation);
  __Pyx_GIVEREF(__pyx_v_self->operation);
  PyTuple_SET_ITEM(__pyx_t_5, 6, __pyx_v_self->operation);
  __Pyx_INCREF(__pyx_v_self->out_params);
  __Pyx_GIVEREF(__pyx_v_self->out_params);
  PyTuple_SET_ITEM(__pyx_t_5, 7, __pyx_v_self->out_params);
  __Pyx_INCREF(__pyx_v_self->params);
  __Pyx_GIVEREF(__pyx_v_self->params);
  PyTuple_SET_ITEM(__pyx_t_5, 8, __pyx_v_self->params);
  __Pyx_INCREF(__pyx_v_self->preamble);
  __Pyx_GIVEREF(__pyx_v_self->preamble);
  PyTuple_SET_ITEM(__pyx_t_5, 9, __pyx_v_self->preamble);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 10, __pyx_t_4);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.in_params, self.kwargs, self.name, self.nargs, self.nin, self.nout, self.operation, self.out_params, self.params, self.preamble, self.reduce_dims)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_5 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v__dict = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "(tree fragment)":5
 *     state = (self.in_params, self.kwargs, self.name, self.nargs, self.nin, self.nout, self.operation, self.out_params, self.params, self.preamble, self.reduce_dims)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_6 = (__pyx_v__dict != Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.in_params is not None or self.kwargs is not None or self.name is not None or self.operation is not None or self.out_params is not None or self.params is not None or self.preamble is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.in_params, self.kwargs, self.name, self.nargs, self.nin, self.nout, self.operation, self.out_params, self.params, self.preamble, self.reduce_dims)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.in_params is not None or self.kwargs is not None or self.name is not None or self.operation is not None or self.out_params is not None or self.params is not None or self.preamble is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, None), state
 */
  /*else*/ {
    __pyx_t_6 = (__pyx_v_self->in_params != ((PyObject*)Py_None));
    __pyx_t_8 = (__pyx_t_6 != 0);
    if (!__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_v_self->kwargs != Py_None);
    __pyx_t_6 = (__pyx_t_8 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_7 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->name != ((PyObject*)Py_None));
    __pyx_t_8 = (__pyx_t_6 != 0);
    if (!__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_v_self->operation != ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_8 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_7 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->out_params != ((PyObject*)Py_None));
    __pyx_t_8 = (__pyx_t_6 != 0);
    if (!__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_v_self->params != ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_8 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_7 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->preamble != ((PyObject*)Py_None));
    __pyx_t_8 = (__pyx_t_6 != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_7;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.in_params is not None or self.kwargs is not None or self.name is not None or self.operation is not None or self.out_params is not None or self.params is not None or self.preamble is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, None), state
 *     else:
 */
  __pyx_t_7 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":11
 *         use_setstate = self.in_params is not None or self.kwargs is not None or self.name is not None or self.operation is not None or self.out_params is not None or self.params is not None or self.preamble is not None
 *     if use_setstate:
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_ElementwiseKernel); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_131642003);
    __Pyx_GIVEREF(__pyx_int_131642003);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_131642003);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_5, 2, Py_None);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.in_params is not None or self.kwargs is not None or self.name is not None or self.operation is not None or self.out_params is not None or self.params is not None or self.preamble is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, None), state
 *     else:
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ElementwiseKernel__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_ElementwiseKernel); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_131642003);
    __Pyx_GIVEREF(__pyx_int_131642003);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_131642003);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
    __pyx_t_3 = 0;
    __pyx_t_5 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.in_params, self.kwargs, self.name, self.nargs, self.nin, self.nout, self.operation, self.out_params, self.params, self.preamble, self.reduce_dims)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ElementwiseKernel.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ElementwiseKernel__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4cupy_4core_4core_17ElementwiseKernel_6__setstate_cython__[] = "ElementwiseKernel.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_6__setstate_cython__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_6__setstate_cython__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":15
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ElementwiseKernel__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(4, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core___pyx_unpickle_ElementwiseKernel__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ElementwiseKernel__set_state(self, __pyx_state)
 */

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

/* "cupy/core/elementwise.pxi":598
 * 
 * @util.memoize(for_each_device=True)
 * def _get_ufunc_kernel(             # <<<<<<<<<<<<<<
 *         in_types, out_types, routine, args_info, params, name, preamble):
 *     kernel_params = _get_kernel_params(params, args_info)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_31_get_ufunc_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_30_get_ufunc_kernel[] = "_get_ufunc_kernel(in_types, out_types, routine, args_info, params, name, preamble)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_31_get_ufunc_kernel = {"_get_ufunc_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_31_get_ufunc_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_30_get_ufunc_kernel};
static PyObject *__pyx_pw_4cupy_4core_4core_31_get_ufunc_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_in_types = 0;
  PyObject *__pyx_v_out_types = 0;
  PyObject *__pyx_v_routine = 0;
  PyObject *__pyx_v_args_info = 0;
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_ufunc_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_in_types,&__pyx_n_s_out_types,&__pyx_n_s_routine,&__pyx_n_s_args_info,&__pyx_n_s_params,&__pyx_n_s_name,&__pyx_n_s_preamble,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_in_types)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out_types)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_ufunc_kernel", 1, 7, 7, 1); __PYX_ERR(1, 598, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_routine)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_ufunc_kernel", 1, 7, 7, 2); __PYX_ERR(1, 598, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_args_info)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_ufunc_kernel", 1, 7, 7, 3); __PYX_ERR(1, 598, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_ufunc_kernel", 1, 7, 7, 4); __PYX_ERR(1, 598, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_ufunc_kernel", 1, 7, 7, 5); __PYX_ERR(1, 598, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_preamble)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_ufunc_kernel", 1, 7, 7, 6); __PYX_ERR(1, 598, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_ufunc_kernel") < 0)) __PYX_ERR(1, 598, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
    }
    __pyx_v_in_types = values[0];
    __pyx_v_out_types = values[1];
    __pyx_v_routine = values[2];
    __pyx_v_args_info = values[3];
    __pyx_v_params = values[4];
    __pyx_v_name = values[5];
    __pyx_v_preamble = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_ufunc_kernel", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 598, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_ufunc_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_30_get_ufunc_kernel(__pyx_self, __pyx_v_in_types, __pyx_v_out_types, __pyx_v_routine, __pyx_v_args_info, __pyx_v_params, __pyx_v_name, __pyx_v_preamble);

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

static PyObject *__pyx_pf_4cupy_4core_4core_30_get_ufunc_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_in_types, PyObject *__pyx_v_out_types, PyObject *__pyx_v_routine, PyObject *__pyx_v_args_info, PyObject *__pyx_v_params, PyObject *__pyx_v_name, PyObject *__pyx_v_preamble) {
  PyObject *__pyx_v_kernel_params = NULL;
  PyObject *__pyx_v_types = NULL;
  PyObject *__pyx_v_op = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_operation = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  Py_ssize_t __pyx_t_12;
  __Pyx_RefNannySetupContext("_get_ufunc_kernel", 0);
  __Pyx_INCREF(__pyx_v_preamble);

  /* "cupy/core/elementwise.pxi":600
 * def _get_ufunc_kernel(
 *         in_types, out_types, routine, args_info, params, name, preamble):
 *     kernel_params = _get_kernel_params(params, args_info)             # <<<<<<<<<<<<<<
 * 
 *     types = []
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_params))||((__pyx_v_params) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_params)->tp_name), 0))) __PYX_ERR(1, 600, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_args_info))||((__pyx_v_args_info) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args_info)->tp_name), 0))) __PYX_ERR(1, 600, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_kernel_params(((PyObject*)__pyx_v_params), ((PyObject*)__pyx_v_args_info), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 600, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_kernel_params = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":602
 *     kernel_params = _get_kernel_params(params, args_info)
 * 
 *     types = []             # <<<<<<<<<<<<<<
 *     op = []
 *     for i, x in enumerate(in_types):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 602, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":603
 * 
 *     types = []
 *     op = []             # <<<<<<<<<<<<<<
 *     for i, x in enumerate(in_types):
 *         types.append('typedef %s in%d_type;' % (_get_typename(x), i))
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_op = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":604
 *     types = []
 *     op = []
 *     for i, x in enumerate(in_types):             # <<<<<<<<<<<<<<
 *         types.append('typedef %s in%d_type;' % (_get_typename(x), i))
 *         if args_info[i][0] is ndarray:
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_in_types)) || PyTuple_CheckExact(__pyx_v_in_types)) {
    __pyx_t_2 = __pyx_v_in_types; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_in_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 604, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 604, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 604, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 604, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 604, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 604, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 604, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 604, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":605
 *     op = []
 *     for i, x in enumerate(in_types):
 *         types.append('typedef %s in%d_type;' % (_get_typename(x), i))             # <<<<<<<<<<<<<<
 *         if args_info[i][0] is ndarray:
 *             op.append(
 */
    __pyx_t_5 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_x, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 605, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 605, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_i);
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_typedef_s_in_d_type, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 605, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_types, __pyx_t_5); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(1, 605, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":606
 *     for i, x in enumerate(in_types):
 *         types.append('typedef %s in%d_type;' % (_get_typename(x), i))
 *         if args_info[i][0] is ndarray:             # <<<<<<<<<<<<<<
 *             op.append(
 *                 'const in{0}_type in{0}(_raw_in{0}[_ind.get()]);'
 */
    __pyx_t_5 = PyObject_GetItem(__pyx_v_args_info, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 606, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 606, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_8 = (__pyx_t_6 == ((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray));
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_9 = (__pyx_t_8 != 0);
    if (__pyx_t_9) {

      /* "cupy/core/elementwise.pxi":609
 *             op.append(
 *                 'const in{0}_type in{0}(_raw_in{0}[_ind.get()]);'
 *                 .format(i))             # <<<<<<<<<<<<<<
 * 
 *     for i, x in enumerate(out_types):
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_const_in_0__type_in_0__raw_in_0, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 609, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 609, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_i};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 609, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_i};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 609, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 609, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_INCREF(__pyx_v_i);
          __Pyx_GIVEREF(__pyx_v_i);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_i);
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 609, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cupy/core/elementwise.pxi":607
 *         types.append('typedef %s in%d_type;' % (_get_typename(x), i))
 *         if args_info[i][0] is ndarray:
 *             op.append(             # <<<<<<<<<<<<<<
 *                 'const in{0}_type in{0}(_raw_in{0}[_ind.get()]);'
 *                 .format(i))
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_op, __pyx_t_6); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(1, 607, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/elementwise.pxi":606
 *     for i, x in enumerate(in_types):
 *         types.append('typedef %s in%d_type;' % (_get_typename(x), i))
 *         if args_info[i][0] is ndarray:             # <<<<<<<<<<<<<<
 *             op.append(
 *                 'const in{0}_type in{0}(_raw_in{0}[_ind.get()]);'
 */
    }

    /* "cupy/core/elementwise.pxi":604
 *     types = []
 *     op = []
 *     for i, x in enumerate(in_types):             # <<<<<<<<<<<<<<
 *         types.append('typedef %s in%d_type;' % (_get_typename(x), i))
 *         if args_info[i][0] is ndarray:
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":611
 *                 .format(i))
 * 
 *     for i, x in enumerate(out_types):             # <<<<<<<<<<<<<<
 *         types.append('typedef %s out%d_type;' % (
 *             _get_typename(args_info[i + len(in_types)][1]), i))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_out_types)) || PyTuple_CheckExact(__pyx_v_out_types)) {
    __pyx_t_2 = __pyx_v_out_types; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_out_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 611, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 611, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 611, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 611, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 611, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 611, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 611, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
    __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 611, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":613
 *     for i, x in enumerate(out_types):
 *         types.append('typedef %s out%d_type;' % (
 *             _get_typename(args_info[i + len(in_types)][1]), i))             # <<<<<<<<<<<<<<
 *         op.append('out{0}_type &out{0} = _raw_out{0}[_ind.get()];'.format(i))
 * 
 */
    __pyx_t_12 = PyObject_Length(__pyx_v_in_types); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(1, 613, __pyx_L1_error)
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 613, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyNumber_Add(__pyx_v_i, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 613, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_GetItem(__pyx_v_args_info, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 613, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_6, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 613, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_t_5, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 613, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 613, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_i);
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":612
 * 
 *     for i, x in enumerate(out_types):
 *         types.append('typedef %s out%d_type;' % (             # <<<<<<<<<<<<<<
 *             _get_typename(args_info[i + len(in_types)][1]), i))
 *         op.append('out{0}_type &out{0} = _raw_out{0}[_ind.get()];'.format(i))
 */
    __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_typedef_s_out_d_type, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 612, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_types, __pyx_t_6); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(1, 612, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":614
 *         types.append('typedef %s out%d_type;' % (
 *             _get_typename(args_info[i + len(in_types)][1]), i))
 *         op.append('out{0}_type &out{0} = _raw_out{0}[_ind.get()];'.format(i))             # <<<<<<<<<<<<<<
 * 
 *     op.append(routine)
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_out_0__type_out_0__raw_out_0__in, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 614, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_11) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 614, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_i};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 614, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_i};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 614, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 614, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = NULL;
        __Pyx_INCREF(__pyx_v_i);
        __Pyx_GIVEREF(__pyx_v_i);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_i);
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 614, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_op, __pyx_t_6); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(1, 614, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":611
 *                 .format(i))
 * 
 *     for i, x in enumerate(out_types):             # <<<<<<<<<<<<<<
 *         types.append('typedef %s out%d_type;' % (
 *             _get_typename(args_info[i + len(in_types)][1]), i))
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":616
 *         op.append('out{0}_type &out{0} = _raw_out{0}[_ind.get()];'.format(i))
 * 
 *     op.append(routine)             # <<<<<<<<<<<<<<
 *     operation = '\n'.join(op)
 * 
 */
  __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_op, __pyx_v_routine); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(1, 616, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":617
 * 
 *     op.append(routine)
 *     operation = '\n'.join(op)             # <<<<<<<<<<<<<<
 * 
 *     types.append(preamble)
 */
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__63, __pyx_v_op); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 617, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_operation = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":619
 *     operation = '\n'.join(op)
 * 
 *     types.append(preamble)             # <<<<<<<<<<<<<<
 *     preamble = '\n'.join(types)
 * 
 */
  __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_types, __pyx_v_preamble); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(1, 619, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":620
 * 
 *     types.append(preamble)
 *     preamble = '\n'.join(types)             # <<<<<<<<<<<<<<
 * 
 *     return _get_simple_elementwise_kernel(
 */
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__63, __pyx_v_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 620, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_preamble, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":622
 *     preamble = '\n'.join(types)
 * 
 *     return _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         kernel_params, operation, name, preamble)
 * 
 */
  __Pyx_XDECREF(__pyx_r);

  /* "cupy/core/elementwise.pxi":623
 * 
 *     return _get_simple_elementwise_kernel(
 *         kernel_params, operation, name, preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_simple_elementwise_kernel(__pyx_v_kernel_params, __pyx_v_operation, __pyx_v_name, __pyx_v_preamble, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 622, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":598
 * 
 * @util.memoize(for_each_device=True)
 * def _get_ufunc_kernel(             # <<<<<<<<<<<<<<
 *         in_types, out_types, routine, args_info, params, name, preamble):
 *     kernel_params = _get_kernel_params(params, args_info)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core._get_ufunc_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_kernel_params);
  __Pyx_XDECREF(__pyx_v_types);
  __Pyx_XDECREF(__pyx_v_op);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_operation);
  __Pyx_XDECREF(__pyx_v_preamble);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":626
 * 
 * 
 * cdef tuple _guess_routine_from_in_types(list ops, tuple in_types):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, n
 *     cdef tuple op, op_types
 */

static PyObject *__pyx_f_4cupy_4core_4core__guess_routine_from_in_types(PyObject *__pyx_v_ops, PyObject *__pyx_v_in_types) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_n;
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_v_op_types = 0;
  PyObject *__pyx_v_can_cast = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  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;
  __Pyx_RefNannySetupContext("_guess_routine_from_in_types", 0);

  /* "cupy/core/elementwise.pxi":629
 *     cdef Py_ssize_t i, n
 *     cdef tuple op, op_types
 *     n = len(in_types)             # <<<<<<<<<<<<<<
 *     can_cast = numpy.can_cast
 *     for op in ops:
 */
  if (unlikely(__pyx_v_in_types == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 629, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_in_types); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 629, __pyx_L1_error)
  __pyx_v_n = __pyx_t_1;

  /* "cupy/core/elementwise.pxi":630
 *     cdef tuple op, op_types
 *     n = len(in_types)
 *     can_cast = numpy.can_cast             # <<<<<<<<<<<<<<
 *     for op in ops:
 *         op_types = op[0]
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_can_cast); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_can_cast = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":631
 *     n = len(in_types)
 *     can_cast = numpy.can_cast
 *     for op in ops:             # <<<<<<<<<<<<<<
 *         op_types = op[0]
 *         for i in range(n):
 */
  if (unlikely(__pyx_v_ops == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(1, 631, __pyx_L1_error)
  }
  __pyx_t_3 = __pyx_v_ops; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(1, 631, __pyx_L1_error)
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    if (!(likely(PyTuple_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(1, 631, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_op, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":632
 *     can_cast = numpy.can_cast
 *     for op in ops:
 *         op_types = op[0]             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             if not can_cast(in_types[i], op_types[i]):
 */
    if (unlikely(__pyx_v_op == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 632, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_GetItemInt_Tuple(__pyx_v_op, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(PyTuple_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(1, 632, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_op_types, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":633
 *     for op in ops:
 *         op_types = op[0]
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             if not can_cast(in_types[i], op_types[i]):
 *                 break
 */
    __pyx_t_4 = __pyx_v_n;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_i = __pyx_t_5;

      /* "cupy/core/elementwise.pxi":634
 *         op_types = op[0]
 *         for i in range(n):
 *             if not can_cast(in_types[i], op_types[i]):             # <<<<<<<<<<<<<<
 *                 break
 *         else:
 */
      if (unlikely(__pyx_v_in_types == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(1, 634, __pyx_L1_error)
      }
      __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v_in_types, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (unlikely(__pyx_v_op_types == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(1, 634, __pyx_L1_error)
      }
      __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v_op_types, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_v_can_cast);
      __pyx_t_8 = __pyx_v_can_cast; __pyx_t_9 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_6, __pyx_t_7};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 634, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_6, __pyx_t_7};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 634, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 634, __pyx_L1_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_6);
        PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_7);
        __pyx_t_6 = 0;
        __pyx_t_7 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 634, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(1, 634, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_13 = ((!__pyx_t_12) != 0);
      if (__pyx_t_13) {

        /* "cupy/core/elementwise.pxi":635
 *         for i in range(n):
 *             if not can_cast(in_types[i], op_types[i]):
 *                 break             # <<<<<<<<<<<<<<
 *         else:
 *             return op
 */
        goto __pyx_L6_break;

        /* "cupy/core/elementwise.pxi":634
 *         op_types = op[0]
 *         for i in range(n):
 *             if not can_cast(in_types[i], op_types[i]):             # <<<<<<<<<<<<<<
 *                 break
 *         else:
 */
      }
    }
    /*else*/ {

      /* "cupy/core/elementwise.pxi":637
 *                 break
 *         else:
 *             return op             # <<<<<<<<<<<<<<
 *     return None
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_op);
      __pyx_r = __pyx_v_op;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L0;
    }
    __pyx_L6_break:;

    /* "cupy/core/elementwise.pxi":631
 *     n = len(in_types)
 *     can_cast = numpy.can_cast
 *     for op in ops:             # <<<<<<<<<<<<<<
 *         op_types = op[0]
 *         for i in range(n):
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":638
 *         else:
 *             return op
 *     return None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_None);
  __pyx_r = ((PyObject*)Py_None);
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":626
 * 
 * 
 * cdef tuple _guess_routine_from_in_types(list ops, tuple in_types):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, n
 *     cdef tuple op, op_types
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_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._guess_routine_from_in_types", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_op);
  __Pyx_XDECREF(__pyx_v_op_types);
  __Pyx_XDECREF(__pyx_v_can_cast);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":641
 * 
 * 
 * cdef tuple _guess_routine_from_dtype(list ops, object dtype):             # <<<<<<<<<<<<<<
 *     cdef tuple op, op_types
 *     for op in ops:
 */

static PyObject *__pyx_f_4cupy_4core_4core__guess_routine_from_dtype(PyObject *__pyx_v_ops, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_v_op_types = 0;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("_guess_routine_from_dtype", 0);

  /* "cupy/core/elementwise.pxi":643
 * cdef tuple _guess_routine_from_dtype(list ops, object dtype):
 *     cdef tuple op, op_types
 *     for op in ops:             # <<<<<<<<<<<<<<
 *         op_types = op[1]
 *         for t in op_types:
 */
  if (unlikely(__pyx_v_ops == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(1, 643, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_v_ops; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 643, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 643, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_op, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":644
 *     cdef tuple op, op_types
 *     for op in ops:
 *         op_types = op[1]             # <<<<<<<<<<<<<<
 *         for t in op_types:
 *             if t != dtype:
 */
    if (unlikely(__pyx_v_op == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 644, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_op, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 644, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 644, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_op_types, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":645
 *     for op in ops:
 *         op_types = op[1]
 *         for t in op_types:             # <<<<<<<<<<<<<<
 *             if t != dtype:
 *                 break
 */
    if (unlikely(__pyx_v_op_types == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(1, 645, __pyx_L1_error)
    }
    __pyx_t_3 = __pyx_v_op_types; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 645, __pyx_L1_error)
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 645, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "cupy/core/elementwise.pxi":646
 *         op_types = op[1]
 *         for t in op_types:
 *             if t != dtype:             # <<<<<<<<<<<<<<
 *                 break
 *         else:
 */
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_v_dtype, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 646, __pyx_L1_error)
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 646, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {

        /* "cupy/core/elementwise.pxi":647
 *         for t in op_types:
 *             if t != dtype:
 *                 break             # <<<<<<<<<<<<<<
 *         else:
 *             return op
 */
        goto __pyx_L6_break;

        /* "cupy/core/elementwise.pxi":646
 *         op_types = op[1]
 *         for t in op_types:
 *             if t != dtype:             # <<<<<<<<<<<<<<
 *                 break
 *         else:
 */
      }

      /* "cupy/core/elementwise.pxi":645
 *     for op in ops:
 *         op_types = op[1]
 *         for t in op_types:             # <<<<<<<<<<<<<<
 *             if t != dtype:
 *                 break
 */
    }
    /*else*/ {

      /* "cupy/core/elementwise.pxi":649
 *                 break
 *         else:
 *             return op             # <<<<<<<<<<<<<<
 *     return None
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_op);
      __pyx_r = __pyx_v_op;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L0;
    }

    /* "cupy/core/elementwise.pxi":645
 *     for op in ops:
 *         op_types = op[1]
 *         for t in op_types:             # <<<<<<<<<<<<<<
 *             if t != dtype:
 *                 break
 */
    __pyx_L6_break:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":643
 * cdef tuple _guess_routine_from_dtype(list ops, object dtype):
 *     cdef tuple op, op_types
 *     for op in ops:             # <<<<<<<<<<<<<<
 *         op_types = op[1]
 *         for t in op_types:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":650
 *         else:
 *             return op
 *     return None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_None);
  __pyx_r = ((PyObject*)Py_None);
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":641
 * 
 * 
 * cdef tuple _guess_routine_from_dtype(list ops, object dtype):             # <<<<<<<<<<<<<<
 *     cdef tuple op, op_types
 *     for op in ops:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core._guess_routine_from_dtype", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_op);
  __Pyx_XDECREF(__pyx_v_op_types);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":653
 * 
 * 
 * cdef bint _check_should_use_min_scalar(list in_args) except *:             # <<<<<<<<<<<<<<
 *     cdef int kind, max_array_kind, max_scalar_kind
 *     cdef bint all_scalars
 */

static int __pyx_f_4cupy_4core_4core__check_should_use_min_scalar(PyObject *__pyx_v_in_args) {
  int __pyx_v_kind;
  int __pyx_v_max_array_kind;
  int __pyx_v_max_scalar_kind;
  int __pyx_v_all_scalars;
  PyObject *__pyx_v_i = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("_check_should_use_min_scalar", 0);

  /* "cupy/core/elementwise.pxi":656
 *     cdef int kind, max_array_kind, max_scalar_kind
 *     cdef bint all_scalars
 *     all_scalars = True             # <<<<<<<<<<<<<<
 *     max_array_kind = -1
 *     max_scalar_kind = -1
 */
  __pyx_v_all_scalars = 1;

  /* "cupy/core/elementwise.pxi":657
 *     cdef bint all_scalars
 *     all_scalars = True
 *     max_array_kind = -1             # <<<<<<<<<<<<<<
 *     max_scalar_kind = -1
 *     for i in in_args:
 */
  __pyx_v_max_array_kind = -1;

  /* "cupy/core/elementwise.pxi":658
 *     all_scalars = True
 *     max_array_kind = -1
 *     max_scalar_kind = -1             # <<<<<<<<<<<<<<
 *     for i in in_args:
 *         kind = _kind_score[i.dtype.kind]
 */
  __pyx_v_max_scalar_kind = -1;

  /* "cupy/core/elementwise.pxi":659
 *     max_array_kind = -1
 *     max_scalar_kind = -1
 *     for i in in_args:             # <<<<<<<<<<<<<<
 *         kind = _kind_score[i.dtype.kind]
 *         if isinstance(i, ndarray):
 */
  if (unlikely(__pyx_v_in_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(1, 659, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_v_in_args; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 659, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 659, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":660
 *     max_scalar_kind = -1
 *     for i in in_args:
 *         kind = _kind_score[i.dtype.kind]             # <<<<<<<<<<<<<<
 *         if isinstance(i, ndarray):
 *             all_scalars = False
 */
    if (unlikely(__pyx_v_4cupy_4core_4core__kind_score == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 660, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_i, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 660, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_kind); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 660, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_4cupy_4core_4core__kind_score, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 660, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 660, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_kind = __pyx_t_5;

    /* "cupy/core/elementwise.pxi":661
 *     for i in in_args:
 *         kind = _kind_score[i.dtype.kind]
 *         if isinstance(i, ndarray):             # <<<<<<<<<<<<<<
 *             all_scalars = False
 *             max_array_kind = max(max_array_kind, kind)
 */
    __pyx_t_6 = __Pyx_TypeCheck(__pyx_v_i, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_7 = (__pyx_t_6 != 0);
    if (__pyx_t_7) {

      /* "cupy/core/elementwise.pxi":662
 *         kind = _kind_score[i.dtype.kind]
 *         if isinstance(i, ndarray):
 *             all_scalars = False             # <<<<<<<<<<<<<<
 *             max_array_kind = max(max_array_kind, kind)
 *         else:
 */
      __pyx_v_all_scalars = 0;

      /* "cupy/core/elementwise.pxi":663
 *         if isinstance(i, ndarray):
 *             all_scalars = False
 *             max_array_kind = max(max_array_kind, kind)             # <<<<<<<<<<<<<<
 *         else:
 *             max_scalar_kind = max(max_scalar_kind, kind)
 */
      __pyx_t_5 = __pyx_v_kind;
      __pyx_t_8 = __pyx_v_max_array_kind;
      if (((__pyx_t_5 > __pyx_t_8) != 0)) {
        __pyx_t_9 = __pyx_t_5;
      } else {
        __pyx_t_9 = __pyx_t_8;
      }
      __pyx_v_max_array_kind = __pyx_t_9;

      /* "cupy/core/elementwise.pxi":661
 *     for i in in_args:
 *         kind = _kind_score[i.dtype.kind]
 *         if isinstance(i, ndarray):             # <<<<<<<<<<<<<<
 *             all_scalars = False
 *             max_array_kind = max(max_array_kind, kind)
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":665
 *             max_array_kind = max(max_array_kind, kind)
 *         else:
 *             max_scalar_kind = max(max_scalar_kind, kind)             # <<<<<<<<<<<<<<
 *     return (max_scalar_kind != -1 and
 *             not all_scalars and
 */
    /*else*/ {
      __pyx_t_9 = __pyx_v_kind;
      __pyx_t_5 = __pyx_v_max_scalar_kind;
      if (((__pyx_t_9 > __pyx_t_5) != 0)) {
        __pyx_t_8 = __pyx_t_9;
      } else {
        __pyx_t_8 = __pyx_t_5;
      }
      __pyx_v_max_scalar_kind = __pyx_t_8;
    }
    __pyx_L5:;

    /* "cupy/core/elementwise.pxi":659
 *     max_array_kind = -1
 *     max_scalar_kind = -1
 *     for i in in_args:             # <<<<<<<<<<<<<<
 *         kind = _kind_score[i.dtype.kind]
 *         if isinstance(i, ndarray):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":666
 *         else:
 *             max_scalar_kind = max(max_scalar_kind, kind)
 *     return (max_scalar_kind != -1 and             # <<<<<<<<<<<<<<
 *             not all_scalars and
 *             max_array_kind >= max_scalar_kind)
 */
  __pyx_t_6 = ((__pyx_v_max_scalar_kind != -1L) != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_7 = __pyx_t_6;
    goto __pyx_L6_bool_binop_done;
  }

  /* "cupy/core/elementwise.pxi":667
 *             max_scalar_kind = max(max_scalar_kind, kind)
 *     return (max_scalar_kind != -1 and
 *             not all_scalars and             # <<<<<<<<<<<<<<
 *             max_array_kind >= max_scalar_kind)
 * 
 */
  __pyx_t_6 = ((!(__pyx_v_all_scalars != 0)) != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_7 = __pyx_t_6;
    goto __pyx_L6_bool_binop_done;
  }

  /* "cupy/core/elementwise.pxi":668
 *     return (max_scalar_kind != -1 and
 *             not all_scalars and
 *             max_array_kind >= max_scalar_kind)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_6 = ((__pyx_v_max_array_kind >= __pyx_v_max_scalar_kind) != 0);
  __pyx_t_7 = __pyx_t_6;
  __pyx_L6_bool_binop_done:;
  __pyx_r = __pyx_t_7;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":653
 * 
 * 
 * cdef bint _check_should_use_min_scalar(list in_args) except *:             # <<<<<<<<<<<<<<
 *     cdef int kind, max_array_kind, max_scalar_kind
 *     cdef bint all_scalars
 */

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

/* "cupy/core/elementwise.pxi":671
 * 
 * 
 * cdef tuple _guess_routine(str name, dict cache, list ops, list in_args, dtype):             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         use_raw_value = _check_should_use_min_scalar(in_args)
 */

static PyObject *__pyx_f_4cupy_4core_4core__guess_routine(PyObject *__pyx_v_name, PyObject *__pyx_v_cache, PyObject *__pyx_v_ops, PyObject *__pyx_v_in_args, PyObject *__pyx_v_dtype) {
  int __pyx_v_use_raw_value;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_op = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("_guess_routine", 0);
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/elementwise.pxi":672
 * 
 * cdef tuple _guess_routine(str name, dict cache, list ops, list in_args, dtype):
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         use_raw_value = _check_should_use_min_scalar(in_args)
 *         if use_raw_value:
 */
  __pyx_t_1 = (__pyx_v_dtype == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":673
 * cdef tuple _guess_routine(str name, dict cache, list ops, list in_args, dtype):
 *     if dtype is None:
 *         use_raw_value = _check_should_use_min_scalar(in_args)             # <<<<<<<<<<<<<<
 *         if use_raw_value:
 *             in_types = tuple(in_args)
 */
    __pyx_t_2 = __pyx_f_4cupy_4core_4core__check_should_use_min_scalar(__pyx_v_in_args); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 673, __pyx_L1_error)
    __pyx_v_use_raw_value = __pyx_t_2;

    /* "cupy/core/elementwise.pxi":674
 *     if dtype is None:
 *         use_raw_value = _check_should_use_min_scalar(in_args)
 *         if use_raw_value:             # <<<<<<<<<<<<<<
 *             in_types = tuple(in_args)
 *             op = ()
 */
    __pyx_t_2 = (__pyx_v_use_raw_value != 0);
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":675
 *         use_raw_value = _check_should_use_min_scalar(in_args)
 *         if use_raw_value:
 *             in_types = tuple(in_args)             # <<<<<<<<<<<<<<
 *             op = ()
 *         else:
 */
      if (unlikely(__pyx_v_in_args == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        __PYX_ERR(1, 675, __pyx_L1_error)
      }
      __pyx_t_3 = PyList_AsTuple(__pyx_v_in_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 675, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_v_in_types = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/elementwise.pxi":676
 *         if use_raw_value:
 *             in_types = tuple(in_args)
 *             op = ()             # <<<<<<<<<<<<<<
 *         else:
 *             in_types = tuple([i.dtype.type for i in in_args])
 */
      __Pyx_INCREF(__pyx_empty_tuple);
      __pyx_v_op = __pyx_empty_tuple;

      /* "cupy/core/elementwise.pxi":674
 *     if dtype is None:
 *         use_raw_value = _check_should_use_min_scalar(in_args)
 *         if use_raw_value:             # <<<<<<<<<<<<<<
 *             in_types = tuple(in_args)
 *             op = ()
 */
      goto __pyx_L4;
    }

    /* "cupy/core/elementwise.pxi":678
 *             op = ()
 *         else:
 *             in_types = tuple([i.dtype.type for i in in_args])             # <<<<<<<<<<<<<<
 *             op = cache.get(in_types, ())
 * 
 */
    /*else*/ {
      __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 678, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (unlikely(__pyx_v_in_args == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        __PYX_ERR(1, 678, __pyx_L1_error)
      }
      __pyx_t_4 = __pyx_v_in_args; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      for (;;) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 678, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 678, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
        __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_i, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 678, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_type); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 678, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(1, 678, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 678, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_in_types = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/elementwise.pxi":679
 *         else:
 *             in_types = tuple([i.dtype.type for i in in_args])
 *             op = cache.get(in_types, ())             # <<<<<<<<<<<<<<
 * 
 *         if op is ():
 */
      if (unlikely(__pyx_v_cache == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
        __PYX_ERR(1, 679, __pyx_L1_error)
      }
      __pyx_t_4 = __Pyx_PyDict_GetItemDefault(__pyx_v_cache, __pyx_v_in_types, __pyx_empty_tuple); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 679, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_op = __pyx_t_4;
      __pyx_t_4 = 0;
    }
    __pyx_L4:;

    /* "cupy/core/elementwise.pxi":681
 *             op = cache.get(in_types, ())
 * 
 *         if op is ():             # <<<<<<<<<<<<<<
 *             op = _guess_routine_from_in_types(ops, in_types)
 *             if not use_raw_value:
 */
    __pyx_t_2 = (__pyx_v_op == __pyx_empty_tuple);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/elementwise.pxi":682
 * 
 *         if op is ():
 *             op = _guess_routine_from_in_types(ops, in_types)             # <<<<<<<<<<<<<<
 *             if not use_raw_value:
 *                 cache[in_types] = op
 */
      __pyx_t_4 = __pyx_f_4cupy_4core_4core__guess_routine_from_in_types(__pyx_v_ops, __pyx_v_in_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 682, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_op, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/elementwise.pxi":683
 *         if op is ():
 *             op = _guess_routine_from_in_types(ops, in_types)
 *             if not use_raw_value:             # <<<<<<<<<<<<<<
 *                 cache[in_types] = op
 *     else:
 */
      __pyx_t_1 = ((!(__pyx_v_use_raw_value != 0)) != 0);
      if (__pyx_t_1) {

        /* "cupy/core/elementwise.pxi":684
 *             op = _guess_routine_from_in_types(ops, in_types)
 *             if not use_raw_value:
 *                 cache[in_types] = op             # <<<<<<<<<<<<<<
 *     else:
 *         op = cache.get(dtype, ())
 */
        if (unlikely(__pyx_v_cache == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(1, 684, __pyx_L1_error)
        }
        if (unlikely(PyDict_SetItem(__pyx_v_cache, __pyx_v_in_types, __pyx_v_op) < 0)) __PYX_ERR(1, 684, __pyx_L1_error)

        /* "cupy/core/elementwise.pxi":683
 *         if op is ():
 *             op = _guess_routine_from_in_types(ops, in_types)
 *             if not use_raw_value:             # <<<<<<<<<<<<<<
 *                 cache[in_types] = op
 *     else:
 */
      }

      /* "cupy/core/elementwise.pxi":681
 *             op = cache.get(in_types, ())
 * 
 *         if op is ():             # <<<<<<<<<<<<<<
 *             op = _guess_routine_from_in_types(ops, in_types)
 *             if not use_raw_value:
 */
    }

    /* "cupy/core/elementwise.pxi":672
 * 
 * cdef tuple _guess_routine(str name, dict cache, list ops, list in_args, dtype):
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         use_raw_value = _check_should_use_min_scalar(in_args)
 *         if use_raw_value:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/elementwise.pxi":686
 *                 cache[in_types] = op
 *     else:
 *         op = cache.get(dtype, ())             # <<<<<<<<<<<<<<
 *         if op is ():
 *             op = _guess_routine_from_dtype(ops, dtype)
 */
  /*else*/ {
    if (unlikely(__pyx_v_cache == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
      __PYX_ERR(1, 686, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_PyDict_GetItemDefault(__pyx_v_cache, __pyx_v_dtype, __pyx_empty_tuple); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 686, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_op = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/core/elementwise.pxi":687
 *     else:
 *         op = cache.get(dtype, ())
 *         if op is ():             # <<<<<<<<<<<<<<
 *             op = _guess_routine_from_dtype(ops, dtype)
 *             cache[dtype] = op
 */
    __pyx_t_1 = (__pyx_v_op == __pyx_empty_tuple);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":688
 *         op = cache.get(dtype, ())
 *         if op is ():
 *             op = _guess_routine_from_dtype(ops, dtype)             # <<<<<<<<<<<<<<
 *             cache[dtype] = op
 * 
 */
      __pyx_t_4 = __pyx_f_4cupy_4core_4core__guess_routine_from_dtype(__pyx_v_ops, __pyx_v_dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 688, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_op, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/elementwise.pxi":689
 *         if op is ():
 *             op = _guess_routine_from_dtype(ops, dtype)
 *             cache[dtype] = op             # <<<<<<<<<<<<<<
 * 
 *     if op:
 */
      if (unlikely(__pyx_v_cache == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(1, 689, __pyx_L1_error)
      }
      if (unlikely(PyDict_SetItem(__pyx_v_cache, __pyx_v_dtype, __pyx_v_op) < 0)) __PYX_ERR(1, 689, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":687
 *     else:
 *         op = cache.get(dtype, ())
 *         if op is ():             # <<<<<<<<<<<<<<
 *             op = _guess_routine_from_dtype(ops, dtype)
 *             cache[dtype] = op
 */
    }
  }
  __pyx_L3:;

  /* "cupy/core/elementwise.pxi":691
 *             cache[dtype] = op
 * 
 *     if op:             # <<<<<<<<<<<<<<
 *         return op
 *     if dtype is None:
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_op); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 691, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":692
 * 
 *     if op:
 *         return op             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         dtype = tuple([i.dtype.type for i in in_args])
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(PyTuple_CheckExact(__pyx_v_op))||((__pyx_v_op) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_op)->tp_name), 0))) __PYX_ERR(1, 692, __pyx_L1_error)
    __Pyx_INCREF(__pyx_v_op);
    __pyx_r = ((PyObject*)__pyx_v_op);
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":691
 *             cache[dtype] = op
 * 
 *     if op:             # <<<<<<<<<<<<<<
 *         return op
 *     if dtype is None:
 */
  }

  /* "cupy/core/elementwise.pxi":693
 *     if op:
 *         return op
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         dtype = tuple([i.dtype.type for i in in_args])
 *     raise TypeError('Wrong type (%s) of arguments for %s' %
 */
  __pyx_t_2 = (__pyx_v_dtype == Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/elementwise.pxi":694
 *         return op
 *     if dtype is None:
 *         dtype = tuple([i.dtype.type for i in in_args])             # <<<<<<<<<<<<<<
 *     raise TypeError('Wrong type (%s) of arguments for %s' %
 *                     (dtype, name))
 */
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 694, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__pyx_v_in_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(1, 694, __pyx_L1_error)
    }
    __pyx_t_3 = __pyx_v_in_args; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
    for (;;) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_7 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 694, __pyx_L1_error)
      #else
      __pyx_t_7 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 694, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_i, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 694, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 694, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_6))) __PYX_ERR(1, 694, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyList_AsTuple(((PyObject*)__pyx_t_4)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 694, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":693
 *     if op:
 *         return op
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         dtype = tuple([i.dtype.type for i in in_args])
 *     raise TypeError('Wrong type (%s) of arguments for %s' %
 */
  }

  /* "cupy/core/elementwise.pxi":696
 *         dtype = tuple([i.dtype.type for i in in_args])
 *     raise TypeError('Wrong type (%s) of arguments for %s' %
 *                     (dtype, name))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 696, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_dtype);
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_name);

  /* "cupy/core/elementwise.pxi":695
 *     if dtype is None:
 *         dtype = tuple([i.dtype.type for i in in_args])
 *     raise TypeError('Wrong type (%s) of arguments for %s' %             # <<<<<<<<<<<<<<
 *                     (dtype, name))
 * 
 */
  __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_type_s_of_arguments_for_s, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 695, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 695, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 695, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __PYX_ERR(1, 695, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":671
 * 
 * 
 * cdef tuple _guess_routine(str name, dict cache, list ops, list in_args, dtype):             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         use_raw_value = _check_should_use_min_scalar(in_args)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core._guess_routine", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_op);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":711
 *     """
 * 
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                  default_casting=None):
 *         self.name = name
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_5ufunc___init__[] = "ufunc.__init__(self, name, nin, nout, ops, preamble='', doc='', default_casting=None)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_5ufunc_1__init__ = {"__init__", (PyCFunction)__pyx_pw_4cupy_4core_4core_5ufunc_1__init__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_5ufunc___init__};
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_nin = 0;
  PyObject *__pyx_v_nout = 0;
  PyObject *__pyx_v_ops = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_doc = 0;
  PyObject *__pyx_v_default_casting = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_name,&__pyx_n_s_nin,&__pyx_n_s_nout,&__pyx_n_s_ops,&__pyx_n_s_preamble,&__pyx_n_s_doc,&__pyx_n_s_default_casting,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    values[5] = ((PyObject *)((PyObject*)__pyx_kp_s__5));
    values[6] = ((PyObject *)((PyObject*)__pyx_kp_s__5));

    /* "cupy/core/elementwise.pxi":712
 * 
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',
 *                  default_casting=None):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self.nin = nin
 */
    values[7] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 8, 1); __PYX_ERR(1, 711, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nin)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 8, 2); __PYX_ERR(1, 711, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nout)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 8, 3); __PYX_ERR(1, 711, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ops)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 8, 4); __PYX_ERR(1, 711, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_preamble);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_doc);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_default_casting);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(1, 711, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_name = values[1];
    __pyx_v_nin = values[2];
    __pyx_v_nout = values[3];
    __pyx_v_ops = values[4];
    __pyx_v_preamble = values[5];
    __pyx_v_doc = values[6];
    __pyx_v_default_casting = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 711, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ufunc.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_5ufunc___init__(__pyx_self, __pyx_v_self, __pyx_v_name, __pyx_v_nin, __pyx_v_nout, __pyx_v_ops, __pyx_v_preamble, __pyx_v_doc, __pyx_v_default_casting);

  /* "cupy/core/elementwise.pxi":711
 *     """
 * 
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                  default_casting=None):
 *         self.name = name
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_4cupy_4core_4core_5ufunc_8__init___2generator1(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "cupy/core/elementwise.pxi":725
 *             self._default_casting = default_casting
 *         _in_params = tuple(
 *             ParameterInfo('T in%d' % i, True)             # <<<<<<<<<<<<<<
 *             for i in range(nin))
 *         _out_params = tuple(
 */

static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc_8__init___genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *)__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_3_genexpr(__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_3_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(1, 725, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4cupy_4core_4core_5ufunc_8__init___2generator1, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_ufunc___init___locals_genexpr, __pyx_n_s_cupy_core_core); if (unlikely(!gen)) __PYX_ERR(1, 725, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("cupy.core.core.ufunc.__init__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_4cupy_4core_4core_5ufunc_8__init___2generator1(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *__pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(1, 725, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":726
 *         _in_params = tuple(
 *             ParameterInfo('T in%d' % i, True)
 *             for i in range(nin))             # <<<<<<<<<<<<<<
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_nin)) { __Pyx_RaiseClosureNameError("nin"); __PYX_ERR(1, 726, __pyx_L1_error) }
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_nin);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_nin);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_nin);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 726, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 726, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 726, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 726, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 726, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 726, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 726, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_i);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_i, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":725
 *             self._default_casting = default_casting
 *         _in_params = tuple(
 *             ParameterInfo('T in%d' % i, True)             # <<<<<<<<<<<<<<
 *             for i in range(nin))
 *         _out_params = tuple(
 */
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_T_in_d, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 725, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 725, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
    __Pyx_INCREF(Py_True);
    __Pyx_GIVEREF(Py_True);
    PyTuple_SET_ITEM(__pyx_t_5, 1, Py_True);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ParameterInfo), __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 725, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_3;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_4;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    /* 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_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(1, 725, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":726
 *         _in_params = tuple(
 *             ParameterInfo('T in%d' % i, True)
 *             for i in range(nin))             # <<<<<<<<<<<<<<
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "cupy/core/elementwise.pxi":725
 *             self._default_casting = default_casting
 *         _in_params = tuple(
 *             ParameterInfo('T in%d' % i, True)             # <<<<<<<<<<<<<<
 *             for i in range(nin))
 *         _out_params = tuple(
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_4cupy_4core_4core_5ufunc_8__init___5generator2(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "cupy/core/elementwise.pxi":728
 *             for i in range(nin))
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)             # <<<<<<<<<<<<<<
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (
 */

static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc_8__init___3genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *)__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_4_genexpr(__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_4_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(1, 728, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4cupy_4core_4core_5ufunc_8__init___5generator2, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_ufunc___init___locals_genexpr, __pyx_n_s_cupy_core_core); if (unlikely(!gen)) __PYX_ERR(1, 728, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("cupy.core.core.ufunc.__init__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_4cupy_4core_4core_5ufunc_8__init___5generator2(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *__pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(1, 728, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":729
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)
 *             for i in range(nout))             # <<<<<<<<<<<<<<
 *         self._params = _in_params + _out_params + (
 *             ParameterInfo('CIndexer _ind', False),)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_nout)) { __Pyx_RaiseClosureNameError("nout"); __PYX_ERR(1, 729, __pyx_L1_error) }
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_nout);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_nout);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_nout);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 729, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 729, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 729, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 729, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 729, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 729, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 729, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_i);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_i, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":728
 *             for i in range(nin))
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)             # <<<<<<<<<<<<<<
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (
 */
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_T_out_d, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
    __Pyx_INCREF(Py_False);
    __Pyx_GIVEREF(Py_False);
    PyTuple_SET_ITEM(__pyx_t_5, 1, Py_False);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ParameterInfo), __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_3;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_4;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    /* 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_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(1, 728, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":729
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)
 *             for i in range(nout))             # <<<<<<<<<<<<<<
 *         self._params = _in_params + _out_params + (
 *             ParameterInfo('CIndexer _ind', False),)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "cupy/core/elementwise.pxi":728
 *             for i in range(nin))
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)             # <<<<<<<<<<<<<<
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":711
 *     """
 * 
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                  default_casting=None):
 *         self.name = name
 */

static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_nin, PyObject *__pyx_v_nout, PyObject *__pyx_v_ops, PyObject *__pyx_v_preamble, PyObject *__pyx_v_doc, PyObject *__pyx_v_default_casting) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *__pyx_cur_scope;
  PyObject *__pyx_v__in_params = NULL;
  PyObject *__pyx_v__out_params = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __pyx_cur_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *)__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_2___init__(__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_2___init__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(1, 711, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_nin = __pyx_v_nin;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_nin);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_nin);
  __pyx_cur_scope->__pyx_v_nout = __pyx_v_nout;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_nout);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_nout);

  /* "cupy/core/elementwise.pxi":713
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',
 *                  default_casting=None):
 *         self.name = name             # <<<<<<<<<<<<<<
 *         self.nin = nin
 *         self.nout = nout
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(1, 713, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":714
 *                  default_casting=None):
 *         self.name = name
 *         self.nin = nin             # <<<<<<<<<<<<<<
 *         self.nout = nout
 *         self.nargs = nin + nout
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nin, __pyx_cur_scope->__pyx_v_nin) < 0) __PYX_ERR(1, 714, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":715
 *         self.name = name
 *         self.nin = nin
 *         self.nout = nout             # <<<<<<<<<<<<<<
 *         self.nargs = nin + nout
 *         self._ops = ops
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nout, __pyx_cur_scope->__pyx_v_nout) < 0) __PYX_ERR(1, 715, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":716
 *         self.nin = nin
 *         self.nout = nout
 *         self.nargs = nin + nout             # <<<<<<<<<<<<<<
 *         self._ops = ops
 *         self._preamble = preamble
 */
  __pyx_t_1 = PyNumber_Add(__pyx_cur_scope->__pyx_v_nin, __pyx_cur_scope->__pyx_v_nout); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 716, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nargs, __pyx_t_1) < 0) __PYX_ERR(1, 716, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":717
 *         self.nout = nout
 *         self.nargs = nin + nout
 *         self._ops = ops             # <<<<<<<<<<<<<<
 *         self._preamble = preamble
 *         self.__doc__ = doc
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_ops_2, __pyx_v_ops) < 0) __PYX_ERR(1, 717, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":718
 *         self.nargs = nin + nout
 *         self._ops = ops
 *         self._preamble = preamble             # <<<<<<<<<<<<<<
 *         self.__doc__ = doc
 *         if default_casting is None:
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_preamble_2, __pyx_v_preamble) < 0) __PYX_ERR(1, 718, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":719
 *         self._ops = ops
 *         self._preamble = preamble
 *         self.__doc__ = doc             # <<<<<<<<<<<<<<
 *         if default_casting is None:
 *             self._default_casting = 'same_kind'
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_doc_2, __pyx_v_doc) < 0) __PYX_ERR(1, 719, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":720
 *         self._preamble = preamble
 *         self.__doc__ = doc
 *         if default_casting is None:             # <<<<<<<<<<<<<<
 *             self._default_casting = 'same_kind'
 *         else:
 */
  __pyx_t_2 = (__pyx_v_default_casting == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":721
 *         self.__doc__ = doc
 *         if default_casting is None:
 *             self._default_casting = 'same_kind'             # <<<<<<<<<<<<<<
 *         else:
 *             self._default_casting = default_casting
 */
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_default_casting_2, __pyx_n_s_same_kind) < 0) __PYX_ERR(1, 721, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":720
 *         self._preamble = preamble
 *         self.__doc__ = doc
 *         if default_casting is None:             # <<<<<<<<<<<<<<
 *             self._default_casting = 'same_kind'
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/elementwise.pxi":723
 *             self._default_casting = 'same_kind'
 *         else:
 *             self._default_casting = default_casting             # <<<<<<<<<<<<<<
 *         _in_params = tuple(
 *             ParameterInfo('T in%d' % i, True)
 */
  /*else*/ {
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_default_casting_2, __pyx_v_default_casting) < 0) __PYX_ERR(1, 723, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "cupy/core/elementwise.pxi":725
 *             self._default_casting = default_casting
 *         _in_params = tuple(
 *             ParameterInfo('T in%d' % i, True)             # <<<<<<<<<<<<<<
 *             for i in range(nin))
 *         _out_params = tuple(
 */
  __pyx_t_1 = __pyx_pf_4cupy_4core_4core_5ufunc_8__init___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 725, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":724
 *         else:
 *             self._default_casting = default_casting
 *         _in_params = tuple(             # <<<<<<<<<<<<<<
 *             ParameterInfo('T in%d' % i, True)
 *             for i in range(nin))
 */
  __pyx_t_4 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 724, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v__in_params = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/elementwise.pxi":728
 *             for i in range(nin))
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)             # <<<<<<<<<<<<<<
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (
 */
  __pyx_t_4 = __pyx_pf_4cupy_4core_4core_5ufunc_8__init___3genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/elementwise.pxi":727
 *             ParameterInfo('T in%d' % i, True)
 *             for i in range(nin))
 *         _out_params = tuple(             # <<<<<<<<<<<<<<
 *             ParameterInfo('T out%d' % i, False)
 *             for i in range(nout))
 */
  __pyx_t_1 = PySequence_Tuple(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 727, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v__out_params = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":730
 *             ParameterInfo('T out%d' % i, False)
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (             # <<<<<<<<<<<<<<
 *             ParameterInfo('CIndexer _ind', False),)
 *         self._routine_cache = {}
 */
  __pyx_t_1 = PyNumber_Add(__pyx_v__in_params, __pyx_v__out_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":731
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (
 *             ParameterInfo('CIndexer _ind', False),)             # <<<<<<<<<<<<<<
 *         self._routine_cache = {}
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ParameterInfo), __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 731, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 731, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/elementwise.pxi":730
 *             ParameterInfo('T out%d' % i, False)
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (             # <<<<<<<<<<<<<<
 *             ParameterInfo('CIndexer _ind', False),)
 *         self._routine_cache = {}
 */
  __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_params_2, __pyx_t_4) < 0) __PYX_ERR(1, 730, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/elementwise.pxi":732
 *         self._params = _in_params + _out_params + (
 *             ParameterInfo('CIndexer _ind', False),)
 *         self._routine_cache = {}             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 732, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_routine_cache, __pyx_t_4) < 0) __PYX_ERR(1, 732, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/elementwise.pxi":711
 *     """
 * 
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                  default_casting=None):
 *         self.name = name
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ufunc.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__in_params);
  __Pyx_XDECREF(__pyx_v__out_params);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":734
 *         self._routine_cache = {}
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<ufunc '%s'>" % self.name
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_3__repr__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_4cupy_4core_4core_5ufunc_2__repr__[] = "ufunc.__repr__(self)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_5ufunc_3__repr__ = {"__repr__", (PyCFunction)__pyx_pw_4cupy_4core_4core_5ufunc_3__repr__, METH_O, __pyx_doc_4cupy_4core_4core_5ufunc_2__repr__};
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_3__repr__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_5ufunc_2__repr__(__pyx_self, ((PyObject *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc_2__repr__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "cupy/core/elementwise.pxi":735
 * 
 *     def __repr__(self):
 *         return "<ufunc '%s'>" % self.name             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 735, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_ufunc_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 735, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":734
 *         self._routine_cache = {}
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<ufunc '%s'>" % self.name
 * 
 */

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

/* "cupy/core/elementwise.pxi":738
 * 
 *     @property
 *     def types(self):             # <<<<<<<<<<<<<<
 *         """A list of type signatures.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_5types(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_4cupy_4core_4core_5ufunc_4types[] = "ufunc.types(self)\nA list of type signatures.\n\n        Each type signature is represented by type character codes of inputs\n        and outputs separated by '->'.\n\n        ";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_5ufunc_5types = {"types", (PyCFunction)__pyx_pw_4cupy_4core_4core_5ufunc_5types, METH_O, __pyx_doc_4cupy_4core_4core_5ufunc_4types};
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_5types(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("types (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_5ufunc_4types(__pyx_self, ((PyObject *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc_4types(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_types = NULL;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_v_in_str = NULL;
  PyObject *__pyx_v_out_str = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  __Pyx_RefNannySetupContext("types", 0);

  /* "cupy/core/elementwise.pxi":745
 * 
 *         """
 *         types = []             # <<<<<<<<<<<<<<
 *         for in_types, out_types, _ in self._ops:
 *             in_str = ''.join([<str>numpy.dtype(t).char for t in in_types])
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 745, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":746
 *         """
 *         types = []
 *         for in_types, out_types, _ in self._ops:             # <<<<<<<<<<<<<<
 *             in_str = ''.join([<str>numpy.dtype(t).char for t in in_types])
 *             out_str = ''.join([<str>numpy.dtype(t).char for t in out_types])
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ops_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 746, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 746, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 746, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 746, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 746, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 746, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 746, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(1, 746, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 746, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 746, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 746, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 746, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 2; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 3) < 0) __PYX_ERR(1, 746, __pyx_L1_error)
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(1, 746, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_in_types, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_out_types, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":747
 *         types = []
 *         for in_types, out_types, _ in self._ops:
 *             in_str = ''.join([<str>numpy.dtype(t).char for t in in_types])             # <<<<<<<<<<<<<<
 *             out_str = ''.join([<str>numpy.dtype(t).char for t in out_types])
 *             types.append('%s->%s' % (in_str, out_str))
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 747, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (likely(PyList_CheckExact(__pyx_v_in_types)) || PyTuple_CheckExact(__pyx_v_in_types)) {
      __pyx_t_7 = __pyx_v_in_types; __Pyx_INCREF(__pyx_t_7); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_in_types); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 747, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_11 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 747, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_11)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_6 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 747, __pyx_L1_error)
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_7, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 747, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 747, __pyx_L1_error)
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_7, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 747, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        }
      } else {
        __pyx_t_6 = __pyx_t_11(__pyx_t_7);
        if (unlikely(!__pyx_t_6)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(1, 747, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 747, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 747, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_t); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 747, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_t};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 747, __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_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_t};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 747, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        {
          __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 747, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5); __pyx_t_5 = NULL;
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_v_t);
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 747, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_char); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 747, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)((PyObject*)__pyx_t_8)))) __PYX_ERR(1, 747, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyString_Join(__pyx_kp_s__5, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 747, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_in_str, ((PyObject*)__pyx_t_7));
    __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":748
 *         for in_types, out_types, _ in self._ops:
 *             in_str = ''.join([<str>numpy.dtype(t).char for t in in_types])
 *             out_str = ''.join([<str>numpy.dtype(t).char for t in out_types])             # <<<<<<<<<<<<<<
 *             types.append('%s->%s' % (in_str, out_str))
 *         return types
 */
    __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 748, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (likely(PyList_CheckExact(__pyx_v_out_types)) || PyTuple_CheckExact(__pyx_v_out_types)) {
      __pyx_t_1 = __pyx_v_out_types; __Pyx_INCREF(__pyx_t_1); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_out_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 748, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 748, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_11)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_8 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 748, __pyx_L1_error)
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 748, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 748, __pyx_L1_error)
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 748, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        }
      } else {
        __pyx_t_8 = __pyx_t_11(__pyx_t_1);
        if (unlikely(!__pyx_t_8)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(1, 748, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_8);
      }
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 748, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_dtype); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 748, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
        }
      }
      if (!__pyx_t_6) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_t); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 748, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_t};
          __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 748, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_8);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_t};
          __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 748, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_8);
        } else
        #endif
        {
          __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 748, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_t);
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_5, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 748, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_char); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 748, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_7, (PyObject*)((PyObject*)__pyx_t_12)))) __PYX_ERR(1, 748, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__5, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 748, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF_SET(__pyx_v_out_str, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":749
 *             in_str = ''.join([<str>numpy.dtype(t).char for t in in_types])
 *             out_str = ''.join([<str>numpy.dtype(t).char for t in out_types])
 *             types.append('%s->%s' % (in_str, out_str))             # <<<<<<<<<<<<<<
 *         return types
 * 
 */
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_in_str);
    __Pyx_GIVEREF(__pyx_v_in_str);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_in_str);
    __Pyx_INCREF(__pyx_v_out_str);
    __Pyx_GIVEREF(__pyx_v_out_str);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_out_str);
    __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_s_s, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_types, __pyx_t_7); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(1, 749, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":746
 *         """
 *         types = []
 *         for in_types, out_types, _ in self._ops:             # <<<<<<<<<<<<<<
 *             in_str = ''.join([<str>numpy.dtype(t).char for t in in_types])
 *             out_str = ''.join([<str>numpy.dtype(t).char for t in out_types])
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":750
 *             out_str = ''.join([<str>numpy.dtype(t).char for t in out_types])
 *             types.append('%s->%s' % (in_str, out_str))
 *         return types             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, *args, **kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_types);
  __pyx_r = __pyx_v_types;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":738
 * 
 *     @property
 *     def types(self):             # <<<<<<<<<<<<<<
 *         """A list of type signatures.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core.ufunc.types", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_types);
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF(__pyx_v_in_str);
  __Pyx_XDECREF(__pyx_v_out_str);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":752
 *         return types
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Applies the universal function to arguments elementwise.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_7__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_5ufunc_6__call__[] = "ufunc.__call__(self, *args, **kwargs)\nApplies the universal function to arguments elementwise.\n\n        Args:\n            args: Input arguments. Each of them can be a :class:`cupy.ndarray`\n                object or a scalar. The output arguments can be omitted or be\n                specified by the ``out`` argument.\n            out (cupy.ndarray): Output array. It outputs to new arrays\n                default.\n            dtype: Data type specifier.\n\n        Returns:\n            Output array or a tuple of output arrays.\n\n        ";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_5ufunc_7__call__ = {"__call__", (PyCFunction)__pyx_pw_4cupy_4core_4core_5ufunc_7__call__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_5ufunc_6__call__};
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_7__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_args);
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        default:
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "__call__") < 0)) __PYX_ERR(1, 752, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 752, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("cupy.core.core.ufunc.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_5ufunc_6__call__(__pyx_self, __pyx_v_self, __pyx_v_args, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc_6__call__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_4cupy_4cuda_8function_Function *__pyx_v_kern = 0;
  PyObject *__pyx_v_out = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_casting = NULL;
  Py_ssize_t __pyx_v_n_args;
  PyObject *__pyx_v_in_args = NULL;
  PyObject *__pyx_v_out_args = NULL;
  struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_broad = NULL;
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  PyObject *__pyx_v_routine = NULL;
  PyObject *__pyx_v_ret = NULL;
  PyObject *__pyx_v_inout_args = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_x = NULL;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_indexer = NULL;
  PyObject *__pyx_v_args_info = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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;
  Py_ssize_t __pyx_t_9;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  __Pyx_RefNannySetupContext("__call__", 0);
  __Pyx_INCREF(__pyx_v_args);

  /* "cupy/core/elementwise.pxi":770
 *         cdef function.Function kern
 * 
 *         out = kwargs.pop('out', None)             # <<<<<<<<<<<<<<
 *         dtype = kwargs.pop('dtype', None)
 *         # Note default behavior of casting is 'same_kind' on numpy>=1.10
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__87, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_out = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":771
 * 
 *         out = kwargs.pop('out', None)
 *         dtype = kwargs.pop('dtype', None)             # <<<<<<<<<<<<<<
 *         # Note default behavior of casting is 'same_kind' on numpy>=1.10
 *         casting = kwargs.pop('casting', self._default_casting)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__88, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_dtype = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":773
 *         dtype = kwargs.pop('dtype', None)
 *         # Note default behavior of casting is 'same_kind' on numpy>=1.10
 *         casting = kwargs.pop('casting', self._default_casting)             # <<<<<<<<<<<<<<
 *         if dtype is not None:
 *             dtype = numpy.dtype(dtype).type
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 773, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_default_casting_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 773, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(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, __pyx_n_s_casting, __pyx_t_3};
    __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(1, 773, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 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_4, __pyx_n_s_casting, __pyx_t_3};
    __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(1, 773, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 773, __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_n_s_casting);
    __Pyx_GIVEREF(__pyx_n_s_casting);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_n_s_casting);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 773, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_casting = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":774
 *         # Note default behavior of casting is 'same_kind' on numpy>=1.10
 *         casting = kwargs.pop('casting', self._default_casting)
 *         if dtype is not None:             # <<<<<<<<<<<<<<
 *             dtype = numpy.dtype(dtype).type
 *         if kwargs:
 */
  __pyx_t_7 = (__pyx_v_dtype != Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/core/elementwise.pxi":775
 *         casting = kwargs.pop('casting', self._default_casting)
 *         if dtype is not None:
 *             dtype = numpy.dtype(dtype).type             # <<<<<<<<<<<<<<
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 775, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 775, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_2) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 775, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_dtype};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 775, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_dtype};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 775, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 775, __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 = NULL;
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_dtype);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 775, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 775, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":774
 *         # Note default behavior of casting is 'same_kind' on numpy>=1.10
 *         casting = kwargs.pop('casting', self._default_casting)
 *         if dtype is not None:             # <<<<<<<<<<<<<<
 *             dtype = numpy.dtype(dtype).type
 *         if kwargs:
 */
  }

  /* "cupy/core/elementwise.pxi":776
 *         if dtype is not None:
 *             dtype = numpy.dtype(dtype).type
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 776, __pyx_L1_error)
  if (__pyx_t_8) {

    /* "cupy/core/elementwise.pxi":777
 *             dtype = numpy.dtype(dtype).type
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)             # <<<<<<<<<<<<<<
 * 
 *         n_args = len(args)
 */
    __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_arguments_s, __pyx_v_kwargs); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 777, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 777, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 777, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __PYX_ERR(1, 777, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":776
 *         if dtype is not None:
 *             dtype = numpy.dtype(dtype).type
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":779
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 *         n_args = len(args)             # <<<<<<<<<<<<<<
 *         if n_args != self.nin and n_args != self.nargs:
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 */
  __pyx_t_9 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(1, 779, __pyx_L1_error)
  __pyx_v_n_args = __pyx_t_9;

  /* "cupy/core/elementwise.pxi":780
 * 
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 * 
 */
  __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_n_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_6, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 780, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(1, 780, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_7) {
  } else {
    __pyx_t_8 = __pyx_t_7;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_n_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyObject_RichCompare(__pyx_t_3, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 780, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(1, 780, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_8 = __pyx_t_7;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_8) {

    /* "cupy/core/elementwise.pxi":781
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:
 *             raise TypeError('Wrong number of arguments for %s' % self.name)             # <<<<<<<<<<<<<<
 * 
 *         args = _preprocess_args(args)
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 781, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_number_of_arguments_for_s, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 781, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 781, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 781, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(1, 781, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":780
 * 
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":783
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 * 
 *         args = _preprocess_args(args)             # <<<<<<<<<<<<<<
 *         if out is None:
 *             in_args = args[:self.nin]
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_v_args, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 783, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":784
 * 
 *         args = _preprocess_args(args)
 *         if out is None:             # <<<<<<<<<<<<<<
 *             in_args = args[:self.nin]
 *             out_args = args[self.nin:]
 */
  __pyx_t_8 = (__pyx_v_out == Py_None);
  __pyx_t_7 = (__pyx_t_8 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/elementwise.pxi":785
 *         args = _preprocess_args(args)
 *         if out is None:
 *             in_args = args[:self.nin]             # <<<<<<<<<<<<<<
 *             out_args = args[self.nin:]
 *         else:
 */
    if (unlikely(__pyx_v_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 785, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 785, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 785, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_v_args, 0, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 785, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_in_args = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":786
 *         if out is None:
 *             in_args = args[:self.nin]
 *             out_args = args[self.nin:]             # <<<<<<<<<<<<<<
 *         else:
 *             if self.nout != 1:
 */
    if (unlikely(__pyx_v_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 786, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 786, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_v_args, __pyx_t_9, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_out_args = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":784
 * 
 *         args = _preprocess_args(args)
 *         if out is None:             # <<<<<<<<<<<<<<
 *             in_args = args[:self.nin]
 *             out_args = args[self.nin:]
 */
    goto __pyx_L8;
  }

  /* "cupy/core/elementwise.pxi":788
 *             out_args = args[self.nin:]
 *         else:
 *             if self.nout != 1:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Cannot use 'out' in %s" % self.name)
 *             if n_args != self.nin:
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nout); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 788, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_int_1, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 788, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(1, 788, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_7) {

      /* "cupy/core/elementwise.pxi":789
 *         else:
 *             if self.nout != 1:
 *                 raise ValueError("Cannot use 'out' in %s" % self.name)             # <<<<<<<<<<<<<<
 *             if n_args != self.nin:
 *                 raise ValueError("Cannot specify 'out' as both "
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 789, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Cannot_use_out_in_s, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 789, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 789, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 789, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(1, 789, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":788
 *             out_args = args[self.nin:]
 *         else:
 *             if self.nout != 1:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Cannot use 'out' in %s" % self.name)
 *             if n_args != self.nin:
 */
    }

    /* "cupy/core/elementwise.pxi":790
 *             if self.nout != 1:
 *                 raise ValueError("Cannot use 'out' in %s" % self.name)
 *             if n_args != self.nin:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Cannot specify 'out' as both "
 *                                  "a positional and keyword argument")
 */
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_n_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 790, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 790, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_6, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 790, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(1, 790, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_7) {

      /* "cupy/core/elementwise.pxi":791
 *                 raise ValueError("Cannot use 'out' in %s" % self.name)
 *             if n_args != self.nin:
 *                 raise ValueError("Cannot specify 'out' as both "             # <<<<<<<<<<<<<<
 *                                  "a positional and keyword argument")
 * 
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__89, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 791, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(1, 791, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":790
 *             if self.nout != 1:
 *                 raise ValueError("Cannot use 'out' in %s" % self.name)
 *             if n_args != self.nin:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Cannot specify 'out' as both "
 *                                  "a positional and keyword argument")
 */
    }

    /* "cupy/core/elementwise.pxi":794
 *                                  "a positional and keyword argument")
 * 
 *             in_args = list(args)             # <<<<<<<<<<<<<<
 *             out_args = _preprocess_args((out,))
 *             args += out_args
 */
    __pyx_t_3 = PySequence_List(__pyx_v_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 794, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_in_args = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":795
 * 
 *             in_args = list(args)
 *             out_args = _preprocess_args((out,))             # <<<<<<<<<<<<<<
 *             args += out_args
 * 
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 795, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_out);
    __Pyx_GIVEREF(__pyx_v_out);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_out);
    __pyx_t_6 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_t_3, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 795, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_out_args = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":796
 *             in_args = list(args)
 *             out_args = _preprocess_args((out,))
 *             args += out_args             # <<<<<<<<<<<<<<
 * 
 *         broad = broadcast(*args)
 */
    __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_args, __pyx_v_out_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 796, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_6);
    __pyx_t_6 = 0;
  }
  __pyx_L8:;

  /* "cupy/core/elementwise.pxi":798
 *             args += out_args
 * 
 *         broad = broadcast(*args)             # <<<<<<<<<<<<<<
 *         shape = broad.shape
 * 
 */
  __pyx_t_6 = PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_broadcast), __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_broad = ((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":799
 * 
 *         broad = broadcast(*args)
 *         shape = broad.shape             # <<<<<<<<<<<<<<
 * 
 *         in_types, out_types, routine = _guess_routine(
 */
  __pyx_t_3 = __pyx_v_broad->shape;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_v_shape = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":802
 * 
 *         in_types, out_types, routine = _guess_routine(
 *             self.name, self._routine_cache, self._ops, in_args, dtype)             # <<<<<<<<<<<<<<
 * 
 *         out_args = _get_out_args(out_args, out_types, shape, casting)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 802, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(PyString_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 802, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_routine_cache); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 802, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (!(likely(PyDict_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_6)->tp_name), 0))) __PYX_ERR(1, 802, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ops_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 802, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 802, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":801
 *         shape = broad.shape
 * 
 *         in_types, out_types, routine = _guess_routine(             # <<<<<<<<<<<<<<
 *             self.name, self._routine_cache, self._ops, in_args, dtype)
 * 
 */
  __pyx_t_2 = __pyx_f_4cupy_4core_4core__guess_routine(((PyObject*)__pyx_t_3), ((PyObject*)__pyx_t_6), ((PyObject*)__pyx_t_1), __pyx_v_in_args, __pyx_v_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_2 != Py_None)) {
    PyObject* sequence = __pyx_t_2;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(1, 801, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 801, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 801, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 801, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 801, __pyx_L1_error)
  }
  __pyx_v_in_types = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_out_types = __pyx_t_6;
  __pyx_t_6 = 0;
  __pyx_v_routine = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":804
 *             self.name, self._routine_cache, self._ops, in_args, dtype)
 * 
 *         out_args = _get_out_args(out_args, out_types, shape, casting)             # <<<<<<<<<<<<<<
 *         if self.nout == 1:
 *             ret = out_args[0]
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_out_types))||((__pyx_v_out_types) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_out_types)->tp_name), 0))) __PYX_ERR(1, 804, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_shape))||((__pyx_v_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_shape)->tp_name), 0))) __PYX_ERR(1, 804, __pyx_L1_error)
  if (!(likely(PyString_CheckExact(__pyx_v_casting))||((__pyx_v_casting) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_casting)->tp_name), 0))) __PYX_ERR(1, 804, __pyx_L1_error)
  __pyx_t_2 = __pyx_f_4cupy_4core_4core__get_out_args(__pyx_v_out_args, ((PyObject*)__pyx_v_out_types), ((PyObject*)__pyx_v_shape), ((PyObject*)__pyx_v_casting)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 804, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_out_args, ((PyObject*)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":805
 * 
 *         out_args = _get_out_args(out_args, out_types, shape, casting)
 *         if self.nout == 1:             # <<<<<<<<<<<<<<
 *             ret = out_args[0]
 *         else:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nout); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 805, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_2, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 805, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(1, 805, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_7) {

    /* "cupy/core/elementwise.pxi":806
 *         out_args = _get_out_args(out_args, out_types, shape, casting)
 *         if self.nout == 1:
 *             ret = out_args[0]             # <<<<<<<<<<<<<<
 *         else:
 *             ret = tuple(out_args)
 */
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 806, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 806, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_ret = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":805
 * 
 *         out_args = _get_out_args(out_args, out_types, shape, casting)
 *         if self.nout == 1:             # <<<<<<<<<<<<<<
 *             ret = out_args[0]
 *         else:
 */
    goto __pyx_L11;
  }

  /* "cupy/core/elementwise.pxi":808
 *             ret = out_args[0]
 *         else:
 *             ret = tuple(out_args)             # <<<<<<<<<<<<<<
 * 
 *         if 0 in shape:
 */
  /*else*/ {
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(1, 808, __pyx_L1_error)
    }
    __pyx_t_3 = PyList_AsTuple(__pyx_v_out_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 808, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_ret = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_L11:;

  /* "cupy/core/elementwise.pxi":810
 *             ret = tuple(out_args)
 * 
 *         if 0 in shape:             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
  __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_int_0, __pyx_v_shape, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(1, 810, __pyx_L1_error)
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/core/elementwise.pxi":811
 * 
 *         if 0 in shape:
 *             return ret             # <<<<<<<<<<<<<<
 * 
 *         inout_args = []
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_ret);
    __pyx_r = __pyx_v_ret;
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":810
 *             ret = tuple(out_args)
 * 
 *         if 0 in shape:             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":813
 *             return ret
 * 
 *         inout_args = []             # <<<<<<<<<<<<<<
 *         for i, t in enumerate(in_types):
 *             x = broad.values[i]
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 813, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_inout_args = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":814
 * 
 *         inout_args = []
 *         for i, t in enumerate(in_types):             # <<<<<<<<<<<<<<
 *             x = broad.values[i]
 *             inout_args.append(x if isinstance(x, ndarray) else t(x))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_3 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_in_types)) || PyTuple_CheckExact(__pyx_v_in_types)) {
    __pyx_t_2 = __pyx_v_in_types; __Pyx_INCREF(__pyx_t_2); __pyx_t_9 = 0;
    __pyx_t_10 = NULL;
  } else {
    __pyx_t_9 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_in_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 814, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_10 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 814, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_10)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_9); __Pyx_INCREF(__pyx_t_6); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(1, 814, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 814, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_9); __Pyx_INCREF(__pyx_t_6); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(1, 814, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 814, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_10(__pyx_t_2);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 814, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
    __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 814, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_3 = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":815
 *         inout_args = []
 *         for i, t in enumerate(in_types):
 *             x = broad.values[i]             # <<<<<<<<<<<<<<
 *             inout_args.append(x if isinstance(x, ndarray) else t(x))
 *         inout_args.extend(out_args)
 */
    if (unlikely(__pyx_v_broad->values == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 815, __pyx_L1_error)
    }
    __pyx_t_6 = PyObject_GetItem(__pyx_v_broad->values, __pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 815, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":816
 *         for i, t in enumerate(in_types):
 *             x = broad.values[i]
 *             inout_args.append(x if isinstance(x, ndarray) else t(x))             # <<<<<<<<<<<<<<
 *         inout_args.extend(out_args)
 *         inout_args, shape = _reduce_dims(inout_args, self._params, shape)
 */
    __pyx_t_8 = __Pyx_TypeCheck(__pyx_v_x, __pyx_ptype_4cupy_4core_4core_ndarray); 
    if ((__pyx_t_8 != 0)) {
      __Pyx_INCREF(__pyx_v_x);
      __pyx_t_6 = __pyx_v_x;
    } else {
      __Pyx_INCREF(__pyx_v_t);
      __pyx_t_4 = __pyx_v_t; __pyx_t_11 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_11) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 816, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_x};
          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 816, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_x};
          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 816, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else
        #endif
        {
          __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 816, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
          __Pyx_INCREF(__pyx_v_x);
          __Pyx_GIVEREF(__pyx_v_x);
          PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_v_x);
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 816, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    __pyx_t_13 = __Pyx_PyObject_Append(__pyx_v_inout_args, __pyx_t_6); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(1, 816, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":814
 * 
 *         inout_args = []
 *         for i, t in enumerate(in_types):             # <<<<<<<<<<<<<<
 *             x = broad.values[i]
 *             inout_args.append(x if isinstance(x, ndarray) else t(x))
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":817
 *             x = broad.values[i]
 *             inout_args.append(x if isinstance(x, ndarray) else t(x))
 *         inout_args.extend(out_args)             # <<<<<<<<<<<<<<
 *         inout_args, shape = _reduce_dims(inout_args, self._params, shape)
 *         indexer = Indexer(shape)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_inout_args, __pyx_n_s_extend); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 817, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_out_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 817, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_out_args};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 817, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_out_args};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 817, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 817, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_out_args);
      __Pyx_GIVEREF(__pyx_v_out_args);
      PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_out_args);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 817, __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_3); __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":818
 *             inout_args.append(x if isinstance(x, ndarray) else t(x))
 *         inout_args.extend(out_args)
 *         inout_args, shape = _reduce_dims(inout_args, self._params, shape)             # <<<<<<<<<<<<<<
 *         indexer = Indexer(shape)
 *         inout_args.append(indexer)
 */
  if (!(likely(PyList_CheckExact(__pyx_v_inout_args))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_inout_args)->tp_name), 0))) __PYX_ERR(1, 818, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 818, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 818, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_shape))||((__pyx_v_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_shape)->tp_name), 0))) __PYX_ERR(1, 818, __pyx_L1_error)
  __pyx_t_2 = __pyx_f_4cupy_4core_4core__reduce_dims(((PyObject*)__pyx_v_inout_args), ((PyObject*)__pyx_t_3), ((PyObject*)__pyx_v_shape), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 818, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(__pyx_t_2 != Py_None)) {
    PyObject* sequence = __pyx_t_2;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(1, 818, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_1);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 818, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 818, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 818, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_inout_args, __pyx_t_3);
  __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_shape, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":819
 *         inout_args.extend(out_args)
 *         inout_args, shape = _reduce_dims(inout_args, self._params, shape)
 *         indexer = Indexer(shape)             # <<<<<<<<<<<<<<
 *         inout_args.append(indexer)
 *         args_info = _get_args_info(inout_args)
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 819, __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_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 819, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":820
 *         inout_args, shape = _reduce_dims(inout_args, self._params, shape)
 *         indexer = Indexer(shape)
 *         inout_args.append(indexer)             # <<<<<<<<<<<<<<
 *         args_info = _get_args_info(inout_args)
 * 
 */
  __pyx_t_13 = __Pyx_PyObject_Append(__pyx_v_inout_args, ((PyObject *)__pyx_v_indexer)); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(1, 820, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":821
 *         indexer = Indexer(shape)
 *         inout_args.append(indexer)
 *         args_info = _get_args_info(inout_args)             # <<<<<<<<<<<<<<
 * 
 *         kern = _get_ufunc_kernel(
 */
  if (!(likely(PyList_CheckExact(__pyx_v_inout_args))||((__pyx_v_inout_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_inout_args)->tp_name), 0))) __PYX_ERR(1, 821, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_args_info(((PyObject*)__pyx_v_inout_args), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 821, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_args_info = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":823
 *         args_info = _get_args_info(inout_args)
 * 
 *         kern = _get_ufunc_kernel(             # <<<<<<<<<<<<<<
 *             in_types, out_types, routine, args_info,
 *             self._params, self.name, self._preamble)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_ufunc_kernel); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 823, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/elementwise.pxi":825
 *         kern = _get_ufunc_kernel(
 *             in_types, out_types, routine, args_info,
 *             self._params, self.name, self._preamble)             # <<<<<<<<<<<<<<
 * 
 *         kern.linear_launch(indexer.size, inout_args)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 825, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 825, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_preamble_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 825, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_12 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_12);
      __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[8] = {__pyx_t_12, __pyx_v_in_types, __pyx_v_out_types, __pyx_v_routine, __pyx_v_args_info, __pyx_t_3, __pyx_t_6, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 7+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 823, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[8] = {__pyx_t_12, __pyx_v_in_types, __pyx_v_out_types, __pyx_v_routine, __pyx_v_args_info, __pyx_t_3, __pyx_t_6, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 7+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 823, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_11 = PyTuple_New(7+__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (__pyx_t_12) {
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_12); __pyx_t_12 = NULL;
    }
    __Pyx_INCREF(__pyx_v_in_types);
    __Pyx_GIVEREF(__pyx_v_in_types);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_5, __pyx_v_in_types);
    __Pyx_INCREF(__pyx_v_out_types);
    __Pyx_GIVEREF(__pyx_v_out_types);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_5, __pyx_v_out_types);
    __Pyx_INCREF(__pyx_v_routine);
    __Pyx_GIVEREF(__pyx_v_routine);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_5, __pyx_v_routine);
    __Pyx_INCREF(__pyx_v_args_info);
    __Pyx_GIVEREF(__pyx_v_args_info);
    PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_5, __pyx_v_args_info);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_5, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 5+__pyx_t_5, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_11, 6+__pyx_t_5, __pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_6 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":823
 *         args_info = _get_args_info(inout_args)
 * 
 *         kern = _get_ufunc_kernel(             # <<<<<<<<<<<<<<
 *             in_types, out_types, routine, args_info,
 *             self._params, self.name, self._preamble)
 */
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4cuda_8function_Function))))) __PYX_ERR(1, 823, __pyx_L1_error)
  __pyx_v_kern = ((struct __pyx_obj_4cupy_4cuda_8function_Function *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":827
 *             self._params, self.name, self._preamble)
 * 
 *         kern.linear_launch(indexer.size, inout_args)             # <<<<<<<<<<<<<<
 *         return ret
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Function *)__pyx_v_kern->__pyx_vtab)->linear_launch(__pyx_v_kern, __pyx_v_indexer->size, __pyx_v_inout_args, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 827, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":828
 * 
 *         kern.linear_launch(indexer.size, inout_args)
 *         return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ret);
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":752
 *         return types
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Applies the universal function to arguments elementwise.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core.ufunc.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF((PyObject *)__pyx_v_kern);
  __Pyx_XDECREF(__pyx_v_out);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_casting);
  __Pyx_XDECREF(__pyx_v_in_args);
  __Pyx_XDECREF(__pyx_v_out_args);
  __Pyx_XDECREF((PyObject *)__pyx_v_broad);
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XDECREF(__pyx_v_routine);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_inout_args);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_indexer);
  __Pyx_XDECREF(__pyx_v_args_info);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":831
 * 
 * 
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                    default_casting=None):
 *     _ops = []
 */

static PyObject *__pyx_pw_4cupy_4core_4core_33create_ufunc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_create_ufunc(PyObject *__pyx_v_name, PyObject *__pyx_v_ops, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_create_ufunc *__pyx_optional_args) {
  PyObject *__pyx_v_routine = ((PyObject *)Py_None);
  PyObject *__pyx_v_preamble = ((PyObject *)__pyx_kp_s__5);
  PyObject *__pyx_v_doc = ((PyObject *)__pyx_kp_s__5);

  /* "cupy/core/elementwise.pxi":832
 * 
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc='',
 *                    default_casting=None):             # <<<<<<<<<<<<<<
 *     _ops = []
 *     for t in ops:
 */
  PyObject *__pyx_v_default_casting = ((PyObject *)Py_None);
  PyObject *__pyx_v__ops = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_typ = NULL;
  PyObject *__pyx_v_rt = NULL;
  PyObject *__pyx_v_types = NULL;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  PyObject *__pyx_v_ret = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *(*__pyx_t_12)(PyObject *);
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  __Pyx_RefNannySetupContext("create_ufunc", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_routine = __pyx_optional_args->routine;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_preamble = __pyx_optional_args->preamble;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_doc = __pyx_optional_args->doc;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_default_casting = __pyx_optional_args->default_casting;
          }
        }
      }
    }
  }

  /* "cupy/core/elementwise.pxi":833
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc='',
 *                    default_casting=None):
 *     _ops = []             # <<<<<<<<<<<<<<
 *     for t in ops:
 *         if not isinstance(t, tuple):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 833, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__ops = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":834
 *                    default_casting=None):
 *     _ops = []
 *     for t in ops:             # <<<<<<<<<<<<<<
 *         if not isinstance(t, tuple):
 *             typ = t
 */
  if (likely(PyList_CheckExact(__pyx_v_ops)) || PyTuple_CheckExact(__pyx_v_ops)) {
    __pyx_t_1 = __pyx_v_ops; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_ops); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 834, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 834, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 834, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 834, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 834, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 834, __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(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 834, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/elementwise.pxi":835
 *     _ops = []
 *     for t in ops:
 *         if not isinstance(t, tuple):             # <<<<<<<<<<<<<<
 *             typ = t
 *             rt = routine
 */
    __pyx_t_5 = PyTuple_Check(__pyx_v_t); 
    __pyx_t_6 = ((!(__pyx_t_5 != 0)) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/elementwise.pxi":836
 *     for t in ops:
 *         if not isinstance(t, tuple):
 *             typ = t             # <<<<<<<<<<<<<<
 *             rt = routine
 *         else:
 */
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_XDECREF_SET(__pyx_v_typ, __pyx_v_t);

      /* "cupy/core/elementwise.pxi":837
 *         if not isinstance(t, tuple):
 *             typ = t
 *             rt = routine             # <<<<<<<<<<<<<<
 *         else:
 *             typ, rt = t
 */
      __Pyx_INCREF(__pyx_v_routine);
      __Pyx_XDECREF_SET(__pyx_v_rt, __pyx_v_routine);

      /* "cupy/core/elementwise.pxi":835
 *     _ops = []
 *     for t in ops:
 *         if not isinstance(t, tuple):             # <<<<<<<<<<<<<<
 *             typ = t
 *             rt = routine
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":839
 *             rt = routine
 *         else:
 *             typ, rt = t             # <<<<<<<<<<<<<<
 * 
 *         types = typ.split('->')
 */
    /*else*/ {
      if ((likely(PyTuple_CheckExact(__pyx_v_t))) || (PyList_CheckExact(__pyx_v_t))) {
        PyObject* sequence = __pyx_v_t;
        #if !CYTHON_COMPILING_IN_PYPY
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(1, 839, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_7);
        #else
        __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 839, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 839, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      } else {
        Py_ssize_t index = -1;
        __pyx_t_8 = PyObject_GetIter(__pyx_v_t); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 839, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
        index = 0; __pyx_t_4 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(1, 839, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(1, 839, __pyx_L1_error)
        __pyx_L7_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_typ, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_rt, __pyx_t_7);
      __pyx_t_7 = 0;
    }
    __pyx_L5:;

    /* "cupy/core/elementwise.pxi":841
 *             typ, rt = t
 * 
 *         types = typ.split('->')             # <<<<<<<<<<<<<<
 *         if len(types) == 1:
 *             in_types = out_types = tuple(types)
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_typ, __pyx_n_s_split); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 841, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__91, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 841, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF_SET(__pyx_v_types, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/elementwise.pxi":842
 * 
 *         types = typ.split('->')
 *         if len(types) == 1:             # <<<<<<<<<<<<<<
 *             in_types = out_types = tuple(types)
 *         else:
 */
    __pyx_t_10 = PyObject_Length(__pyx_v_types); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(1, 842, __pyx_L1_error)
    __pyx_t_6 = ((__pyx_t_10 == 1) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/elementwise.pxi":843
 *         types = typ.split('->')
 *         if len(types) == 1:
 *             in_types = out_types = tuple(types)             # <<<<<<<<<<<<<<
 *         else:
 *             in_types, out_types = map(tuple, types)
 */
      __pyx_t_4 = PySequence_Tuple(__pyx_v_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 843, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_in_types, __pyx_t_4);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_out_types, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/elementwise.pxi":842
 * 
 *         types = typ.split('->')
 *         if len(types) == 1:             # <<<<<<<<<<<<<<
 *             in_types = out_types = tuple(types)
 *         else:
 */
      goto __pyx_L8;
    }

    /* "cupy/core/elementwise.pxi":845
 *             in_types = out_types = tuple(types)
 *         else:
 *             in_types, out_types = map(tuple, types)             # <<<<<<<<<<<<<<
 *         in_types = tuple([numpy.dtype(t).type for t in in_types])
 *         out_types = tuple([numpy.dtype(t).type for t in out_types])
 */
    /*else*/ {
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 845, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)(&PyTuple_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyTuple_Type)));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)(&PyTuple_Type)));
      __Pyx_INCREF(__pyx_v_types);
      __Pyx_GIVEREF(__pyx_v_types);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_types);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 845, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) {
        PyObject* sequence = __pyx_t_7;
        #if !CYTHON_COMPILING_IN_PYPY
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(1, 845, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_8);
        #else
        __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 845, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 845, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 845, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_4 = __pyx_t_9(__pyx_t_11); if (unlikely(!__pyx_t_4)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 1; __pyx_t_8 = __pyx_t_9(__pyx_t_11); if (unlikely(!__pyx_t_8)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_8);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_11), 2) < 0) __PYX_ERR(1, 845, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L10_unpacking_done;
        __pyx_L9_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(1, 845, __pyx_L1_error)
        __pyx_L10_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_in_types, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_out_types, __pyx_t_8);
      __pyx_t_8 = 0;
    }
    __pyx_L8:;

    /* "cupy/core/elementwise.pxi":846
 *         else:
 *             in_types, out_types = map(tuple, types)
 *         in_types = tuple([numpy.dtype(t).type for t in in_types])             # <<<<<<<<<<<<<<
 *         out_types = tuple([numpy.dtype(t).type for t in out_types])
 *         _ops.append((in_types, out_types, rt))
 */
    __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 846, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (likely(PyList_CheckExact(__pyx_v_in_types)) || PyTuple_CheckExact(__pyx_v_in_types)) {
      __pyx_t_8 = __pyx_v_in_types; __Pyx_INCREF(__pyx_t_8); __pyx_t_10 = 0;
      __pyx_t_12 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_in_types); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 846, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_12 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 846, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_12)) {
        if (likely(PyList_CheckExact(__pyx_t_8))) {
          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_8)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 846, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 846, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 846, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 846, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        }
      } else {
        __pyx_t_4 = __pyx_t_12(__pyx_t_8);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(1, 846, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 846, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_dtype); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 846, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_13);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_13, function);
        }
      }
      if (!__pyx_t_11) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_v_t); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 846, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_13)) {
          PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_t};
          __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 846, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_t_4);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
          PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_t};
          __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 846, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_t_4);
        } else
        #endif
        {
          __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 846, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_11); __pyx_t_11 = NULL;
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_v_t);
          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_14, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 846, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_type); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 846, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_7, (PyObject*)__pyx_t_13))) __PYX_ERR(1, 846, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyList_AsTuple(((PyObject*)__pyx_t_7)); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 846, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF_SET(__pyx_v_in_types, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/elementwise.pxi":847
 *             in_types, out_types = map(tuple, types)
 *         in_types = tuple([numpy.dtype(t).type for t in in_types])
 *         out_types = tuple([numpy.dtype(t).type for t in out_types])             # <<<<<<<<<<<<<<
 *         _ops.append((in_types, out_types, rt))
 * 
 */
    __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 847, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (likely(PyList_CheckExact(__pyx_v_out_types)) || PyTuple_CheckExact(__pyx_v_out_types)) {
      __pyx_t_7 = __pyx_v_out_types; __Pyx_INCREF(__pyx_t_7); __pyx_t_10 = 0;
      __pyx_t_12 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_out_types); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 847, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_12 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 847, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_12)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_13 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_10); __Pyx_INCREF(__pyx_t_13); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 847, __pyx_L1_error)
          #else
          __pyx_t_13 = PySequence_ITEM(__pyx_t_7, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 847, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_13 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_10); __Pyx_INCREF(__pyx_t_13); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 847, __pyx_L1_error)
          #else
          __pyx_t_13 = PySequence_ITEM(__pyx_t_7, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 847, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          #endif
        }
      } else {
        __pyx_t_13 = __pyx_t_12(__pyx_t_7);
        if (unlikely(!__pyx_t_13)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(1, 847, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_13);
      }
      __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_13);
      __pyx_t_13 = 0;
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 847, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dtype); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 847, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_14);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_14, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_v_t); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 847, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_14)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_t};
          __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 847, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_13);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_t};
          __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 847, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_13);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 847, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); __pyx_t_4 = NULL;
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_t);
          __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_11, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 847, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_type); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 847, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_8, (PyObject*)__pyx_t_14))) __PYX_ERR(1, 847, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyList_AsTuple(((PyObject*)__pyx_t_8)); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 847, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF_SET(__pyx_v_out_types, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":848
 *         in_types = tuple([numpy.dtype(t).type for t in in_types])
 *         out_types = tuple([numpy.dtype(t).type for t in out_types])
 *         _ops.append((in_types, out_types, rt))             # <<<<<<<<<<<<<<
 * 
 *     ret = ufunc(name, len(_ops[0][0]), len(_ops[0][1]), _ops, preamble, doc,
 */
    __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 848, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_in_types);
    __Pyx_GIVEREF(__pyx_v_in_types);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_in_types);
    __Pyx_INCREF(__pyx_v_out_types);
    __Pyx_GIVEREF(__pyx_v_out_types);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_out_types);
    __Pyx_INCREF(__pyx_v_rt);
    __Pyx_GIVEREF(__pyx_v_rt);
    PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_v_rt);
    __pyx_t_15 = __Pyx_PyList_Append(__pyx_v__ops, __pyx_t_7); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(1, 848, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":834
 *                    default_casting=None):
 *     _ops = []
 *     for t in ops:             # <<<<<<<<<<<<<<
 *         if not isinstance(t, tuple):
 *             typ = t
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":850
 *         _ops.append((in_types, out_types, rt))
 * 
 *     ret = ufunc(name, len(_ops[0][0]), len(_ops[0][1]), _ops, preamble, doc,             # <<<<<<<<<<<<<<
 *                 default_casting=default_casting)
 *     return ret
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ufunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v__ops, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_7, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_2 = PyObject_Length(__pyx_t_8); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(1, 850, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v__ops, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_14 = __Pyx_GetItemInt(__pyx_t_7, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_2 = PyObject_Length(__pyx_t_14); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(1, 850, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_7 = PyTuple_New(6); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_name);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_14);
  __Pyx_INCREF(__pyx_v__ops);
  __Pyx_GIVEREF(__pyx_v__ops);
  PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_v__ops);
  __Pyx_INCREF(__pyx_v_preamble);
  __Pyx_GIVEREF(__pyx_v_preamble);
  PyTuple_SET_ITEM(__pyx_t_7, 4, __pyx_v_preamble);
  __Pyx_INCREF(__pyx_v_doc);
  __Pyx_GIVEREF(__pyx_v_doc);
  PyTuple_SET_ITEM(__pyx_t_7, 5, __pyx_v_doc);
  __pyx_t_8 = 0;
  __pyx_t_14 = 0;

  /* "cupy/core/elementwise.pxi":851
 * 
 *     ret = ufunc(name, len(_ops[0][0]), len(_ops[0][1]), _ops, preamble, doc,
 *                 default_casting=default_casting)             # <<<<<<<<<<<<<<
 *     return ret
 */
  __pyx_t_14 = PyDict_New(); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 851, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_default_casting, __pyx_v_default_casting) < 0) __PYX_ERR(1, 851, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":850
 *         _ops.append((in_types, out_types, rt))
 * 
 *     ret = ufunc(name, len(_ops[0][0]), len(_ops[0][1]), _ops, preamble, doc,             # <<<<<<<<<<<<<<
 *                 default_casting=default_casting)
 *     return ret
 */
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, __pyx_t_14); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_v_ret = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":852
 *     ret = ufunc(name, len(_ops[0][0]), len(_ops[0][1]), _ops, preamble, doc,
 *                 default_casting=default_casting)
 *     return ret             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ret);
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":831
 * 
 * 
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                    default_casting=None):
 *     _ops = []
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("cupy.core.core.create_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__ops);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_typ);
  __Pyx_XDECREF(__pyx_v_rt);
  __Pyx_XDECREF(__pyx_v_types);
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_33create_ufunc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_32create_ufunc[] = "create_ufunc(name, ops, routine=None, preamble='', doc='', default_casting=None)";
static PyObject *__pyx_pw_4cupy_4core_4core_33create_ufunc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_ops = 0;
  PyObject *__pyx_v_routine = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_doc = 0;
  PyObject *__pyx_v_default_casting = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_ufunc (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,&__pyx_n_s_ops,&__pyx_n_s_routine,&__pyx_n_s_preamble,&__pyx_n_s_doc,&__pyx_n_s_default_casting,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)__pyx_kp_s__5);
    values[4] = ((PyObject *)__pyx_kp_s__5);

    /* "cupy/core/elementwise.pxi":832
 * 
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc='',
 *                    default_casting=None):             # <<<<<<<<<<<<<<
 *     _ops = []
 *     for t in ops:
 */
    values[5] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ops)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_ufunc", 0, 2, 6, 1); __PYX_ERR(1, 831, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_routine);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_preamble);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_doc);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_default_casting);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_ufunc") < 0)) __PYX_ERR(1, 831, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_name = values[0];
    __pyx_v_ops = values[1];
    __pyx_v_routine = values[2];
    __pyx_v_preamble = values[3];
    __pyx_v_doc = values[4];
    __pyx_v_default_casting = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_ufunc", 0, 2, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 831, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.create_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_32create_ufunc(__pyx_self, __pyx_v_name, __pyx_v_ops, __pyx_v_routine, __pyx_v_preamble, __pyx_v_doc, __pyx_v_default_casting);

  /* "cupy/core/elementwise.pxi":831
 * 
 * 
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                    default_casting=None):
 *     _ops = []
 */

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

static PyObject *__pyx_pf_4cupy_4core_4core_32create_ufunc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_ops, PyObject *__pyx_v_routine, PyObject *__pyx_v_preamble, PyObject *__pyx_v_doc, PyObject *__pyx_v_default_casting) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_create_ufunc __pyx_t_2;
  __Pyx_RefNannySetupContext("create_ufunc", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.routine = __pyx_v_routine;
  __pyx_t_2.preamble = __pyx_v_preamble;
  __pyx_t_2.doc = __pyx_v_doc;
  __pyx_t_2.default_casting = __pyx_v_default_casting;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_v_name, __pyx_v_ops, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 831, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/reduction.pxi":10
 * 
 * 
 * cpdef _get_simple_reduction_kernel(             # <<<<<<<<<<<<<<
 *         name, block_size, reduce_type, params, identity,
 *         pre_map_expr, reduce_expr, post_map_expr,
 */

static PyObject *__pyx_pw_4cupy_4core_4core_35_get_simple_reduction_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_simple_reduction_kernel(PyObject *__pyx_v_name, PyObject *__pyx_v_block_size, PyObject *__pyx_v_reduce_type, PyObject *__pyx_v_params, PyObject *__pyx_v_identity, PyObject *__pyx_v_pre_map_expr, PyObject *__pyx_v_reduce_expr, PyObject *__pyx_v_post_map_expr, PyObject *__pyx_v_type_preamble, PyObject *__pyx_v_input_expr, PyObject *__pyx_v_output_expr, PyObject *__pyx_v_preamble, PyObject *__pyx_v_options, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_module_code = NULL;
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_v_module = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache __pyx_t_6;
  __Pyx_RefNannySetupContext("_get_simple_reduction_kernel", 0);
  __Pyx_INCREF(__pyx_v_identity);

  /* "cupy/core/reduction.pxi":14
 *         pre_map_expr, reduce_expr, post_map_expr,
 *         type_preamble, input_expr, output_expr, preamble, options):
 *     if identity is None:             # <<<<<<<<<<<<<<
 *         identity = ''
 *     module_code = string.Template('''
 */
  __pyx_t_1 = (__pyx_v_identity == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/reduction.pxi":15
 *         type_preamble, input_expr, output_expr, preamble, options):
 *     if identity is None:
 *         identity = ''             # <<<<<<<<<<<<<<
 *     module_code = string.Template('''
 *     ${type_preamble}
 */
    __Pyx_INCREF(__pyx_kp_s__5);
    __Pyx_DECREF_SET(__pyx_v_identity, __pyx_kp_s__5);

    /* "cupy/core/reduction.pxi":14
 *         pre_map_expr, reduce_expr, post_map_expr,
 *         type_preamble, input_expr, output_expr, preamble, options):
 *     if identity is None:             # <<<<<<<<<<<<<<
 *         identity = ''
 *     module_code = string.Template('''
 */
  }

  /* "cupy/core/reduction.pxi":16
 *     if identity is None:
 *         identity = ''
 *     module_code = string.Template('''             # <<<<<<<<<<<<<<
 *     ${type_preamble}
 *     ${preamble}
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_string); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Template); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__92, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":92
 *         }
 *       }
 *     }''').substitute(             # <<<<<<<<<<<<<<
 *         name=name,
 *         block_size=block_size,
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_substitute); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 92, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":93
 *       }
 *     }''').substitute(
 *         name=name,             # <<<<<<<<<<<<<<
 *         block_size=block_size,
 *         reduce_type=reduce_type,
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 93, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":94
 *     }''').substitute(
 *         name=name,
 *         block_size=block_size,             # <<<<<<<<<<<<<<
 *         reduce_type=reduce_type,
 *         params=params,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_block_size, __pyx_v_block_size) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":95
 *         name=name,
 *         block_size=block_size,
 *         reduce_type=reduce_type,             # <<<<<<<<<<<<<<
 *         params=params,
 *         identity=identity,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reduce_type, __pyx_v_reduce_type) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":96
 *         block_size=block_size,
 *         reduce_type=reduce_type,
 *         params=params,             # <<<<<<<<<<<<<<
 *         identity=identity,
 *         reduce_expr=reduce_expr,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_params, __pyx_v_params) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":97
 *         reduce_type=reduce_type,
 *         params=params,
 *         identity=identity,             # <<<<<<<<<<<<<<
 *         reduce_expr=reduce_expr,
 *         pre_map_expr=pre_map_expr,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_identity, __pyx_v_identity) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":98
 *         params=params,
 *         identity=identity,
 *         reduce_expr=reduce_expr,             # <<<<<<<<<<<<<<
 *         pre_map_expr=pre_map_expr,
 *         post_map_expr=post_map_expr,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reduce_expr, __pyx_v_reduce_expr) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":99
 *         identity=identity,
 *         reduce_expr=reduce_expr,
 *         pre_map_expr=pre_map_expr,             # <<<<<<<<<<<<<<
 *         post_map_expr=post_map_expr,
 *         type_preamble=type_preamble,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_pre_map_expr, __pyx_v_pre_map_expr) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":100
 *         reduce_expr=reduce_expr,
 *         pre_map_expr=pre_map_expr,
 *         post_map_expr=post_map_expr,             # <<<<<<<<<<<<<<
 *         type_preamble=type_preamble,
 *         input_expr=input_expr,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_post_map_expr, __pyx_v_post_map_expr) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":101
 *         pre_map_expr=pre_map_expr,
 *         post_map_expr=post_map_expr,
 *         type_preamble=type_preamble,             # <<<<<<<<<<<<<<
 *         input_expr=input_expr,
 *         output_expr=output_expr,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_type_preamble, __pyx_v_type_preamble) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":102
 *         post_map_expr=post_map_expr,
 *         type_preamble=type_preamble,
 *         input_expr=input_expr,             # <<<<<<<<<<<<<<
 *         output_expr=output_expr,
 *         preamble=preamble)
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_input_expr, __pyx_v_input_expr) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":103
 *         type_preamble=type_preamble,
 *         input_expr=input_expr,
 *         output_expr=output_expr,             # <<<<<<<<<<<<<<
 *         preamble=preamble)
 *     module = compile_with_cache(module_code, options)
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_output_expr, __pyx_v_output_expr) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":104
 *         input_expr=input_expr,
 *         output_expr=output_expr,
 *         preamble=preamble)             # <<<<<<<<<<<<<<
 *     module = compile_with_cache(module_code, options)
 *     return module.get_function(name)
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_preamble, __pyx_v_preamble) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":92
 *         }
 *       }
 *     }''').substitute(             # <<<<<<<<<<<<<<
 *         name=name,
 *         block_size=block_size,
 */
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 92, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_module_code = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":105
 *         output_expr=output_expr,
 *         preamble=preamble)
 *     module = compile_with_cache(module_code, options)             # <<<<<<<<<<<<<<
 *     return module.get_function(name)
 * 
 */
  if (!(likely(PyString_CheckExact(__pyx_v_module_code))||((__pyx_v_module_code) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_module_code)->tp_name), 0))) __PYX_ERR(5, 105, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_options))||((__pyx_v_options) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_options)->tp_name), 0))) __PYX_ERR(5, 105, __pyx_L1_error)
  __pyx_t_6.__pyx_n = 1;
  __pyx_t_6.options = ((PyObject*)__pyx_v_options);
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_compile_with_cache(((PyObject*)__pyx_v_module_code), 0, &__pyx_t_6)); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_module = ((struct __pyx_obj_4cupy_4cuda_8function_Module *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":106
 *         preamble=preamble)
 *     module = compile_with_cache(module_code, options)
 *     return module.get_function(name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyString_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(5, 106, __pyx_L1_error)
  __pyx_t_5 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Module *)__pyx_v_module->__pyx_vtab)->get_function(__pyx_v_module, ((PyObject*)__pyx_v_name), 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":10
 * 
 * 
 * cpdef _get_simple_reduction_kernel(             # <<<<<<<<<<<<<<
 *         name, block_size, reduce_type, params, identity,
 *         pre_map_expr, reduce_expr, post_map_expr,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core._get_simple_reduction_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_module_code);
  __Pyx_XDECREF((PyObject *)__pyx_v_module);
  __Pyx_XDECREF(__pyx_v_identity);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_35_get_simple_reduction_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_34_get_simple_reduction_kernel[] = "_get_simple_reduction_kernel(name, block_size, reduce_type, params, identity, pre_map_expr, reduce_expr, post_map_expr, type_preamble, input_expr, output_expr, preamble, options)";
static PyObject *__pyx_pw_4cupy_4core_4core_35_get_simple_reduction_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_block_size = 0;
  PyObject *__pyx_v_reduce_type = 0;
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_identity = 0;
  PyObject *__pyx_v_pre_map_expr = 0;
  PyObject *__pyx_v_reduce_expr = 0;
  PyObject *__pyx_v_post_map_expr = 0;
  PyObject *__pyx_v_type_preamble = 0;
  PyObject *__pyx_v_input_expr = 0;
  PyObject *__pyx_v_output_expr = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_options = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_simple_reduction_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,&__pyx_n_s_block_size,&__pyx_n_s_reduce_type,&__pyx_n_s_params,&__pyx_n_s_identity,&__pyx_n_s_pre_map_expr,&__pyx_n_s_reduce_expr,&__pyx_n_s_post_map_expr,&__pyx_n_s_type_preamble,&__pyx_n_s_input_expr,&__pyx_n_s_output_expr,&__pyx_n_s_preamble,&__pyx_n_s_options,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        CYTHON_FALLTHROUGH;
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_block_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 1); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_reduce_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 2); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 3); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_identity)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 4); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pre_map_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 5); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_reduce_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 6); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_post_map_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 7); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_type_preamble)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 8); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_input_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 9); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_output_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 10); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (likely((values[11] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_preamble)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 11); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 12:
        if (likely((values[12] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_options)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 12); __PYX_ERR(5, 10, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_simple_reduction_kernel") < 0)) __PYX_ERR(5, 10, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 13) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
      values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
      values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
      values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
    }
    __pyx_v_name = values[0];
    __pyx_v_block_size = values[1];
    __pyx_v_reduce_type = values[2];
    __pyx_v_params = values[3];
    __pyx_v_identity = values[4];
    __pyx_v_pre_map_expr = values[5];
    __pyx_v_reduce_expr = values[6];
    __pyx_v_post_map_expr = values[7];
    __pyx_v_type_preamble = values[8];
    __pyx_v_input_expr = values[9];
    __pyx_v_output_expr = values[10];
    __pyx_v_preamble = values[11];
    __pyx_v_options = values[12];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 10, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_simple_reduction_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_34_get_simple_reduction_kernel(__pyx_self, __pyx_v_name, __pyx_v_block_size, __pyx_v_reduce_type, __pyx_v_params, __pyx_v_identity, __pyx_v_pre_map_expr, __pyx_v_reduce_expr, __pyx_v_post_map_expr, __pyx_v_type_preamble, __pyx_v_input_expr, __pyx_v_output_expr, __pyx_v_preamble, __pyx_v_options);

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

static PyObject *__pyx_pf_4cupy_4core_4core_34_get_simple_reduction_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_block_size, PyObject *__pyx_v_reduce_type, PyObject *__pyx_v_params, PyObject *__pyx_v_identity, PyObject *__pyx_v_pre_map_expr, PyObject *__pyx_v_reduce_expr, PyObject *__pyx_v_post_map_expr, PyObject *__pyx_v_type_preamble, PyObject *__pyx_v_input_expr, PyObject *__pyx_v_output_expr, PyObject *__pyx_v_preamble, PyObject *__pyx_v_options) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_simple_reduction_kernel", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_simple_reduction_kernel(__pyx_v_name, __pyx_v_block_size, __pyx_v_reduce_type, __pyx_v_params, __pyx_v_identity, __pyx_v_pre_map_expr, __pyx_v_reduce_expr, __pyx_v_post_map_expr, __pyx_v_type_preamble, __pyx_v_input_expr, __pyx_v_output_expr, __pyx_v_preamble, __pyx_v_options, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/reduction.pxi":109
 * 
 * 
 * cpdef tuple _get_axis(object axis, Py_ssize_t ndim):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t dim
 *     if axis is None:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_37_get_axis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_axis(PyObject *__pyx_v_axis, Py_ssize_t __pyx_v_ndim, CYTHON_UNUSED int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_dim;
  PyObject *__pyx_v_raxis = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("_get_axis", 0);
  __Pyx_INCREF(__pyx_v_axis);

  /* "cupy/core/reduction.pxi":111
 * cpdef tuple _get_axis(object axis, Py_ssize_t ndim):
 *     cdef Py_ssize_t dim
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         axis = tuple(range(ndim))
 *     elif isinstance(axis, collections.Sequence):
 */
  __pyx_t_1 = (__pyx_v_axis == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/reduction.pxi":112
 *     cdef Py_ssize_t dim
 *     if axis is None:
 *         axis = tuple(range(ndim))             # <<<<<<<<<<<<<<
 *     elif isinstance(axis, collections.Sequence):
 *         axis = tuple(axis)
 */
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":111
 * cpdef tuple _get_axis(object axis, Py_ssize_t ndim):
 *     cdef Py_ssize_t dim
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         axis = tuple(range(ndim))
 *     elif isinstance(axis, collections.Sequence):
 */
    goto __pyx_L3;
  }

  /* "cupy/core/reduction.pxi":113
 *     if axis is None:
 *         axis = tuple(range(ndim))
 *     elif isinstance(axis, collections.Sequence):             # <<<<<<<<<<<<<<
 *         axis = tuple(axis)
 *     else:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_collections); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_Sequence); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_axis, __pyx_t_3); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(5, 113, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":114
 *         axis = tuple(range(ndim))
 *     elif isinstance(axis, collections.Sequence):
 *         axis = tuple(axis)             # <<<<<<<<<<<<<<
 *     else:
 *         axis = axis,
 */
    __pyx_t_3 = PySequence_Tuple(__pyx_v_axis); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 114, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/reduction.pxi":113
 *     if axis is None:
 *         axis = tuple(range(ndim))
 *     elif isinstance(axis, collections.Sequence):             # <<<<<<<<<<<<<<
 *         axis = tuple(axis)
 *     else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/reduction.pxi":116
 *         axis = tuple(axis)
 *     else:
 *         axis = axis,             # <<<<<<<<<<<<<<
 * 
 *     for dim in axis:
 */
  /*else*/ {
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 116, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_axis);
    __Pyx_GIVEREF(__pyx_v_axis);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_axis);
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/reduction.pxi":118
 *         axis = axis,
 * 
 *     for dim in axis:             # <<<<<<<<<<<<<<
 *         if dim < -ndim or dim >= ndim:
 *             raise ValueError('Axis overrun')
 */
  if (likely(PyList_CheckExact(__pyx_v_axis)) || PyTuple_CheckExact(__pyx_v_axis)) {
    __pyx_t_3 = __pyx_v_axis; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_axis); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 118, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 118, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_5 >= 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_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(5, 118, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 118, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(5, 118, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 118, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_6(__pyx_t_3);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(5, 118, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 118, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_dim = __pyx_t_7;

    /* "cupy/core/reduction.pxi":119
 * 
 *     for dim in axis:
 *         if dim < -ndim or dim >= ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError('Axis overrun')
 *     axis = tuple(sorted([dim % ndim for dim in axis]))
 */
    __pyx_t_2 = ((__pyx_v_dim < (-__pyx_v_ndim)) != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_dim >= __pyx_v_ndim) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_1) {

      /* "cupy/core/reduction.pxi":120
 *     for dim in axis:
 *         if dim < -ndim or dim >= ndim:
 *             raise ValueError('Axis overrun')             # <<<<<<<<<<<<<<
 *     axis = tuple(sorted([dim % ndim for dim in axis]))
 *     raxis = tuple([dim for dim in range(ndim) if dim not in axis])
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__93, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 120, __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(5, 120, __pyx_L1_error)

      /* "cupy/core/reduction.pxi":119
 * 
 *     for dim in axis:
 *         if dim < -ndim or dim >= ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError('Axis overrun')
 *     axis = tuple(sorted([dim % ndim for dim in axis]))
 */
    }

    /* "cupy/core/reduction.pxi":118
 *         axis = axis,
 * 
 *     for dim in axis:             # <<<<<<<<<<<<<<
 *         if dim < -ndim or dim >= ndim:
 *             raise ValueError('Axis overrun')
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":121
 *         if dim < -ndim or dim >= ndim:
 *             raise ValueError('Axis overrun')
 *     axis = tuple(sorted([dim % ndim for dim in axis]))             # <<<<<<<<<<<<<<
 *     raxis = tuple([dim for dim in range(ndim) if dim not in axis])
 *     return axis, raxis
 */
  __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 121, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (likely(PyList_CheckExact(__pyx_v_axis)) || PyTuple_CheckExact(__pyx_v_axis)) {
    __pyx_t_8 = __pyx_v_axis; __Pyx_INCREF(__pyx_t_8); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_axis); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 121, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_8))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_9 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(5, 121, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 121, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(5, 121, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 121, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      }
    } else {
      __pyx_t_9 = __pyx_t_6(__pyx_t_8);
      if (unlikely(!__pyx_t_9)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(5, 121, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_9);
    }
    __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 121, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_v_dim = __pyx_t_7;
    if (unlikely(__pyx_v_ndim == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(5, 121, __pyx_L1_error)
    }
    __pyx_t_9 = PyInt_FromSsize_t(__Pyx_mod_Py_ssize_t(__pyx_v_dim, __pyx_v_ndim)); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_9))) __PYX_ERR(5, 121, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_3 = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_10 = PyList_Sort(__pyx_t_3); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(5, 121, __pyx_L1_error)
  if (unlikely(__pyx_t_3 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(5, 121, __pyx_L1_error)
  }
  __pyx_t_4 = PyList_AsTuple(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 121, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":122
 *             raise ValueError('Axis overrun')
 *     axis = tuple(sorted([dim % ndim for dim in axis]))
 *     raxis = tuple([dim for dim in range(ndim) if dim not in axis])             # <<<<<<<<<<<<<<
 *     return axis, raxis
 * 
 */
  __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 122, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __pyx_v_ndim;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_5; __pyx_t_7+=1) {
    __pyx_v_dim = __pyx_t_7;
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_t_3, __pyx_v_axis, Py_NE)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(5, 122, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 122, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_3))) __PYX_ERR(5, 122, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
  }
  __pyx_t_3 = PyList_AsTuple(((PyObject*)__pyx_t_4)); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 122, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_raxis = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":123
 *     axis = tuple(sorted([dim % ndim for dim in axis]))
 *     raxis = tuple([dim for dim in range(ndim) if dim not in axis])
 *     return axis, raxis             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_axis);
  __Pyx_GIVEREF(__pyx_v_axis);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_axis);
  __Pyx_INCREF(__pyx_v_raxis);
  __Pyx_GIVEREF(__pyx_v_raxis);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_raxis);
  __pyx_r = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":109
 * 
 * 
 * cpdef tuple _get_axis(object axis, Py_ssize_t ndim):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t dim
 *     if axis is None:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core._get_axis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_raxis);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_37_get_axis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_36_get_axis[] = "_get_axis(axis, Py_ssize_t ndim) -> tuple";
static PyObject *__pyx_pw_4cupy_4core_4core_37_get_axis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  Py_ssize_t __pyx_v_ndim;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_axis (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_ndim,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ndim)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_axis", 1, 2, 2, 1); __PYX_ERR(5, 109, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_axis") < 0)) __PYX_ERR(5, 109, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_axis = values[0];
    __pyx_v_ndim = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_ndim == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 109, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_axis", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 109, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_axis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_36_get_axis(__pyx_self, __pyx_v_axis, __pyx_v_ndim);

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

static PyObject *__pyx_pf_4cupy_4core_4core_36_get_axis(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_axis, Py_ssize_t __pyx_v_ndim) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_axis", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_axis(__pyx_v_axis, __pyx_v_ndim, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 109, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/reduction.pxi":126
 * 
 * 
 * cpdef tuple _get_out_shape(             # <<<<<<<<<<<<<<
 *         tuple shape, tuple axis, tuple raxis, bint keepdims):
 *     if keepdims:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_39_get_out_shape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_out_shape(PyObject *__pyx_v_shape, PyObject *__pyx_v_axis, PyObject *__pyx_v_raxis, int __pyx_v_keepdims, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_out_shape = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("_get_out_shape", 0);

  /* "cupy/core/reduction.pxi":128
 * cpdef tuple _get_out_shape(
 *         tuple shape, tuple axis, tuple raxis, bint keepdims):
 *     if keepdims:             # <<<<<<<<<<<<<<
 *         out_shape = list(shape)
 *         for i in axis:
 */
  __pyx_t_1 = (__pyx_v_keepdims != 0);
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":129
 *         tuple shape, tuple axis, tuple raxis, bint keepdims):
 *     if keepdims:
 *         out_shape = list(shape)             # <<<<<<<<<<<<<<
 *         for i in axis:
 *             out_shape[i] = 1
 */
    __pyx_t_2 = PySequence_List(__pyx_v_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 129, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_out_shape = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":130
 *     if keepdims:
 *         out_shape = list(shape)
 *         for i in axis:             # <<<<<<<<<<<<<<
 *             out_shape[i] = 1
 *         return tuple(out_shape)
 */
    if (unlikely(__pyx_v_axis == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(5, 130, __pyx_L1_error)
    }
    __pyx_t_2 = __pyx_v_axis; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    for (;;) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(5, 130, __pyx_L1_error)
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 130, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/reduction.pxi":131
 *         out_shape = list(shape)
 *         for i in axis:
 *             out_shape[i] = 1             # <<<<<<<<<<<<<<
 *         return tuple(out_shape)
 *     return tuple([shape[i] for i in raxis])
 */
      if (unlikely(PyObject_SetItem(__pyx_v_out_shape, __pyx_v_i, __pyx_int_1) < 0)) __PYX_ERR(5, 131, __pyx_L1_error)

      /* "cupy/core/reduction.pxi":130
 *     if keepdims:
 *         out_shape = list(shape)
 *         for i in axis:             # <<<<<<<<<<<<<<
 *             out_shape[i] = 1
 *         return tuple(out_shape)
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":132
 *         for i in axis:
 *             out_shape[i] = 1
 *         return tuple(out_shape)             # <<<<<<<<<<<<<<
 *     return tuple([shape[i] for i in raxis])
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyList_AsTuple(__pyx_v_out_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 132, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/reduction.pxi":128
 * cpdef tuple _get_out_shape(
 *         tuple shape, tuple axis, tuple raxis, bint keepdims):
 *     if keepdims:             # <<<<<<<<<<<<<<
 *         out_shape = list(shape)
 *         for i in axis:
 */
  }

  /* "cupy/core/reduction.pxi":133
 *             out_shape[i] = 1
 *         return tuple(out_shape)
 *     return tuple([shape[i] for i in raxis])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(__pyx_v_raxis == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(5, 133, __pyx_L1_error)
  }
  __pyx_t_4 = __pyx_v_raxis; __Pyx_INCREF(__pyx_t_4); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(5, 133, __pyx_L1_error)
    #else
    __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_5);
    __pyx_t_5 = 0;
    if (unlikely(__pyx_v_shape == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(5, 133, __pyx_L1_error)
    }
    __pyx_t_5 = PyObject_GetItem(__pyx_v_shape, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) __PYX_ERR(5, 133, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":126
 * 
 * 
 * cpdef tuple _get_out_shape(             # <<<<<<<<<<<<<<
 *         tuple shape, tuple axis, tuple raxis, bint keepdims):
 *     if keepdims:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core._get_out_shape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_39_get_out_shape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_38_get_out_shape[] = "_get_out_shape(tuple shape, tuple axis, tuple raxis, bool keepdims) -> tuple";
static PyObject *__pyx_pw_4cupy_4core_4core_39_get_out_shape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_raxis = 0;
  int __pyx_v_keepdims;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_out_shape (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_axis,&__pyx_n_s_raxis,&__pyx_n_s_keepdims,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_out_shape", 1, 4, 4, 1); __PYX_ERR(5, 126, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_raxis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_out_shape", 1, 4, 4, 2); __PYX_ERR(5, 126, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_keepdims)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_out_shape", 1, 4, 4, 3); __PYX_ERR(5, 126, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_out_shape") < 0)) __PYX_ERR(5, 126, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_shape = ((PyObject*)values[0]);
    __pyx_v_axis = ((PyObject*)values[1]);
    __pyx_v_raxis = ((PyObject*)values[2]);
    __pyx_v_keepdims = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_keepdims == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 127, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_out_shape", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 126, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_out_shape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(5, 127, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_axis), (&PyTuple_Type), 1, "axis", 1))) __PYX_ERR(5, 127, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_raxis), (&PyTuple_Type), 1, "raxis", 1))) __PYX_ERR(5, 127, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_38_get_out_shape(__pyx_self, __pyx_v_shape, __pyx_v_axis, __pyx_v_raxis, __pyx_v_keepdims);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_38_get_out_shape(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_shape, PyObject *__pyx_v_axis, PyObject *__pyx_v_raxis, int __pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_out_shape", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_out_shape(__pyx_v_shape, __pyx_v_axis, __pyx_v_raxis, __pyx_v_keepdims, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/reduction.pxi":136
 * 
 * 
 * cpdef tuple _get_trans_args(list args, tuple trans, tuple shape, tuple params):             # <<<<<<<<<<<<<<
 *     cdef ParameterInfo p
 *     if trans == tuple(range(len(shape))):
 */

static PyObject *__pyx_pw_4cupy_4core_4core_41_get_trans_args(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_trans_args(PyObject *__pyx_v_args, PyObject *__pyx_v_trans, PyObject *__pyx_v_shape, PyObject *__pyx_v_params, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_p = 0;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("_get_trans_args", 0);
  __Pyx_INCREF(__pyx_v_args);
  __Pyx_INCREF(__pyx_v_shape);

  /* "cupy/core/reduction.pxi":138
 * cpdef tuple _get_trans_args(list args, tuple trans, tuple shape, tuple params):
 *     cdef ParameterInfo p
 *     if trans == tuple(range(len(shape))):             # <<<<<<<<<<<<<<
 *         return args, shape
 *     if params is not None:
 */
  if (unlikely(__pyx_v_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(5, 138, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(5, 138, __pyx_L1_error)
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 138, __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_PyObject_Call(__pyx_builtin_range, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PySequence_Tuple(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_trans, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 138, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(5, 138, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "cupy/core/reduction.pxi":139
 *     cdef ParameterInfo p
 *     if trans == tuple(range(len(shape))):
 *         return args, shape             # <<<<<<<<<<<<<<
 *     if params is not None:
 *         for p in params:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 139, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_args);
    __Pyx_GIVEREF(__pyx_v_args);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_args);
    __Pyx_INCREF(__pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_shape);
    __pyx_r = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/reduction.pxi":138
 * cpdef tuple _get_trans_args(list args, tuple trans, tuple shape, tuple params):
 *     cdef ParameterInfo p
 *     if trans == tuple(range(len(shape))):             # <<<<<<<<<<<<<<
 *         return args, shape
 *     if params is not None:
 */
  }

  /* "cupy/core/reduction.pxi":140
 *     if trans == tuple(range(len(shape))):
 *         return args, shape
 *     if params is not None:             # <<<<<<<<<<<<<<
 *         for p in params:
 *             if p.raw:
 */
  __pyx_t_4 = (__pyx_v_params != ((PyObject*)Py_None));
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "cupy/core/reduction.pxi":141
 *         return args, shape
 *     if params is not None:
 *         for p in params:             # <<<<<<<<<<<<<<
 *             if p.raw:
 *                 raise NotImplementedError('Illegal conditions')
 */
    if (unlikely(__pyx_v_params == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(5, 141, __pyx_L1_error)
    }
    __pyx_t_2 = __pyx_v_params; __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = 0;
    for (;;) {
      if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(5, 141, __pyx_L1_error)
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ParameterInfo))))) __PYX_ERR(5, 141, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_p, ((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_t_3));
      __pyx_t_3 = 0;

      /* "cupy/core/reduction.pxi":142
 *     if params is not None:
 *         for p in params:
 *             if p.raw:             # <<<<<<<<<<<<<<
 *                 raise NotImplementedError('Illegal conditions')
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a
 */
      __pyx_t_5 = (__pyx_v_p->raw != 0);
      if (__pyx_t_5) {

        /* "cupy/core/reduction.pxi":143
 *         for p in params:
 *             if p.raw:
 *                 raise NotImplementedError('Illegal conditions')             # <<<<<<<<<<<<<<
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a
 *             for a in args]
 */
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__94, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 143, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __PYX_ERR(5, 143, __pyx_L1_error)

        /* "cupy/core/reduction.pxi":142
 *     if params is not None:
 *         for p in params:
 *             if p.raw:             # <<<<<<<<<<<<<<
 *                 raise NotImplementedError('Illegal conditions')
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a
 */
      }

      /* "cupy/core/reduction.pxi":141
 *         return args, shape
 *     if params is not None:
 *         for p in params:             # <<<<<<<<<<<<<<
 *             if p.raw:
 *                 raise NotImplementedError('Illegal conditions')
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":140
 *     if trans == tuple(range(len(shape))):
 *         return args, shape
 *     if params is not None:             # <<<<<<<<<<<<<<
 *         for p in params:
 *             if p.raw:
 */
  }

  /* "cupy/core/reduction.pxi":144
 *             if p.raw:
 *                 raise NotImplementedError('Illegal conditions')
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a             # <<<<<<<<<<<<<<
 *             for a in args]
 *     shape = tuple([shape[i] for i in trans])
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/reduction.pxi":145
 *                 raise NotImplementedError('Illegal conditions')
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a
 *             for a in args]             # <<<<<<<<<<<<<<
 *     shape = tuple([shape[i] for i in trans])
 *     return args, shape
 */
  if (unlikely(__pyx_v_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(5, 145, __pyx_L1_error)
  }
  __pyx_t_3 = __pyx_v_args; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_6); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(5, 145, __pyx_L1_error)
    #else
    __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 145, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/reduction.pxi":144
 *             if p.raw:
 *                 raise NotImplementedError('Illegal conditions')
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a             # <<<<<<<<<<<<<<
 *             for a in args]
 *     shape = tuple([shape[i] for i in trans])
 */
    __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
    if ((__pyx_t_5 != 0)) {
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_transpose_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 144, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (!__pyx_t_9) {
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_trans); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 144, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_trans};
          __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 144, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_trans};
          __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 144, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else
        #endif
        {
          __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(5, 144, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
          __Pyx_INCREF(__pyx_v_trans);
          __Pyx_GIVEREF(__pyx_v_trans);
          PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_trans);
          __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 144, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_6 = __pyx_t_7;
      __pyx_t_7 = 0;
    } else {

      /* "cupy/core/reduction.pxi":145
 *                 raise NotImplementedError('Illegal conditions')
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a
 *             for a in args]             # <<<<<<<<<<<<<<
 *     shape = tuple([shape[i] for i in trans])
 *     return args, shape
 */
      __Pyx_INCREF(__pyx_v_a);
      __pyx_t_6 = __pyx_v_a;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(5, 144, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_args, ((PyObject*)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":146
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a
 *             for a in args]
 *     shape = tuple([shape[i] for i in trans])             # <<<<<<<<<<<<<<
 *     return args, shape
 * 
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(__pyx_v_trans == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(5, 146, __pyx_L1_error)
  }
  __pyx_t_3 = __pyx_v_trans; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_6); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(5, 146, __pyx_L1_error)
    #else
    __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_6);
    __pyx_t_6 = 0;
    if (unlikely(__pyx_v_shape == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(5, 146, __pyx_L1_error)
    }
    __pyx_t_6 = PyObject_GetItem(__pyx_v_shape, __pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(5, 146, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_shape, ((PyObject*)__pyx_t_3));
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":147
 *             for a in args]
 *     shape = tuple([shape[i] for i in trans])
 *     return args, shape             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_args);
  __Pyx_GIVEREF(__pyx_v_args);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_args);
  __Pyx_INCREF(__pyx_v_shape);
  __Pyx_GIVEREF(__pyx_v_shape);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_shape);
  __pyx_r = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":136
 * 
 * 
 * cpdef tuple _get_trans_args(list args, tuple trans, tuple shape, tuple params):             # <<<<<<<<<<<<<<
 *     cdef ParameterInfo p
 *     if trans == tuple(range(len(shape))):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cupy.core.core._get_trans_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_41_get_trans_args(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_40_get_trans_args[] = "_get_trans_args(list args, tuple trans, tuple shape, tuple params) -> tuple";
static PyObject *__pyx_pw_4cupy_4core_4core_41_get_trans_args(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_trans = 0;
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_trans_args (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_args,&__pyx_n_s_trans,&__pyx_n_s_shape,&__pyx_n_s_params,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_trans)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_trans_args", 1, 4, 4, 1); __PYX_ERR(5, 136, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_trans_args", 1, 4, 4, 2); __PYX_ERR(5, 136, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_trans_args", 1, 4, 4, 3); __PYX_ERR(5, 136, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_trans_args") < 0)) __PYX_ERR(5, 136, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_args = ((PyObject*)values[0]);
    __pyx_v_trans = ((PyObject*)values[1]);
    __pyx_v_shape = ((PyObject*)values[2]);
    __pyx_v_params = ((PyObject*)values[3]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_trans_args", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 136, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_trans_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args), (&PyList_Type), 1, "args", 1))) __PYX_ERR(5, 136, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_trans), (&PyTuple_Type), 1, "trans", 1))) __PYX_ERR(5, 136, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(5, 136, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_params), (&PyTuple_Type), 1, "params", 1))) __PYX_ERR(5, 136, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_40_get_trans_args(__pyx_self, __pyx_v_args, __pyx_v_trans, __pyx_v_shape, __pyx_v_params);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_40_get_trans_args(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args, PyObject *__pyx_v_trans, PyObject *__pyx_v_shape, PyObject *__pyx_v_params) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_trans_args", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_trans_args(__pyx_v_args, __pyx_v_trans, __pyx_v_shape, __pyx_v_params, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 136, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/reduction.pxi":150
 * 
 * 
 * cpdef list _get_inout_args(             # <<<<<<<<<<<<<<
 *         list in_args, list out_args, Indexer in_indexer, Indexer out_indexer,
 *         object out_clp2_size, tuple params, bint reduce_dims):
 */

static PyObject *__pyx_pw_4cupy_4core_4core_43_get_inout_args(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_inout_args(PyObject *__pyx_v_in_args, PyObject *__pyx_v_out_args, struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_in_indexer, struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_out_indexer, PyObject *__pyx_v_out_clp2_size, PyObject *__pyx_v_params, int __pyx_v_reduce_dims, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_in_shape = NULL;
  PyObject *__pyx_v_out_shape = NULL;
  PyObject *__pyx_v_args = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("_get_inout_args", 0);
  __Pyx_INCREF(__pyx_v_in_args);
  __Pyx_INCREF(__pyx_v_out_args);

  /* "cupy/core/reduction.pxi":153
 *         list in_args, list out_args, Indexer in_indexer, Indexer out_indexer,
 *         object out_clp2_size, tuple params, bint reduce_dims):
 *     if reduce_dims:             # <<<<<<<<<<<<<<
 *         in_args, in_shape = _reduce_dims(
 *             in_args, params, in_indexer.shape)
 */
  __pyx_t_1 = (__pyx_v_reduce_dims != 0);
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":155
 *     if reduce_dims:
 *         in_args, in_shape = _reduce_dims(
 *             in_args, params, in_indexer.shape)             # <<<<<<<<<<<<<<
 *         out_args, out_shape = _reduce_dims(
 *             out_args, params[len(in_args):], out_indexer.shape)
 */
    __pyx_t_2 = __pyx_v_in_indexer->shape;
    __Pyx_INCREF(__pyx_t_2);

    /* "cupy/core/reduction.pxi":154
 *         object out_clp2_size, tuple params, bint reduce_dims):
 *     if reduce_dims:
 *         in_args, in_shape = _reduce_dims(             # <<<<<<<<<<<<<<
 *             in_args, params, in_indexer.shape)
 *         out_args, out_shape = _reduce_dims(
 */
    __pyx_t_3 = __pyx_f_4cupy_4core_4core__reduce_dims(__pyx_v_in_args, __pyx_v_params, ((PyObject*)__pyx_t_2), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (likely(__pyx_t_3 != Py_None)) {
      PyObject* sequence = __pyx_t_3;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(5, 154, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 154, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 154, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(5, 154, __pyx_L1_error)
    }
    if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(5, 154, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_in_args, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_v_in_shape = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":157
 *             in_args, params, in_indexer.shape)
 *         out_args, out_shape = _reduce_dims(
 *             out_args, params[len(in_args):], out_indexer.shape)             # <<<<<<<<<<<<<<
 *         in_indexer.shape = in_shape
 *         out_indexer.shape = out_shape
 */
    if (unlikely(__pyx_v_params == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(5, 157, __pyx_L1_error)
    }
    if (unlikely(__pyx_v_in_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(5, 157, __pyx_L1_error)
    }
    __pyx_t_5 = PyList_GET_SIZE(__pyx_v_in_args); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(5, 157, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyTuple_GetSlice(__pyx_v_params, __pyx_t_5, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __pyx_v_out_indexer->shape;
    __Pyx_INCREF(__pyx_t_4);

    /* "cupy/core/reduction.pxi":156
 *         in_args, in_shape = _reduce_dims(
 *             in_args, params, in_indexer.shape)
 *         out_args, out_shape = _reduce_dims(             # <<<<<<<<<<<<<<
 *             out_args, params[len(in_args):], out_indexer.shape)
 *         in_indexer.shape = in_shape
 */
    __pyx_t_2 = __pyx_f_4cupy_4core_4core__reduce_dims(__pyx_v_out_args, ((PyObject*)__pyx_t_3), ((PyObject*)__pyx_t_4), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (likely(__pyx_t_2 != Py_None)) {
      PyObject* sequence = __pyx_t_2;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(5, 156, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      #else
      __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 156, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 156, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(5, 156, __pyx_L1_error)
    }
    if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(5, 156, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_out_args, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;
    __pyx_v_out_shape = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/reduction.pxi":158
 *         out_args, out_shape = _reduce_dims(
 *             out_args, params[len(in_args):], out_indexer.shape)
 *         in_indexer.shape = in_shape             # <<<<<<<<<<<<<<
 *         out_indexer.shape = out_shape
 *     args = in_args + out_args + [in_indexer, out_indexer,
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v_in_shape))||((__pyx_v_in_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_in_shape)->tp_name), 0))) __PYX_ERR(5, 158, __pyx_L1_error)
    __pyx_t_2 = __pyx_v_in_shape;
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_in_indexer->shape);
    __Pyx_DECREF(__pyx_v_in_indexer->shape);
    __pyx_v_in_indexer->shape = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":159
 *             out_args, params[len(in_args):], out_indexer.shape)
 *         in_indexer.shape = in_shape
 *         out_indexer.shape = out_shape             # <<<<<<<<<<<<<<
 *     args = in_args + out_args + [in_indexer, out_indexer,
 *                                  numpy.int32(out_clp2_size)]
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v_out_shape))||((__pyx_v_out_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_out_shape)->tp_name), 0))) __PYX_ERR(5, 159, __pyx_L1_error)
    __pyx_t_2 = __pyx_v_out_shape;
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_out_indexer->shape);
    __Pyx_DECREF(__pyx_v_out_indexer->shape);
    __pyx_v_out_indexer->shape = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":153
 *         list in_args, list out_args, Indexer in_indexer, Indexer out_indexer,
 *         object out_clp2_size, tuple params, bint reduce_dims):
 *     if reduce_dims:             # <<<<<<<<<<<<<<
 *         in_args, in_shape = _reduce_dims(
 *             in_args, params, in_indexer.shape)
 */
  }

  /* "cupy/core/reduction.pxi":160
 *         in_indexer.shape = in_shape
 *         out_indexer.shape = out_shape
 *     args = in_args + out_args + [in_indexer, out_indexer,             # <<<<<<<<<<<<<<
 *                                  numpy.int32(out_clp2_size)]
 *     return args
 */
  __pyx_t_2 = PyNumber_Add(__pyx_v_in_args, __pyx_v_out_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/reduction.pxi":161
 *         out_indexer.shape = out_shape
 *     args = in_args + out_args + [in_indexer, out_indexer,
 *                                  numpy.int32(out_clp2_size)]             # <<<<<<<<<<<<<<
 *     return args
 * 
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_out_clp2_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 161, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_out_clp2_size};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 161, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_out_clp2_size};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 161, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 161, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(__pyx_v_out_clp2_size);
      __Pyx_GIVEREF(__pyx_v_out_clp2_size);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_out_clp2_size);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 161, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/reduction.pxi":160
 *         in_indexer.shape = in_shape
 *         out_indexer.shape = out_shape
 *     args = in_args + out_args + [in_indexer, out_indexer,             # <<<<<<<<<<<<<<
 *                                  numpy.int32(out_clp2_size)]
 *     return args
 */
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_v_in_indexer));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_in_indexer));
  PyList_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_in_indexer));
  __Pyx_INCREF(((PyObject *)__pyx_v_out_indexer));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_out_indexer));
  PyList_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_out_indexer));
  __Pyx_GIVEREF(__pyx_t_3);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_args = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":162
 *     args = in_args + out_args + [in_indexer, out_indexer,
 *                                  numpy.int32(out_clp2_size)]
 *     return args             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_args);
  __pyx_r = __pyx_v_args;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":150
 * 
 * 
 * cpdef list _get_inout_args(             # <<<<<<<<<<<<<<
 *         list in_args, list out_args, Indexer in_indexer, Indexer out_indexer,
 *         object out_clp2_size, tuple params, bint reduce_dims):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core._get_inout_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_in_shape);
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_in_args);
  __Pyx_XDECREF(__pyx_v_out_args);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_43_get_inout_args(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_42_get_inout_args[] = "_get_inout_args(list in_args, list out_args, Indexer in_indexer, Indexer out_indexer, out_clp2_size, tuple params, bool reduce_dims) -> list";
static PyObject *__pyx_pw_4cupy_4core_4core_43_get_inout_args(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_in_args = 0;
  PyObject *__pyx_v_out_args = 0;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_in_indexer = 0;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_out_indexer = 0;
  PyObject *__pyx_v_out_clp2_size = 0;
  PyObject *__pyx_v_params = 0;
  int __pyx_v_reduce_dims;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_inout_args (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_in_args,&__pyx_n_s_out_args,&__pyx_n_s_in_indexer,&__pyx_n_s_out_indexer,&__pyx_n_s_out_clp2_size,&__pyx_n_s_params,&__pyx_n_s_reduce_dims,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_in_args)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out_args)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_inout_args", 1, 7, 7, 1); __PYX_ERR(5, 150, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_in_indexer)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_inout_args", 1, 7, 7, 2); __PYX_ERR(5, 150, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out_indexer)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_inout_args", 1, 7, 7, 3); __PYX_ERR(5, 150, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out_clp2_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_inout_args", 1, 7, 7, 4); __PYX_ERR(5, 150, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_inout_args", 1, 7, 7, 5); __PYX_ERR(5, 150, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_reduce_dims)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_inout_args", 1, 7, 7, 6); __PYX_ERR(5, 150, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_inout_args") < 0)) __PYX_ERR(5, 150, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
    }
    __pyx_v_in_args = ((PyObject*)values[0]);
    __pyx_v_out_args = ((PyObject*)values[1]);
    __pyx_v_in_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)values[2]);
    __pyx_v_out_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)values[3]);
    __pyx_v_out_clp2_size = values[4];
    __pyx_v_params = ((PyObject*)values[5]);
    __pyx_v_reduce_dims = __Pyx_PyObject_IsTrue(values[6]); if (unlikely((__pyx_v_reduce_dims == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 152, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_inout_args", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 150, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_inout_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_in_args), (&PyList_Type), 1, "in_args", 1))) __PYX_ERR(5, 151, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out_args), (&PyList_Type), 1, "out_args", 1))) __PYX_ERR(5, 151, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_in_indexer), __pyx_ptype_4cupy_4core_4core_Indexer, 1, "in_indexer", 0))) __PYX_ERR(5, 151, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out_indexer), __pyx_ptype_4cupy_4core_4core_Indexer, 1, "out_indexer", 0))) __PYX_ERR(5, 151, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_params), (&PyTuple_Type), 1, "params", 1))) __PYX_ERR(5, 152, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_42_get_inout_args(__pyx_self, __pyx_v_in_args, __pyx_v_out_args, __pyx_v_in_indexer, __pyx_v_out_indexer, __pyx_v_out_clp2_size, __pyx_v_params, __pyx_v_reduce_dims);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_42_get_inout_args(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_in_args, PyObject *__pyx_v_out_args, struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_in_indexer, struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_out_indexer, PyObject *__pyx_v_out_clp2_size, PyObject *__pyx_v_params, int __pyx_v_reduce_dims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_inout_args", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_inout_args(__pyx_v_in_args, __pyx_v_out_args, __pyx_v_in_indexer, __pyx_v_out_indexer, __pyx_v_out_clp2_size, __pyx_v_params, __pyx_v_reduce_dims, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/reduction.pxi":166
 * 
 * @util.memoize(for_each_device=True)
 * def _get_simple_reduction_function(             # <<<<<<<<<<<<<<
 *         routine, params, args_info, in_arg_dtype, out_arg_dtype, out_types,
 *         name, block_size, identity, input_expr, output_expr, _preamble,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_45_get_simple_reduction_function(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_44_get_simple_reduction_function[] = "_get_simple_reduction_function(routine, params, args_info, in_arg_dtype, out_arg_dtype, out_types, name, block_size, identity, input_expr, output_expr, _preamble, options)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_45_get_simple_reduction_function = {"_get_simple_reduction_function", (PyCFunction)__pyx_pw_4cupy_4core_4core_45_get_simple_reduction_function, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_44_get_simple_reduction_function};
static PyObject *__pyx_pw_4cupy_4core_4core_45_get_simple_reduction_function(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_routine = 0;
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_args_info = 0;
  PyObject *__pyx_v_in_arg_dtype = 0;
  PyObject *__pyx_v_out_arg_dtype = 0;
  PyObject *__pyx_v_out_types = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_block_size = 0;
  PyObject *__pyx_v_identity = 0;
  PyObject *__pyx_v_input_expr = 0;
  PyObject *__pyx_v_output_expr = 0;
  PyObject *__pyx_v__preamble = 0;
  PyObject *__pyx_v_options = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_simple_reduction_function (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_routine,&__pyx_n_s_params,&__pyx_n_s_args_info,&__pyx_n_s_in_arg_dtype,&__pyx_n_s_out_arg_dtype,&__pyx_n_s_out_types,&__pyx_n_s_name,&__pyx_n_s_block_size,&__pyx_n_s_identity,&__pyx_n_s_input_expr,&__pyx_n_s_output_expr,&__pyx_n_s_preamble_2,&__pyx_n_s_options,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        CYTHON_FALLTHROUGH;
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_routine)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 1); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_args_info)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 2); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_in_arg_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 3); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out_arg_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 4); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out_types)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 5); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 6); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_block_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 7); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_identity)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 8); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_input_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 9); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_output_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 10); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (likely((values[11] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_preamble_2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 11); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 12:
        if (likely((values[12] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_options)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 12); __PYX_ERR(5, 166, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_simple_reduction_function") < 0)) __PYX_ERR(5, 166, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 13) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
      values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
      values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
      values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
    }
    __pyx_v_routine = values[0];
    __pyx_v_params = values[1];
    __pyx_v_args_info = values[2];
    __pyx_v_in_arg_dtype = values[3];
    __pyx_v_out_arg_dtype = values[4];
    __pyx_v_out_types = values[5];
    __pyx_v_name = values[6];
    __pyx_v_block_size = values[7];
    __pyx_v_identity = values[8];
    __pyx_v_input_expr = values[9];
    __pyx_v_output_expr = values[10];
    __pyx_v__preamble = values[11];
    __pyx_v_options = values[12];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 166, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_simple_reduction_function", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_44_get_simple_reduction_function(__pyx_self, __pyx_v_routine, __pyx_v_params, __pyx_v_args_info, __pyx_v_in_arg_dtype, __pyx_v_out_arg_dtype, __pyx_v_out_types, __pyx_v_name, __pyx_v_block_size, __pyx_v_identity, __pyx_v_input_expr, __pyx_v_output_expr, __pyx_v__preamble, __pyx_v_options);

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

static PyObject *__pyx_pf_4cupy_4core_4core_44_get_simple_reduction_function(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_routine, PyObject *__pyx_v_params, PyObject *__pyx_v_args_info, PyObject *__pyx_v_in_arg_dtype, PyObject *__pyx_v_out_arg_dtype, PyObject *__pyx_v_out_types, PyObject *__pyx_v_name, PyObject *__pyx_v_block_size, PyObject *__pyx_v_identity, PyObject *__pyx_v_input_expr, PyObject *__pyx_v_output_expr, PyObject *__pyx_v__preamble, PyObject *__pyx_v_options) {
  PyObject *__pyx_v_reduce_type = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_type_preamble = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("_get_simple_reduction_function", 0);
  __Pyx_INCREF(__pyx_v_params);

  /* "cupy/core/reduction.pxi":170
 *         name, block_size, identity, input_expr, output_expr, _preamble,
 *         options):
 *     reduce_type = routine[3]             # <<<<<<<<<<<<<<
 *     if reduce_type is None:
 *         reduce_type = _get_typename(out_types[0])
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_routine, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_reduce_type = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":171
 *         options):
 *     reduce_type = routine[3]
 *     if reduce_type is None:             # <<<<<<<<<<<<<<
 *         reduce_type = _get_typename(out_types[0])
 * 
 */
  __pyx_t_2 = (__pyx_v_reduce_type == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/reduction.pxi":172
 *     reduce_type = routine[3]
 *     if reduce_type is None:
 *         reduce_type = _get_typename(out_types[0])             # <<<<<<<<<<<<<<
 * 
 *     t = (_get_typename(in_arg_dtype), _get_typename(out_arg_dtype))
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_out_types, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_t_1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_reduce_type, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":171
 *         options):
 *     reduce_type = routine[3]
 *     if reduce_type is None:             # <<<<<<<<<<<<<<
 *         reduce_type = _get_typename(out_types[0])
 * 
 */
  }

  /* "cupy/core/reduction.pxi":174
 *         reduce_type = _get_typename(out_types[0])
 * 
 *     t = (_get_typename(in_arg_dtype), _get_typename(out_arg_dtype))             # <<<<<<<<<<<<<<
 *     type_preamble = 'typedef %s type_in0_raw; typedef %s type_out0_raw;' % t
 * 
 */
  __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_in_arg_dtype, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_out_arg_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
  __pyx_t_4 = 0;
  __pyx_t_1 = 0;
  __pyx_v_t = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":175
 * 
 *     t = (_get_typename(in_arg_dtype), _get_typename(out_arg_dtype))
 *     type_preamble = 'typedef %s type_in0_raw; typedef %s type_out0_raw;' % t             # <<<<<<<<<<<<<<
 * 
 *     params = _get_kernel_params(params, args_info)
 */
  __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_typedef_s_type_in0_raw_typedef_s, __pyx_v_t); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_type_preamble = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":177
 *     type_preamble = 'typedef %s type_in0_raw; typedef %s type_out0_raw;' % t
 * 
 *     params = _get_kernel_params(params, args_info)             # <<<<<<<<<<<<<<
 *     return _get_simple_reduction_kernel(
 *         name, block_size, reduce_type, params, identity,
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_params))||((__pyx_v_params) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_params)->tp_name), 0))) __PYX_ERR(5, 177, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_args_info))||((__pyx_v_args_info) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args_info)->tp_name), 0))) __PYX_ERR(5, 177, __pyx_L1_error)
  __pyx_t_5 = __pyx_f_4cupy_4core_4core__get_kernel_params(((PyObject*)__pyx_v_params), ((PyObject*)__pyx_v_args_info), 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF_SET(__pyx_v_params, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":178
 * 
 *     params = _get_kernel_params(params, args_info)
 *     return _get_simple_reduction_kernel(             # <<<<<<<<<<<<<<
 *         name, block_size, reduce_type, params, identity,
 *         routine[0], routine[1], routine[2],
 */
  __Pyx_XDECREF(__pyx_r);

  /* "cupy/core/reduction.pxi":180
 *     return _get_simple_reduction_kernel(
 *         name, block_size, reduce_type, params, identity,
 *         routine[0], routine[1], routine[2],             # <<<<<<<<<<<<<<
 *         type_preamble, input_expr, output_expr, _preamble, options)
 * 
 */
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_routine, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_routine, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_routine, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/reduction.pxi":178
 * 
 *     params = _get_kernel_params(params, args_info)
 *     return _get_simple_reduction_kernel(             # <<<<<<<<<<<<<<
 *         name, block_size, reduce_type, params, identity,
 *         routine[0], routine[1], routine[2],
 */
  __pyx_t_6 = __pyx_f_4cupy_4core_4core__get_simple_reduction_kernel(__pyx_v_name, __pyx_v_block_size, __pyx_v_reduce_type, __pyx_v_params, __pyx_v_identity, __pyx_t_5, __pyx_t_1, __pyx_t_4, __pyx_v_type_preamble, __pyx_v_input_expr, __pyx_v_output_expr, __pyx_v__preamble, __pyx_v_options, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":166
 * 
 * @util.memoize(for_each_device=True)
 * def _get_simple_reduction_function(             # <<<<<<<<<<<<<<
 *         routine, params, args_info, in_arg_dtype, out_arg_dtype, out_types,
 *         name, block_size, identity, input_expr, output_expr, _preamble,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core._get_simple_reduction_function", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_reduce_type);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_type_preamble);
  __Pyx_XDECREF(__pyx_v_params);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":188
 *     _block_size = 512
 * 
 *     def __init__(self, name, ops, identity, preamble):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self._ops = ops
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_25simple_reduction_function_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_25simple_reduction_function___init__[] = "simple_reduction_function.__init__(self, name, ops, identity, preamble)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_25simple_reduction_function_1__init__ = {"__init__", (PyCFunction)__pyx_pw_4cupy_4core_4core_25simple_reduction_function_1__init__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_25simple_reduction_function___init__};
static PyObject *__pyx_pw_4cupy_4core_4core_25simple_reduction_function_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_ops = 0;
  PyObject *__pyx_v_identity = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_name,&__pyx_n_s_ops,&__pyx_n_s_identity,&__pyx_n_s_preamble,0};
    PyObject* values[5] = {0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); __PYX_ERR(5, 188, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ops)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); __PYX_ERR(5, 188, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_identity)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); __PYX_ERR(5, 188, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_preamble)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); __PYX_ERR(5, 188, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(5, 188, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
    }
    __pyx_v_self = values[0];
    __pyx_v_name = values[1];
    __pyx_v_ops = values[2];
    __pyx_v_identity = values[3];
    __pyx_v_preamble = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 188, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.simple_reduction_function.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_25simple_reduction_function___init__(__pyx_self, __pyx_v_self, __pyx_v_name, __pyx_v_ops, __pyx_v_identity, __pyx_v_preamble);

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

static PyObject *__pyx_pf_4cupy_4core_4core_25simple_reduction_function___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_ops, PyObject *__pyx_v_identity, PyObject *__pyx_v_preamble) {
  PyObject *__pyx_v_in_params = NULL;
  PyObject *__pyx_v_out_params = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/reduction.pxi":189
 * 
 *     def __init__(self, name, ops, identity, preamble):
 *         self.name = name             # <<<<<<<<<<<<<<
 *         self._ops = ops
 *         self.identity = identity
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(5, 189, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":190
 *     def __init__(self, name, ops, identity, preamble):
 *         self.name = name
 *         self._ops = ops             # <<<<<<<<<<<<<<
 *         self.identity = identity
 *         self._preamble = preamble
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_ops_2, __pyx_v_ops) < 0) __PYX_ERR(5, 190, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":191
 *         self.name = name
 *         self._ops = ops
 *         self.identity = identity             # <<<<<<<<<<<<<<
 *         self._preamble = preamble
 *         self.nin = 1
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_identity, __pyx_v_identity) < 0) __PYX_ERR(5, 191, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":192
 *         self._ops = ops
 *         self.identity = identity
 *         self._preamble = preamble             # <<<<<<<<<<<<<<
 *         self.nin = 1
 *         self.nout = 1
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_preamble_2, __pyx_v_preamble) < 0) __PYX_ERR(5, 192, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":193
 *         self.identity = identity
 *         self._preamble = preamble
 *         self.nin = 1             # <<<<<<<<<<<<<<
 *         self.nout = 1
 *         in_params = _get_param_info('T in0', True)
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nin, __pyx_int_1) < 0) __PYX_ERR(5, 193, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":194
 *         self._preamble = preamble
 *         self.nin = 1
 *         self.nout = 1             # <<<<<<<<<<<<<<
 *         in_params = _get_param_info('T in0', True)
 *         out_params = _get_param_info('T out0', False)
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nout, __pyx_int_1) < 0) __PYX_ERR(5, 194, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":195
 *         self.nin = 1
 *         self.nout = 1
 *         in_params = _get_param_info('T in0', True)             # <<<<<<<<<<<<<<
 *         out_params = _get_param_info('T out0', False)
 *         self._params = (
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__95, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_in_params = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":196
 *         self.nout = 1
 *         in_params = _get_param_info('T in0', True)
 *         out_params = _get_param_info('T out0', False)             # <<<<<<<<<<<<<<
 *         self._params = (
 *             in_params + out_params +
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 196, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__96, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 196, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_out_params = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":198
 *         out_params = _get_param_info('T out0', False)
 *         self._params = (
 *             in_params + out_params +             # <<<<<<<<<<<<<<
 *             _get_param_info(
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +
 */
  __pyx_t_1 = PyNumber_Add(__pyx_v_in_params, __pyx_v_out_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/reduction.pxi":199
 *         self._params = (
 *             in_params + out_params +
 *             _get_param_info(             # <<<<<<<<<<<<<<
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/reduction.pxi":200
 *             in_params + out_params +
 *             _get_param_info(
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +             # <<<<<<<<<<<<<<
 *             _get_param_info('int32 _block_stride', True))
 *         self._input_expr = 'const type_in0_raw in0 = _raw_in0[_in_ind.get()];'
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__97, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":198
 *         out_params = _get_param_info('T out0', False)
 *         self._params = (
 *             in_params + out_params +             # <<<<<<<<<<<<<<
 *             _get_param_info(
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +
 */
  __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":201
 *             _get_param_info(
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))             # <<<<<<<<<<<<<<
 *         self._input_expr = 'const type_in0_raw in0 = _raw_in0[_in_ind.get()];'
 *         self._output_expr = 'type_out0_raw &out0 = _raw_out0[_out_ind.get()];'
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__98, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":200
 *             in_params + out_params +
 *             _get_param_info(
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +             # <<<<<<<<<<<<<<
 *             _get_param_info('int32 _block_stride', True))
 *         self._input_expr = 'const type_in0_raw in0 = _raw_in0[_in_ind.get()];'
 */
  __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":197
 *         in_params = _get_param_info('T in0', True)
 *         out_params = _get_param_info('T out0', False)
 *         self._params = (             # <<<<<<<<<<<<<<
 *             in_params + out_params +
 *             _get_param_info(
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_params_2, __pyx_t_3) < 0) __PYX_ERR(5, 197, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":202
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))
 *         self._input_expr = 'const type_in0_raw in0 = _raw_in0[_in_ind.get()];'             # <<<<<<<<<<<<<<
 *         self._output_expr = 'type_out0_raw &out0 = _raw_out0[_out_ind.get()];'
 *         self._routine_cache = {}
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_input_expr_2, __pyx_kp_s_const_type_in0_raw_in0__raw_in0) < 0) __PYX_ERR(5, 202, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":203
 *             _get_param_info('int32 _block_stride', True))
 *         self._input_expr = 'const type_in0_raw in0 = _raw_in0[_in_ind.get()];'
 *         self._output_expr = 'type_out0_raw &out0 = _raw_out0[_out_ind.get()];'             # <<<<<<<<<<<<<<
 *         self._routine_cache = {}
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_output_expr_2, __pyx_kp_s_type_out0_raw_out0__raw_out0__ou) < 0) __PYX_ERR(5, 203, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":204
 *         self._input_expr = 'const type_in0_raw in0 = _raw_in0[_in_ind.get()];'
 *         self._output_expr = 'type_out0_raw &out0 = _raw_out0[_out_ind.get()];'
 *         self._routine_cache = {}             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, ndarray a, axis=None, dtype=None, ndarray out=None,
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_routine_cache, __pyx_t_3) < 0) __PYX_ERR(5, 204, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":188
 *     _block_size = 512
 * 
 *     def __init__(self, name, ops, identity, preamble):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self._ops = ops
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core.simple_reduction_function.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_in_params);
  __Pyx_XDECREF(__pyx_v_out_params);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":206
 *         self._routine_cache = {}
 * 
 *     def __call__(self, ndarray a, axis=None, dtype=None, ndarray out=None,             # <<<<<<<<<<<<<<
 *                  bint keepdims=False):
 *         cdef list in_args, out_args
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_25simple_reduction_function_3__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_25simple_reduction_function_2__call__[] = "simple_reduction_function.__call__(self, ndarray a, axis=None, dtype=None, ndarray out=None, bool keepdims=False)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_25simple_reduction_function_3__call__ = {"__call__", (PyCFunction)__pyx_pw_4cupy_4core_4core_25simple_reduction_function_3__call__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_25simple_reduction_function_2__call__};
static PyObject *__pyx_pw_4cupy_4core_4core_25simple_reduction_function_3__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_dtype = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = 0;
  int __pyx_v_keepdims;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_a,&__pyx_n_s_axis,&__pyx_n_s_dtype,&__pyx_n_s_out,&__pyx_n_s_keepdims,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[2] = ((PyObject *)((PyObject *)Py_None));
    values[3] = ((PyObject *)((PyObject *)Py_None));
    values[4] = (PyObject *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 0, 2, 6, 1); __PYX_ERR(5, 206, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) __PYX_ERR(5, 206, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_axis = values[2];
    __pyx_v_dtype = values[3];
    __pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[4]);
    if (values[5]) {
      __pyx_v_keepdims = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_keepdims == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 207, __pyx_L3_error)
    } else {

      /* "cupy/core/reduction.pxi":207
 * 
 *     def __call__(self, ndarray a, axis=None, dtype=None, ndarray out=None,
 *                  bint keepdims=False):             # <<<<<<<<<<<<<<
 *         cdef list in_args, out_args
 *         cdef tuple in_sahpe, laxis, raxis
 */
      __pyx_v_keepdims = ((int)((int)0));
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 0, 2, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 206, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.simple_reduction_function.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(5, 206, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(5, 206, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_25simple_reduction_function_2__call__(__pyx_self, __pyx_v_self, __pyx_v_a, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims);

  /* "cupy/core/reduction.pxi":206
 *         self._routine_cache = {}
 * 
 *     def __call__(self, ndarray a, axis=None, dtype=None, ndarray out=None,             # <<<<<<<<<<<<<<
 *                  bint keepdims=False):
 *         cdef list in_args, out_args
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_25simple_reduction_function_2__call__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out, int __pyx_v_keepdims) {
  PyObject *__pyx_v_in_args = 0;
  PyObject *__pyx_v_out_args = 0;
  PyObject *__pyx_v_laxis = 0;
  PyObject *__pyx_v_raxis = 0;
  PyObject *__pyx_v_a_shape = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  PyObject *__pyx_v_routine = NULL;
  PyObject *__pyx_v_out_shape = NULL;
  PyObject *__pyx_v_in_shape = NULL;
  PyObject *__pyx_v_block_size = NULL;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_in_indexer = NULL;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_out_indexer = NULL;
  PyObject *__pyx_v_clp2_count = NULL;
  PyObject *__pyx_v_block_stride = NULL;
  PyObject *__pyx_v_inout_args = NULL;
  PyObject *__pyx_v_args_info = NULL;
  PyObject *__pyx_v_kern = NULL;
  PyObject *__pyx_v_shared_mem = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  long __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  __Pyx_RefNannySetupContext("__call__", 0);
  __Pyx_INCREF(__pyx_v_axis);
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/reduction.pxi":210
 *         cdef list in_args, out_args
 *         cdef tuple in_sahpe, laxis, raxis
 *         if dtype is not None:             # <<<<<<<<<<<<<<
 *             dtype = numpy.dtype(dtype).type
 * 
 */
  __pyx_t_1 = (__pyx_v_dtype != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/reduction.pxi":211
 *         cdef tuple in_sahpe, laxis, raxis
 *         if dtype is not None:
 *             dtype = numpy.dtype(dtype).type             # <<<<<<<<<<<<<<
 * 
 *         in_args = [a]
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 211, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 211, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 211, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_dtype};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 211, __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_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_dtype};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 211, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 211, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_dtype);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 211, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_type); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 211, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/reduction.pxi":210
 *         cdef list in_args, out_args
 *         cdef tuple in_sahpe, laxis, raxis
 *         if dtype is not None:             # <<<<<<<<<<<<<<
 *             dtype = numpy.dtype(dtype).type
 * 
 */
  }

  /* "cupy/core/reduction.pxi":213
 *             dtype = numpy.dtype(dtype).type
 * 
 *         in_args = [a]             # <<<<<<<<<<<<<<
 *         a_shape = a.shape
 *         if out is None:
 */
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(((PyObject *)__pyx_v_a));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
  PyList_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_a));
  __pyx_v_in_args = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":214
 * 
 *         in_args = [a]
 *         a_shape = a.shape             # <<<<<<<<<<<<<<
 *         if out is None:
 *             _preprocess_args((a,))
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 214, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_a_shape = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":215
 *         in_args = [a]
 *         a_shape = a.shape
 *         if out is None:             # <<<<<<<<<<<<<<
 *             _preprocess_args((a,))
 *             out_args = []
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_out) == Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":216
 *         a_shape = a.shape
 *         if out is None:
 *             _preprocess_args((a,))             # <<<<<<<<<<<<<<
 *             out_args = []
 *         else:
 */
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 216, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_a));
    __pyx_t_3 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_t_5, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 216, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/reduction.pxi":217
 *         if out is None:
 *             _preprocess_args((a,))
 *             out_args = []             # <<<<<<<<<<<<<<
 *         else:
 *             _preprocess_args((a, out))
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 217, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_out_args = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/reduction.pxi":215
 *         in_args = [a]
 *         a_shape = a.shape
 *         if out is None:             # <<<<<<<<<<<<<<
 *             _preprocess_args((a,))
 *             out_args = []
 */
    goto __pyx_L4;
  }

  /* "cupy/core/reduction.pxi":219
 *             out_args = []
 *         else:
 *             _preprocess_args((a, out))             # <<<<<<<<<<<<<<
 *             out_args = [out]
 * 
 */
  /*else*/ {
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 219, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_a));
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
    PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_out));
    __pyx_t_5 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_t_3, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 219, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/reduction.pxi":220
 *         else:
 *             _preprocess_args((a, out))
 *             out_args = [out]             # <<<<<<<<<<<<<<
 * 
 *         in_types, out_types, routine = _guess_routine(
 */
    __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 220, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
    PyList_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_out));
    __pyx_v_out_args = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;
  }
  __pyx_L4:;

  /* "cupy/core/reduction.pxi":223
 * 
 *         in_types, out_types, routine = _guess_routine(
 *             self.name, self._routine_cache, self._ops, in_args, dtype)             # <<<<<<<<<<<<<<
 * 
 *         laxis, raxis = _get_axis(axis, a._shape.size())
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (!(likely(PyString_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(5, 223, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_routine_cache); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(PyDict_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(5, 223, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ops_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (!(likely(PyList_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_6)->tp_name), 0))) __PYX_ERR(5, 223, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":222
 *             out_args = [out]
 * 
 *         in_types, out_types, routine = _guess_routine(             # <<<<<<<<<<<<<<
 *             self.name, self._routine_cache, self._ops, in_args, dtype)
 * 
 */
  __pyx_t_4 = __pyx_f_4cupy_4core_4core__guess_routine(((PyObject*)__pyx_t_5), ((PyObject*)__pyx_t_3), ((PyObject*)__pyx_t_6), __pyx_v_in_args, __pyx_v_dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (likely(__pyx_t_4 != Py_None)) {
    PyObject* sequence = __pyx_t_4;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(5, 222, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 222, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 222, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 222, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(5, 222, __pyx_L1_error)
  }
  __pyx_v_in_types = __pyx_t_6;
  __pyx_t_6 = 0;
  __pyx_v_out_types = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_routine = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":225
 *             self.name, self._routine_cache, self._ops, in_args, dtype)
 * 
 *         laxis, raxis = _get_axis(axis, a._shape.size())             # <<<<<<<<<<<<<<
 *         del axis  # to avoid bug
 *         out_shape = _get_out_shape(a_shape, laxis, raxis, keepdims)
 */
  __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_axis(__pyx_v_axis, __pyx_v_a->_shape.size(), 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 225, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (likely(__pyx_t_4 != Py_None)) {
    PyObject* sequence = __pyx_t_4;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(5, 225, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 225, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 225, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(5, 225, __pyx_L1_error)
  }
  if (!(likely(PyTuple_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(5, 225, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(5, 225, __pyx_L1_error)
  __pyx_v_laxis = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_v_raxis = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":226
 * 
 *         laxis, raxis = _get_axis(axis, a._shape.size())
 *         del axis  # to avoid bug             # <<<<<<<<<<<<<<
 *         out_shape = _get_out_shape(a_shape, laxis, raxis, keepdims)
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 */
  __Pyx_DECREF(__pyx_v_axis);
  __pyx_v_axis = NULL;

  /* "cupy/core/reduction.pxi":227
 *         laxis, raxis = _get_axis(axis, a._shape.size())
 *         del axis  # to avoid bug
 *         out_shape = _get_out_shape(a_shape, laxis, raxis, keepdims)             # <<<<<<<<<<<<<<
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 *         if out_args[0].size == 0:
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_a_shape))||((__pyx_v_a_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_a_shape)->tp_name), 0))) __PYX_ERR(5, 227, __pyx_L1_error)
  __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_out_shape(((PyObject*)__pyx_v_a_shape), __pyx_v_laxis, __pyx_v_raxis, __pyx_v_keepdims, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 227, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_out_shape = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":228
 *         del axis  # to avoid bug
 *         out_shape = _get_out_shape(a_shape, laxis, raxis, keepdims)
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')             # <<<<<<<<<<<<<<
 *         if out_args[0].size == 0:
 *             if len(out_args) == 1:
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_out_types))||((__pyx_v_out_types) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_out_types)->tp_name), 0))) __PYX_ERR(5, 228, __pyx_L1_error)
  __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_out_args(__pyx_v_out_args, ((PyObject*)__pyx_v_out_types), __pyx_v_out_shape, __pyx_n_s_unsafe); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF_SET(__pyx_v_out_args, ((PyObject*)__pyx_t_4));
  __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":229
 *         out_shape = _get_out_shape(a_shape, laxis, raxis, keepdims)
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 *         if out_args[0].size == 0:             # <<<<<<<<<<<<<<
 *             if len(out_args) == 1:
 *                 return out_args[0]
 */
  if (unlikely(__pyx_v_out_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(5, 229, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 229, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 229, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 229, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(5, 229, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":230
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 *         if out_args[0].size == 0:
 *             if len(out_args) == 1:             # <<<<<<<<<<<<<<
 *                 return out_args[0]
 *             return tuple(out_args)
 */
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(5, 230, __pyx_L1_error)
    }
    __pyx_t_7 = PyList_GET_SIZE(__pyx_v_out_args); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(5, 230, __pyx_L1_error)
    __pyx_t_1 = ((__pyx_t_7 == 1) != 0);
    if (__pyx_t_1) {

      /* "cupy/core/reduction.pxi":231
 *         if out_args[0].size == 0:
 *             if len(out_args) == 1:
 *                 return out_args[0]             # <<<<<<<<<<<<<<
 *             return tuple(out_args)
 *         if a.size == 0 and self.identity is None:
 */
      __Pyx_XDECREF(__pyx_r);
      if (unlikely(__pyx_v_out_args == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(5, 231, __pyx_L1_error)
      }
      __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 231, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L0;

      /* "cupy/core/reduction.pxi":230
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 *         if out_args[0].size == 0:
 *             if len(out_args) == 1:             # <<<<<<<<<<<<<<
 *                 return out_args[0]
 *             return tuple(out_args)
 */
    }

    /* "cupy/core/reduction.pxi":232
 *             if len(out_args) == 1:
 *                 return out_args[0]
 *             return tuple(out_args)             # <<<<<<<<<<<<<<
 *         if a.size == 0 and self.identity is None:
 *             raise ValueError(('zero-size array to reduction operation'
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(5, 232, __pyx_L1_error)
    }
    __pyx_t_4 = PyList_AsTuple(__pyx_v_out_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 232, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "cupy/core/reduction.pxi":229
 *         out_shape = _get_out_shape(a_shape, laxis, raxis, keepdims)
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 *         if out_args[0].size == 0:             # <<<<<<<<<<<<<<
 *             if len(out_args) == 1:
 *                 return out_args[0]
 */
  }

  /* "cupy/core/reduction.pxi":233
 *                 return out_args[0]
 *             return tuple(out_args)
 *         if a.size == 0 and self.identity is None:             # <<<<<<<<<<<<<<
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)
 */
  __pyx_t_2 = ((__pyx_v_a->size == 0) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_identity); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = (__pyx_t_4 == Py_None);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_8 = (__pyx_t_2 != 0);
  __pyx_t_1 = __pyx_t_8;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":235
 *         if a.size == 0 and self.identity is None:
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)             # <<<<<<<<<<<<<<
 * 
 *         in_args, in_shape = _get_trans_args(
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_zero_size_array_to_reduction_ope, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":234
 *             return tuple(out_args)
 *         if a.size == 0 and self.identity is None:
 *             raise ValueError(('zero-size array to reduction operation'             # <<<<<<<<<<<<<<
 *                               ' %s which has no identity') % self.name)
 * 
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 234, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 234, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(5, 234, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":233
 *                 return out_args[0]
 *             return tuple(out_args)
 *         if a.size == 0 and self.identity is None:             # <<<<<<<<<<<<<<
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)
 */
  }

  /* "cupy/core/reduction.pxi":238
 * 
 *         in_args, in_shape = _get_trans_args(
 *             in_args, laxis + raxis, a_shape, None)             # <<<<<<<<<<<<<<
 * 
 *         block_size = self._block_size
 */
  __pyx_t_3 = PyNumber_Add(__pyx_v_laxis, __pyx_v_raxis); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(PyTuple_CheckExact(__pyx_v_a_shape))||((__pyx_v_a_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_a_shape)->tp_name), 0))) __PYX_ERR(5, 238, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":237
 *                               ' %s which has no identity') % self.name)
 * 
 *         in_args, in_shape = _get_trans_args(             # <<<<<<<<<<<<<<
 *             in_args, laxis + raxis, a_shape, None)
 * 
 */
  __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_trans_args(__pyx_v_in_args, ((PyObject*)__pyx_t_3), ((PyObject*)__pyx_v_a_shape), ((PyObject*)Py_None), 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(__pyx_t_4 != Py_None)) {
    PyObject* sequence = __pyx_t_4;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(5, 237, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(5, 237, __pyx_L1_error)
  }
  if (!(likely(PyList_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(5, 237, __pyx_L1_error)
  __Pyx_DECREF_SET(__pyx_v_in_args, ((PyObject*)__pyx_t_3));
  __pyx_t_3 = 0;
  __pyx_v_in_shape = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":240
 *             in_args, laxis + raxis, a_shape, None)
 * 
 *         block_size = self._block_size             # <<<<<<<<<<<<<<
 *         in_indexer = Indexer(in_shape)
 *         out_indexer = Indexer(out_shape)
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_block_size_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 240, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_block_size = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":241
 * 
 *         block_size = self._block_size
 *         in_indexer = Indexer(in_shape)             # <<<<<<<<<<<<<<
 *         out_indexer = Indexer(out_shape)
 *         # Rounding Up to the Next Power of 2
 */
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_in_shape);
  __Pyx_GIVEREF(__pyx_v_in_shape);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_in_shape);
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_in_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":242
 *         block_size = self._block_size
 *         in_indexer = Indexer(in_shape)
 *         out_indexer = Indexer(out_shape)             # <<<<<<<<<<<<<<
 *         # Rounding Up to the Next Power of 2
 *         # clp2_count >= in_indexer.size // out_indexer.size
 */
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_out_shape);
  __Pyx_GIVEREF(__pyx_v_out_shape);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_out_shape);
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_out_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":245
 *         # Rounding Up to the Next Power of 2
 *         # clp2_count >= in_indexer.size // out_indexer.size
 *         clp2_count = 1 << int.bit_length(             # <<<<<<<<<<<<<<
 *             int(in_indexer.size // out_indexer.size - 1))
 *         block_stride = max(1, block_size // clp2_count)
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyInt_Type)), __pyx_n_s_bit_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 245, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/reduction.pxi":246
 *         # clp2_count >= in_indexer.size // out_indexer.size
 *         clp2_count = 1 << int.bit_length(
 *             int(in_indexer.size // out_indexer.size - 1))             # <<<<<<<<<<<<<<
 *         block_stride = max(1, block_size // clp2_count)
 * 
 */
  if (unlikely(__pyx_v_out_indexer->size == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(5, 246, __pyx_L1_error)
  }
  else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_out_indexer->size == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_in_indexer->size))) {
    PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
    __PYX_ERR(5, 246, __pyx_L1_error)
  }
  __pyx_t_3 = PyInt_FromSsize_t((__Pyx_div_Py_ssize_t(__pyx_v_in_indexer->size, __pyx_v_out_indexer->size) - 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 245, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 245, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 245, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 245, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 245, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":245
 *         # Rounding Up to the Next Power of 2
 *         # clp2_count >= in_indexer.size // out_indexer.size
 *         clp2_count = 1 << int.bit_length(             # <<<<<<<<<<<<<<
 *             int(in_indexer.size // out_indexer.size - 1))
 *         block_stride = max(1, block_size // clp2_count)
 */
  __pyx_t_5 = PyNumber_Lshift(__pyx_int_1, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 245, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_clp2_count = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":247
 *         clp2_count = 1 << int.bit_length(
 *             int(in_indexer.size // out_indexer.size - 1))
 *         block_stride = max(1, block_size // clp2_count)             # <<<<<<<<<<<<<<
 * 
 *         inout_args = _get_inout_args(
 */
  __pyx_t_5 = PyNumber_FloorDivide(__pyx_v_block_size, __pyx_v_clp2_count); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_10 = 1;
  __pyx_t_9 = __Pyx_PyInt_From_long(__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_t_9, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 247, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(5, 247, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_1) {
    __Pyx_INCREF(__pyx_t_5);
    __pyx_t_4 = __pyx_t_5;
  } else {
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 247, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __pyx_t_4;
  __Pyx_INCREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_block_stride = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":251
 *         inout_args = _get_inout_args(
 *             in_args, out_args, in_indexer, out_indexer, block_stride,
 *             self._params, True)             # <<<<<<<<<<<<<<
 *         args_info = _get_args_info(inout_args)
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (!(likely(PyTuple_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(5, 251, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":249
 *         block_stride = max(1, block_size // clp2_count)
 * 
 *         inout_args = _get_inout_args(             # <<<<<<<<<<<<<<
 *             in_args, out_args, in_indexer, out_indexer, block_stride,
 *             self._params, True)
 */
  __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_inout_args(__pyx_v_in_args, __pyx_v_out_args, __pyx_v_in_indexer, __pyx_v_out_indexer, __pyx_v_block_stride, ((PyObject*)__pyx_t_5), 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_inout_args = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":252
 *             in_args, out_args, in_indexer, out_indexer, block_stride,
 *             self._params, True)
 *         args_info = _get_args_info(inout_args)             # <<<<<<<<<<<<<<
 * 
 *         kern = _get_simple_reduction_function(
 */
  __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_args_info(__pyx_v_inout_args, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_args_info = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":254
 *         args_info = _get_args_info(inout_args)
 * 
 *         kern = _get_simple_reduction_function(             # <<<<<<<<<<<<<<
 *             routine, self._params, args_info,
 *             in_args[0].dtype.type, out_args[0].dtype.type, out_types,
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_simple_reduction_function); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 254, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/reduction.pxi":255
 * 
 *         kern = _get_simple_reduction_function(
 *             routine, self._params, args_info,             # <<<<<<<<<<<<<<
 *             in_args[0].dtype.type, out_args[0].dtype.type, out_types,
 *             self.name, block_size, self.identity,
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/reduction.pxi":256
 *         kern = _get_simple_reduction_function(
 *             routine, self._params, args_info,
 *             in_args[0].dtype.type, out_args[0].dtype.type, out_types,             # <<<<<<<<<<<<<<
 *             self.name, block_size, self.identity,
 *             self._input_expr, self._output_expr, self._preamble, ())
 */
  if (unlikely(__pyx_v_in_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(5, 256, __pyx_L1_error)
  }
  __pyx_t_9 = __Pyx_GetItemInt_List(__pyx_v_in_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(__pyx_v_out_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(5, 256, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_dtype); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/reduction.pxi":257
 *             routine, self._params, args_info,
 *             in_args[0].dtype.type, out_args[0].dtype.type, out_types,
 *             self.name, block_size, self.identity,             # <<<<<<<<<<<<<<
 *             self._input_expr, self._output_expr, self._preamble, ())
 * 
 */
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_identity); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/reduction.pxi":258
 *             in_args[0].dtype.type, out_args[0].dtype.type, out_types,
 *             self.name, block_size, self.identity,
 *             self._input_expr, self._output_expr, self._preamble, ())             # <<<<<<<<<<<<<<
 * 
 *         # TODO(okuta) set actual size
 */
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_input_expr_2); if (unlikely(!__pyx_t_13)) __PYX_ERR(5, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_output_expr_2); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_preamble_2); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_16 = NULL;
  __pyx_t_17 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_16)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_16);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_17 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[14] = {__pyx_t_16, __pyx_v_routine, __pyx_t_3, __pyx_v_args_info, __pyx_t_9, __pyx_t_6, __pyx_v_out_types, __pyx_t_11, __pyx_v_block_size, __pyx_t_12, __pyx_t_13, __pyx_t_14, __pyx_t_15, __pyx_empty_tuple};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_17, 13+__pyx_t_17); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 254, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[14] = {__pyx_t_16, __pyx_v_routine, __pyx_t_3, __pyx_v_args_info, __pyx_t_9, __pyx_t_6, __pyx_v_out_types, __pyx_t_11, __pyx_v_block_size, __pyx_t_12, __pyx_t_13, __pyx_t_14, __pyx_t_15, __pyx_empty_tuple};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_17, 13+__pyx_t_17); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 254, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  } else
  #endif
  {
    __pyx_t_18 = PyTuple_New(13+__pyx_t_17); if (unlikely(!__pyx_t_18)) __PYX_ERR(5, 254, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_18);
    if (__pyx_t_16) {
      __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_16); __pyx_t_16 = NULL;
    }
    __Pyx_INCREF(__pyx_v_routine);
    __Pyx_GIVEREF(__pyx_v_routine);
    PyTuple_SET_ITEM(__pyx_t_18, 0+__pyx_t_17, __pyx_v_routine);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_18, 1+__pyx_t_17, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_args_info);
    __Pyx_GIVEREF(__pyx_v_args_info);
    PyTuple_SET_ITEM(__pyx_t_18, 2+__pyx_t_17, __pyx_v_args_info);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_18, 3+__pyx_t_17, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_18, 4+__pyx_t_17, __pyx_t_6);
    __Pyx_INCREF(__pyx_v_out_types);
    __Pyx_GIVEREF(__pyx_v_out_types);
    PyTuple_SET_ITEM(__pyx_t_18, 5+__pyx_t_17, __pyx_v_out_types);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_18, 6+__pyx_t_17, __pyx_t_11);
    __Pyx_INCREF(__pyx_v_block_size);
    __Pyx_GIVEREF(__pyx_v_block_size);
    PyTuple_SET_ITEM(__pyx_t_18, 7+__pyx_t_17, __pyx_v_block_size);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_18, 8+__pyx_t_17, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_18, 9+__pyx_t_17, __pyx_t_13);
    __Pyx_GIVEREF(__pyx_t_14);
    PyTuple_SET_ITEM(__pyx_t_18, 10+__pyx_t_17, __pyx_t_14);
    __Pyx_GIVEREF(__pyx_t_15);
    PyTuple_SET_ITEM(__pyx_t_18, 11+__pyx_t_17, __pyx_t_15);
    __Pyx_INCREF(__pyx_empty_tuple);
    __Pyx_GIVEREF(__pyx_empty_tuple);
    PyTuple_SET_ITEM(__pyx_t_18, 12+__pyx_t_17, __pyx_empty_tuple);
    __pyx_t_3 = 0;
    __pyx_t_9 = 0;
    __pyx_t_6 = 0;
    __pyx_t_11 = 0;
    __pyx_t_12 = 0;
    __pyx_t_13 = 0;
    __pyx_t_14 = 0;
    __pyx_t_15 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_18, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 254, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_kern = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":261
 * 
 *         # TODO(okuta) set actual size
 *         shared_mem = 32 * block_size             # <<<<<<<<<<<<<<
 * 
 *         kern.linear_launch(
 */
  __pyx_t_4 = PyNumber_Multiply(__pyx_int_32, __pyx_v_block_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_shared_mem = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":263
 *         shared_mem = 32 * block_size
 * 
 *         kern.linear_launch(             # <<<<<<<<<<<<<<
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,
 *             inout_args, shared_mem, block_size)
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_kern, __pyx_n_s_linear_launch); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/reduction.pxi":264
 * 
 *         kern.linear_launch(
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,             # <<<<<<<<<<<<<<
 *             inout_args, shared_mem, block_size)
 * 
 */
  __pyx_t_18 = PyInt_FromSsize_t(__pyx_v_out_indexer->size); if (unlikely(!__pyx_t_18)) __PYX_ERR(5, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_15 = PyNumber_Add(__pyx_t_18, __pyx_v_block_stride); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  __pyx_t_18 = __Pyx_PyInt_SubtractObjC(__pyx_t_15, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_18)) __PYX_ERR(5, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_15 = PyNumber_FloorDivide(__pyx_t_18, __pyx_v_block_stride); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  __pyx_t_18 = PyNumber_Multiply(__pyx_t_15, __pyx_v_block_size); if (unlikely(!__pyx_t_18)) __PYX_ERR(5, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/reduction.pxi":265
 *         kern.linear_launch(
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,
 *             inout_args, shared_mem, block_size)             # <<<<<<<<<<<<<<
 * 
 *         if len(out_args) == 1:
 */
  __pyx_t_15 = NULL;
  __pyx_t_17 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_17 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[5] = {__pyx_t_15, __pyx_t_18, __pyx_v_inout_args, __pyx_v_shared_mem, __pyx_v_block_size};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_17, 4+__pyx_t_17); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 263, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[5] = {__pyx_t_15, __pyx_t_18, __pyx_v_inout_args, __pyx_v_shared_mem, __pyx_v_block_size};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_17, 4+__pyx_t_17); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 263, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  } else
  #endif
  {
    __pyx_t_14 = PyTuple_New(4+__pyx_t_17); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    if (__pyx_t_15) {
      __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_15); __pyx_t_15 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_18);
    PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_17, __pyx_t_18);
    __Pyx_INCREF(__pyx_v_inout_args);
    __Pyx_GIVEREF(__pyx_v_inout_args);
    PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_17, __pyx_v_inout_args);
    __Pyx_INCREF(__pyx_v_shared_mem);
    __Pyx_GIVEREF(__pyx_v_shared_mem);
    PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_17, __pyx_v_shared_mem);
    __Pyx_INCREF(__pyx_v_block_size);
    __Pyx_GIVEREF(__pyx_v_block_size);
    PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_17, __pyx_v_block_size);
    __pyx_t_18 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_14, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":267
 *             inout_args, shared_mem, block_size)
 * 
 *         if len(out_args) == 1:             # <<<<<<<<<<<<<<
 *             return out_args[0]
 *         return tuple(out_args)
 */
  if (unlikely(__pyx_v_out_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(5, 267, __pyx_L1_error)
  }
  __pyx_t_7 = PyList_GET_SIZE(__pyx_v_out_args); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(5, 267, __pyx_L1_error)
  __pyx_t_1 = ((__pyx_t_7 == 1) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":268
 * 
 *         if len(out_args) == 1:
 *             return out_args[0]             # <<<<<<<<<<<<<<
 *         return tuple(out_args)
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(5, 268, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "cupy/core/reduction.pxi":267
 *             inout_args, shared_mem, block_size)
 * 
 *         if len(out_args) == 1:             # <<<<<<<<<<<<<<
 *             return out_args[0]
 *         return tuple(out_args)
 */
  }

  /* "cupy/core/reduction.pxi":269
 *         if len(out_args) == 1:
 *             return out_args[0]
 *         return tuple(out_args)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_out_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(5, 269, __pyx_L1_error)
  }
  __pyx_t_4 = PyList_AsTuple(__pyx_v_out_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":206
 *         self._routine_cache = {}
 * 
 *     def __call__(self, ndarray a, axis=None, dtype=None, ndarray out=None,             # <<<<<<<<<<<<<<
 *                  bint keepdims=False):
 *         cdef list in_args, out_args
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_AddTraceback("cupy.core.core.simple_reduction_function.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_in_args);
  __Pyx_XDECREF(__pyx_v_out_args);
  __Pyx_XDECREF(__pyx_v_laxis);
  __Pyx_XDECREF(__pyx_v_raxis);
  __Pyx_XDECREF(__pyx_v_a_shape);
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XDECREF(__pyx_v_routine);
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XDECREF(__pyx_v_in_shape);
  __Pyx_XDECREF(__pyx_v_block_size);
  __Pyx_XDECREF((PyObject *)__pyx_v_in_indexer);
  __Pyx_XDECREF((PyObject *)__pyx_v_out_indexer);
  __Pyx_XDECREF(__pyx_v_clp2_count);
  __Pyx_XDECREF(__pyx_v_block_stride);
  __Pyx_XDECREF(__pyx_v_inout_args);
  __Pyx_XDECREF(__pyx_v_args_info);
  __Pyx_XDECREF(__pyx_v_kern);
  __Pyx_XDECREF(__pyx_v_shared_mem);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_47_get_reduction_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_46_get_reduction_kernel[] = "_get_reduction_kernel(params, args_info, types, name, block_size, reduce_type, identity, map_expr, reduce_expr, post_map_expr, preamble, options)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_47_get_reduction_kernel = {"_get_reduction_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_47_get_reduction_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_46_get_reduction_kernel};
static PyObject *__pyx_pw_4cupy_4core_4core_47_get_reduction_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_args_info = 0;
  PyObject *__pyx_v_types = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_block_size = 0;
  PyObject *__pyx_v_reduce_type = 0;
  PyObject *__pyx_v_identity = 0;
  PyObject *__pyx_v_map_expr = 0;
  PyObject *__pyx_v_reduce_expr = 0;
  PyObject *__pyx_v_post_map_expr = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_options = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_reduction_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_params,&__pyx_n_s_args_info,&__pyx_n_s_types,&__pyx_n_s_name,&__pyx_n_s_block_size,&__pyx_n_s_reduce_type,&__pyx_n_s_identity,&__pyx_n_s_map_expr,&__pyx_n_s_reduce_expr,&__pyx_n_s_post_map_expr,&__pyx_n_s_preamble,&__pyx_n_s_options,0};
    PyObject* values[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_params)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_args_info)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 1); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_types)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 2); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 3); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_block_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 4); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_reduce_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 5); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_identity)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 6); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_map_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 7); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_reduce_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 8); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_post_map_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 9); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_preamble)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 10); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (likely((values[11] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_options)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 11); __PYX_ERR(5, 273, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_reduction_kernel") < 0)) __PYX_ERR(5, 273, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 12) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
      values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
      values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
    }
    __pyx_v_params = values[0];
    __pyx_v_args_info = values[1];
    __pyx_v_types = values[2];
    __pyx_v_name = values[3];
    __pyx_v_block_size = values[4];
    __pyx_v_reduce_type = values[5];
    __pyx_v_identity = values[6];
    __pyx_v_map_expr = values[7];
    __pyx_v_reduce_expr = values[8];
    __pyx_v_post_map_expr = values[9];
    __pyx_v_preamble = values[10];
    __pyx_v_options = values[11];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 273, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_reduction_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_46_get_reduction_kernel(__pyx_self, __pyx_v_params, __pyx_v_args_info, __pyx_v_types, __pyx_v_name, __pyx_v_block_size, __pyx_v_reduce_type, __pyx_v_identity, __pyx_v_map_expr, __pyx_v_reduce_expr, __pyx_v_post_map_expr, __pyx_v_preamble, __pyx_v_options);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_4cupy_4core_4core_21_get_reduction_kernel_2generator3(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "cupy/core/reduction.pxi":281
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)             # <<<<<<<<<<<<<<
 *         for k, v in types)
 *     input_expr = '\n'.join(
 */

static PyObject *__pyx_pf_4cupy_4core_4core_21_get_reduction_kernel_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *)__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_6_genexpr(__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_6_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 281, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4cupy_4core_4core_21_get_reduction_kernel_2generator3, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_get_reduction_kernel_locals_gen, __pyx_n_s_cupy_core_core); if (unlikely(!gen)) __PYX_ERR(5, 281, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

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

static PyObject *__pyx_gb_4cupy_4core_4core_21_get_reduction_kernel_2generator3(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *__pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L8_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 281, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":282
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)
 *         for k, v in types)             # <<<<<<<<<<<<<<
 *     input_expr = '\n'.join(
 *         ['const {0} {1} = _raw_{1}[_j];'.format(p.ctype, p.name)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types)) { __Pyx_RaiseClosureNameError("types"); __PYX_ERR(5, 282, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_types; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 282, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 282, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(5, 282, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 282, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(5, 282, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 282, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(5, 282, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(5, 282, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 282, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 282, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 282, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(5, 282, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(5, 282, __pyx_L1_error)
      __pyx_L7_unpacking_done:;
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_k);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_k, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/reduction.pxi":281
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)             # <<<<<<<<<<<<<<
 *         for k, v in types)
 *     input_expr = '\n'.join(
 */
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_cur_scope->__pyx_v_v, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_k);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_cur_scope->__pyx_v_k);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_typedef_s_s, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L8_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 281, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":282
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)
 *         for k, v in types)             # <<<<<<<<<<<<<<
 *     input_expr = '\n'.join(
 *         ['const {0} {1} = _raw_{1}[_j];'.format(p.ctype, p.name)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "cupy/core/reduction.pxi":281
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)             # <<<<<<<<<<<<<<
 *         for k, v in types)
 *     input_expr = '\n'.join(
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":273
 * 
 * @util.memoize(for_each_device=True)
 * def _get_reduction_kernel(             # <<<<<<<<<<<<<<
 *         params, args_info, types,
 *         name, block_size, reduce_type, identity, map_expr, reduce_expr,
 */

static PyObject *__pyx_pf_4cupy_4core_4core_46_get_reduction_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_params, PyObject *__pyx_v_args_info, PyObject *__pyx_v_types, PyObject *__pyx_v_name, PyObject *__pyx_v_block_size, PyObject *__pyx_v_reduce_type, PyObject *__pyx_v_identity, PyObject *__pyx_v_map_expr, PyObject *__pyx_v_reduce_expr, PyObject *__pyx_v_post_map_expr, PyObject *__pyx_v_preamble, PyObject *__pyx_v_options) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *__pyx_cur_scope;
  PyObject *__pyx_v_kernel_params = NULL;
  PyObject *__pyx_v_arrays = NULL;
  PyObject *__pyx_v_type_preamble = NULL;
  PyObject *__pyx_v_input_expr = NULL;
  PyObject *__pyx_v_output_expr = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  __Pyx_RefNannySetupContext("_get_reduction_kernel", 0);
  __pyx_cur_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *)__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel(__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 273, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_types = __pyx_v_types;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_types);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_types);

  /* "cupy/core/reduction.pxi":277
 *         name, block_size, reduce_type, identity, map_expr, reduce_expr,
 *         post_map_expr, preamble, options):
 *     kernel_params = _get_kernel_params(params, args_info)             # <<<<<<<<<<<<<<
 *     arrays = [p for p, a in zip(params, args_info)
 *               if not p.raw and a[0] is ndarray]
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_params))||((__pyx_v_params) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_params)->tp_name), 0))) __PYX_ERR(5, 277, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_args_info))||((__pyx_v_args_info) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args_info)->tp_name), 0))) __PYX_ERR(5, 277, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_kernel_params(((PyObject*)__pyx_v_params), ((PyObject*)__pyx_v_args_info), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_kernel_params = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":278
 *         post_map_expr, preamble, options):
 *     kernel_params = _get_kernel_params(params, args_info)
 *     arrays = [p for p, a in zip(params, args_info)             # <<<<<<<<<<<<<<
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_params);
  __Pyx_GIVEREF(__pyx_v_params);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_params);
  __Pyx_INCREF(__pyx_v_args_info);
  __Pyx_GIVEREF(__pyx_v_args_info);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_args_info);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 278, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 278, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 278, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 278, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 278, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 278, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(5, 278, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
      PyObject* sequence = __pyx_t_3;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(5, 278, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(5, 278, __pyx_L1_error)
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(5, 278, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/reduction.pxi":279
 *     kernel_params = _get_kernel_params(params, args_info)
 *     arrays = [p for p, a in zip(params, args_info)
 *               if not p.raw and a[0] is ndarray]             # <<<<<<<<<<<<<<
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_raw_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 279, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(5, 279, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_12 = ((!__pyx_t_11) != 0);
    if (__pyx_t_12) {
    } else {
      __pyx_t_10 = __pyx_t_12;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_a, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 279, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_12 = (__pyx_t_3 == ((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray));
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_11 = (__pyx_t_12 != 0);
    __pyx_t_10 = __pyx_t_11;
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_10) {

      /* "cupy/core/reduction.pxi":278
 *         post_map_expr, preamble, options):
 *     kernel_params = _get_kernel_params(params, args_info)
 *     arrays = [p for p, a in zip(params, args_info)             # <<<<<<<<<<<<<<
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(
 */
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_v_p))) __PYX_ERR(5, 278, __pyx_L1_error)

      /* "cupy/core/reduction.pxi":279
 *     kernel_params = _get_kernel_params(params, args_info)
 *     arrays = [p for p, a in zip(params, args_info)
 *               if not p.raw and a[0] is ndarray]             # <<<<<<<<<<<<<<
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)
 */
    }

    /* "cupy/core/reduction.pxi":278
 *         post_map_expr, preamble, options):
 *     kernel_params = _get_kernel_params(params, args_info)
 *     arrays = [p for p, a in zip(params, args_info)             # <<<<<<<<<<<<<<
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_arrays = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":281
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)             # <<<<<<<<<<<<<<
 *         for k, v in types)
 *     input_expr = '\n'.join(
 */
  __pyx_t_1 = __pyx_pf_4cupy_4core_4core_21_get_reduction_kernel_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 281, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/reduction.pxi":280
 *     arrays = [p for p, a in zip(params, args_info)
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(             # <<<<<<<<<<<<<<
 *         'typedef %s %s;' % (_get_typename(v), k)
 *         for k, v in types)
 */
  __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__63, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_type_preamble = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":284
 *         for k, v in types)
 *     input_expr = '\n'.join(
 *         ['const {0} {1} = _raw_{1}[_j];'.format(p.ctype, p.name)             # <<<<<<<<<<<<<<
 *          for p in arrays if p.is_const])
 *     output_expr = '\n'.join(
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/reduction.pxi":285
 *     input_expr = '\n'.join(
 *         ['const {0} {1} = _raw_{1}[_j];'.format(p.ctype, p.name)
 *          for p in arrays if p.is_const])             # <<<<<<<<<<<<<<
 *     output_expr = '\n'.join(
 *         ['{0} &{1} = _raw_{1}[_i];'.format(p.ctype, p.name)
 */
  __pyx_t_1 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 285, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 285, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_is_const); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 285, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(5, 285, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_10) {

      /* "cupy/core/reduction.pxi":284
 *         for k, v in types)
 *     input_expr = '\n'.join(
 *         ['const {0} {1} = _raw_{1}[_j];'.format(p.ctype, p.name)             # <<<<<<<<<<<<<<
 *          for p in arrays if p.is_const])
 *     output_expr = '\n'.join(
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_const_0_1__raw__1__j, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 284, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 284, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 284, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_13 = NULL;
      __pyx_t_14 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_14 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_6, __pyx_t_8};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 284, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_6, __pyx_t_8};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 284, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_15 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 284, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        if (__pyx_t_13) {
          __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_13); __pyx_t_13 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_14, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_14, __pyx_t_8);
        __pyx_t_6 = 0;
        __pyx_t_8 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 284, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_3))) __PYX_ERR(5, 284, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/reduction.pxi":285
 *     input_expr = '\n'.join(
 *         ['const {0} {1} = _raw_{1}[_j];'.format(p.ctype, p.name)
 *          for p in arrays if p.is_const])             # <<<<<<<<<<<<<<
 *     output_expr = '\n'.join(
 *         ['{0} &{1} = _raw_{1}[_i];'.format(p.ctype, p.name)
 */
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":283
 *         'typedef %s %s;' % (_get_typename(v), k)
 *         for k, v in types)
 *     input_expr = '\n'.join(             # <<<<<<<<<<<<<<
 *         ['const {0} {1} = _raw_{1}[_j];'.format(p.ctype, p.name)
 *          for p in arrays if p.is_const])
 */
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__63, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_input_expr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":287
 *          for p in arrays if p.is_const])
 *     output_expr = '\n'.join(
 *         ['{0} &{1} = _raw_{1}[_i];'.format(p.ctype, p.name)             # <<<<<<<<<<<<<<
 *          for p in arrays if not p.is_const])
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/reduction.pxi":288
 *     output_expr = '\n'.join(
 *         ['{0} &{1} = _raw_{1}[_i];'.format(p.ctype, p.name)
 *          for p in arrays if not p.is_const])             # <<<<<<<<<<<<<<
 * 
 *     return _get_simple_reduction_kernel(
 */
  __pyx_t_2 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 288, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 288, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_is_const); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 288, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(5, 288, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_11 = ((!__pyx_t_10) != 0);
    if (__pyx_t_11) {

      /* "cupy/core/reduction.pxi":287
 *          for p in arrays if p.is_const])
 *     output_expr = '\n'.join(
 *         ['{0} &{1} = _raw_{1}[_i];'.format(p.ctype, p.name)             # <<<<<<<<<<<<<<
 *          for p in arrays if not p.is_const])
 * 
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_0_1__raw__1__i, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 287, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 287, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 287, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_6 = NULL;
      __pyx_t_14 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_14 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_15, __pyx_t_8};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 287, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_15, __pyx_t_8};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 287, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_13 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_13)) __PYX_ERR(5, 287, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        if (__pyx_t_6) {
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_6); __pyx_t_6 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_15);
        PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_14, __pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_14, __pyx_t_8);
        __pyx_t_15 = 0;
        __pyx_t_8 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 287, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(5, 287, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/reduction.pxi":288
 *     output_expr = '\n'.join(
 *         ['{0} &{1} = _raw_{1}[_i];'.format(p.ctype, p.name)
 *          for p in arrays if not p.is_const])             # <<<<<<<<<<<<<<
 * 
 *     return _get_simple_reduction_kernel(
 */
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":286
 *         ['const {0} {1} = _raw_{1}[_j];'.format(p.ctype, p.name)
 *          for p in arrays if p.is_const])
 *     output_expr = '\n'.join(             # <<<<<<<<<<<<<<
 *         ['{0} &{1} = _raw_{1}[_i];'.format(p.ctype, p.name)
 *          for p in arrays if not p.is_const])
 */
  __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__63, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_output_expr = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":290
 *          for p in arrays if not p.is_const])
 * 
 *     return _get_simple_reduction_kernel(             # <<<<<<<<<<<<<<
 *         name, block_size, reduce_type, kernel_params, identity,
 *         map_expr, reduce_expr, post_map_expr,
 */
  __Pyx_XDECREF(__pyx_r);

  /* "cupy/core/reduction.pxi":293
 *         name, block_size, reduce_type, kernel_params, identity,
 *         map_expr, reduce_expr, post_map_expr,
 *         type_preamble, input_expr, output_expr, preamble, options)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __pyx_f_4cupy_4core_4core__get_simple_reduction_kernel(__pyx_v_name, __pyx_v_block_size, __pyx_v_reduce_type, __pyx_v_kernel_params, __pyx_v_identity, __pyx_v_map_expr, __pyx_v_reduce_expr, __pyx_v_post_map_expr, __pyx_v_type_preamble, __pyx_v_input_expr, __pyx_v_output_expr, __pyx_v_preamble, __pyx_v_options, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":273
 * 
 * @util.memoize(for_each_device=True)
 * def _get_reduction_kernel(             # <<<<<<<<<<<<<<
 *         params, args_info, types,
 *         name, block_size, reduce_type, identity, map_expr, reduce_expr,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("cupy.core.core._get_reduction_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_kernel_params);
  __Pyx_XDECREF(__pyx_v_arrays);
  __Pyx_XDECREF(__pyx_v_type_preamble);
  __Pyx_XDECREF(__pyx_v_input_expr);
  __Pyx_XDECREF(__pyx_v_output_expr);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":327
 * 
 *     """
 *     def __init__(self, in_params, out_params,             # <<<<<<<<<<<<<<
 *                  map_expr, reduce_expr, post_map_expr,
 *                  identity, name='reduce_kernel', reduce_type=None,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_15ReductionKernel_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_15ReductionKernel___init__[] = "ReductionKernel.__init__(self, in_params, out_params, map_expr, reduce_expr, post_map_expr, identity, name='reduce_kernel', reduce_type=None, reduce_dims=True, preamble='', options=())";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_15ReductionKernel_1__init__ = {"__init__", (PyCFunction)__pyx_pw_4cupy_4core_4core_15ReductionKernel_1__init__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_15ReductionKernel___init__};
static PyObject *__pyx_pw_4cupy_4core_4core_15ReductionKernel_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_in_params = 0;
  PyObject *__pyx_v_out_params = 0;
  PyObject *__pyx_v_map_expr = 0;
  PyObject *__pyx_v_reduce_expr = 0;
  PyObject *__pyx_v_post_map_expr = 0;
  PyObject *__pyx_v_identity = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_reduce_type = 0;
  PyObject *__pyx_v_reduce_dims = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_options = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_in_params,&__pyx_n_s_out_params,&__pyx_n_s_map_expr,&__pyx_n_s_reduce_expr,&__pyx_n_s_post_map_expr,&__pyx_n_s_identity,&__pyx_n_s_name,&__pyx_n_s_reduce_type,&__pyx_n_s_reduce_dims,&__pyx_n_s_preamble,&__pyx_n_s_options,0};
    PyObject* values[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
    values[7] = ((PyObject *)((PyObject*)__pyx_n_s_reduce_kernel));

    /* "cupy/core/reduction.pxi":329
 *     def __init__(self, in_params, out_params,
 *                  map_expr, reduce_expr, post_map_expr,
 *                  identity, name='reduce_kernel', reduce_type=None,             # <<<<<<<<<<<<<<
 *                  reduce_dims=True, preamble='', options=()):
 *         if not compiler.is_valid_kernel_name(name):
 */
    values[8] = ((PyObject *)((PyObject *)Py_None));

    /* "cupy/core/reduction.pxi":330
 *                  map_expr, reduce_expr, post_map_expr,
 *                  identity, name='reduce_kernel', reduce_type=None,
 *                  reduce_dims=True, preamble='', options=()):             # <<<<<<<<<<<<<<
 *         if not compiler.is_valid_kernel_name(name):
 *             raise ValueError(
 */
    values[9] = ((PyObject *)((PyObject *)Py_True));
    values[10] = ((PyObject *)((PyObject*)__pyx_kp_s__5));
    values[11] = ((PyObject *)((PyObject*)__pyx_empty_tuple));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_in_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 12, 1); __PYX_ERR(5, 327, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 12, 2); __PYX_ERR(5, 327, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_map_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 12, 3); __PYX_ERR(5, 327, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_reduce_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 12, 4); __PYX_ERR(5, 327, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_post_map_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 12, 5); __PYX_ERR(5, 327, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_identity)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 12, 6); __PYX_ERR(5, 327, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name);
          if (value) { values[7] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_reduce_type);
          if (value) { values[8] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_reduce_dims);
          if (value) { values[9] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_preamble);
          if (value) { values[10] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_options);
          if (value) { values[11] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(5, 327, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_in_params = values[1];
    __pyx_v_out_params = values[2];
    __pyx_v_map_expr = values[3];
    __pyx_v_reduce_expr = values[4];
    __pyx_v_post_map_expr = values[5];
    __pyx_v_identity = values[6];
    __pyx_v_name = values[7];
    __pyx_v_reduce_type = values[8];
    __pyx_v_reduce_dims = values[9];
    __pyx_v_preamble = values[10];
    __pyx_v_options = values[11];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 12, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 327, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ReductionKernel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_15ReductionKernel___init__(__pyx_self, __pyx_v_self, __pyx_v_in_params, __pyx_v_out_params, __pyx_v_map_expr, __pyx_v_reduce_expr, __pyx_v_post_map_expr, __pyx_v_identity, __pyx_v_name, __pyx_v_reduce_type, __pyx_v_reduce_dims, __pyx_v_preamble, __pyx_v_options);

  /* "cupy/core/reduction.pxi":327
 * 
 *     """
 *     def __init__(self, in_params, out_params,             # <<<<<<<<<<<<<<
 *                  map_expr, reduce_expr, post_map_expr,
 *                  identity, name='reduce_kernel', reduce_type=None,
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_15ReductionKernel___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_in_params, PyObject *__pyx_v_out_params, PyObject *__pyx_v_map_expr, PyObject *__pyx_v_reduce_expr, PyObject *__pyx_v_post_map_expr, PyObject *__pyx_v_identity, PyObject *__pyx_v_name, PyObject *__pyx_v_reduce_type, PyObject *__pyx_v_reduce_dims, PyObject *__pyx_v_preamble, PyObject *__pyx_v_options) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/reduction.pxi":331
 *                  identity, name='reduce_kernel', reduce_type=None,
 *                  reduce_dims=True, preamble='', options=()):
 *         if not compiler.is_valid_kernel_name(name):             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'Invalid kernel name: "%s"' % name)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_compiler); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_is_valid_kernel_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 331, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_name};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 331, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_name};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 331, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 331, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_INCREF(__pyx_v_name);
      __Pyx_GIVEREF(__pyx_v_name);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_name);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 331, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(5, 331, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = ((!__pyx_t_5) != 0);
  if (__pyx_t_6) {

    /* "cupy/core/reduction.pxi":333
 *         if not compiler.is_valid_kernel_name(name):
 *             raise ValueError(
 *                 'Invalid kernel name: "%s"' % name)             # <<<<<<<<<<<<<<
 * 
 *         self.in_params = _get_param_info(in_params, True)
 */
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_kernel_name_s, __pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 333, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "cupy/core/reduction.pxi":332
 *                  reduce_dims=True, preamble='', options=()):
 *         if not compiler.is_valid_kernel_name(name):
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'Invalid kernel name: "%s"' % name)
 * 
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 332, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 332, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(5, 332, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":331
 *                  identity, name='reduce_kernel', reduce_type=None,
 *                  reduce_dims=True, preamble='', options=()):
 *         if not compiler.is_valid_kernel_name(name):             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'Invalid kernel name: "%s"' % name)
 */
  }

  /* "cupy/core/reduction.pxi":335
 *                 'Invalid kernel name: "%s"' % name)
 * 
 *         self.in_params = _get_param_info(in_params, True)             # <<<<<<<<<<<<<<
 *         self.out_params = _get_param_info(out_params, False)
 *         self.nin = len(self.in_params)
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_7 = 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_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_in_params, Py_True};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 335, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_in_params, Py_True};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 335, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_2 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 335, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_v_in_params);
    __Pyx_GIVEREF(__pyx_v_in_params);
    PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_7, __pyx_v_in_params);
    __Pyx_INCREF(Py_True);
    __Pyx_GIVEREF(Py_True);
    PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_7, Py_True);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 335, __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;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_in_params, __pyx_t_1) < 0) __PYX_ERR(5, 335, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":336
 * 
 *         self.in_params = _get_param_info(in_params, True)
 *         self.out_params = _get_param_info(out_params, False)             # <<<<<<<<<<<<<<
 *         self.nin = len(self.in_params)
 *         self.nout = len(self.out_params)
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 336, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  __pyx_t_7 = 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_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_out_params, Py_False};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 336, __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, __pyx_v_out_params, Py_False};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 336, __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_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 336, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_v_out_params);
    __Pyx_GIVEREF(__pyx_v_out_params);
    PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_7, __pyx_v_out_params);
    __Pyx_INCREF(Py_False);
    __Pyx_GIVEREF(Py_False);
    PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_7, Py_False);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 336, __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 (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_out_params, __pyx_t_1) < 0) __PYX_ERR(5, 336, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":337
 *         self.in_params = _get_param_info(in_params, True)
 *         self.out_params = _get_param_info(out_params, False)
 *         self.nin = len(self.in_params)             # <<<<<<<<<<<<<<
 *         self.nout = len(self.out_params)
 *         self.nargs = self.nin + self.nout
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(5, 337, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nin, __pyx_t_1) < 0) __PYX_ERR(5, 337, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":338
 *         self.out_params = _get_param_info(out_params, False)
 *         self.nin = len(self.in_params)
 *         self.nout = len(self.out_params)             # <<<<<<<<<<<<<<
 *         self.nargs = self.nin + self.nout
 *         self.params = (
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_out_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(5, 338, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nout, __pyx_t_1) < 0) __PYX_ERR(5, 338, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":339
 *         self.nin = len(self.in_params)
 *         self.nout = len(self.out_params)
 *         self.nargs = self.nin + self.nout             # <<<<<<<<<<<<<<
 *         self.params = (
 *             self.in_params + self.out_params +
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nout); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nargs, __pyx_t_4) < 0) __PYX_ERR(5, 339, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":341
 *         self.nargs = self.nin + self.nout
 *         self.params = (
 *             self.in_params + self.out_params +             # <<<<<<<<<<<<<<
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_params); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_out_params); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyNumber_Add(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":342
 *         self.params = (
 *             self.in_params + self.out_params +
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +             # <<<<<<<<<<<<<<
 *             _get_param_info('int32 _block_stride', True))
 *         self.identity = identity
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__99, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":341
 *         self.nargs = self.nin + self.nout
 *         self.params = (
 *             self.in_params + self.out_params +             # <<<<<<<<<<<<<<
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))
 */
  __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":343
 *             self.in_params + self.out_params +
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))             # <<<<<<<<<<<<<<
 *         self.identity = identity
 *         self.reduce_expr = reduce_expr
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__100, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":342
 *         self.params = (
 *             self.in_params + self.out_params +
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +             # <<<<<<<<<<<<<<
 *             _get_param_info('int32 _block_stride', True))
 *         self.identity = identity
 */
  __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":340
 *         self.nout = len(self.out_params)
 *         self.nargs = self.nin + self.nout
 *         self.params = (             # <<<<<<<<<<<<<<
 *             self.in_params + self.out_params +
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_params, __pyx_t_4) < 0) __PYX_ERR(5, 340, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":344
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))
 *         self.identity = identity             # <<<<<<<<<<<<<<
 *         self.reduce_expr = reduce_expr
 *         self.map_expr = map_expr
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_identity, __pyx_v_identity) < 0) __PYX_ERR(5, 344, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":345
 *             _get_param_info('int32 _block_stride', True))
 *         self.identity = identity
 *         self.reduce_expr = reduce_expr             # <<<<<<<<<<<<<<
 *         self.map_expr = map_expr
 *         self.name = name
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_reduce_expr, __pyx_v_reduce_expr) < 0) __PYX_ERR(5, 345, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":346
 *         self.identity = identity
 *         self.reduce_expr = reduce_expr
 *         self.map_expr = map_expr             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self.options = options
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_map_expr, __pyx_v_map_expr) < 0) __PYX_ERR(5, 346, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":347
 *         self.reduce_expr = reduce_expr
 *         self.map_expr = map_expr
 *         self.name = name             # <<<<<<<<<<<<<<
 *         self.options = options
 *         self.reduce_dims = reduce_dims
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(5, 347, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":348
 *         self.map_expr = map_expr
 *         self.name = name
 *         self.options = options             # <<<<<<<<<<<<<<
 *         self.reduce_dims = reduce_dims
 *         self.post_map_expr = post_map_expr
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_options, __pyx_v_options) < 0) __PYX_ERR(5, 348, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":349
 *         self.name = name
 *         self.options = options
 *         self.reduce_dims = reduce_dims             # <<<<<<<<<<<<<<
 *         self.post_map_expr = post_map_expr
 *         if reduce_type is None:
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_reduce_dims, __pyx_v_reduce_dims) < 0) __PYX_ERR(5, 349, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":350
 *         self.options = options
 *         self.reduce_dims = reduce_dims
 *         self.post_map_expr = post_map_expr             # <<<<<<<<<<<<<<
 *         if reduce_type is None:
 *             self.reduce_type = self.out_params[0].ctype
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_post_map_expr, __pyx_v_post_map_expr) < 0) __PYX_ERR(5, 350, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":351
 *         self.reduce_dims = reduce_dims
 *         self.post_map_expr = post_map_expr
 *         if reduce_type is None:             # <<<<<<<<<<<<<<
 *             self.reduce_type = self.out_params[0].ctype
 *         else:
 */
  __pyx_t_6 = (__pyx_v_reduce_type == Py_None);
  __pyx_t_5 = (__pyx_t_6 != 0);
  if (__pyx_t_5) {

    /* "cupy/core/reduction.pxi":352
 *         self.post_map_expr = post_map_expr
 *         if reduce_type is None:
 *             self.reduce_type = self.out_params[0].ctype             # <<<<<<<<<<<<<<
 *         else:
 *             self.reduce_type = reduce_type
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_out_params); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 352, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 352, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ctype); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 352, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_reduce_type, __pyx_t_4) < 0) __PYX_ERR(5, 352, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":351
 *         self.reduce_dims = reduce_dims
 *         self.post_map_expr = post_map_expr
 *         if reduce_type is None:             # <<<<<<<<<<<<<<
 *             self.reduce_type = self.out_params[0].ctype
 *         else:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/reduction.pxi":354
 *             self.reduce_type = self.out_params[0].ctype
 *         else:
 *             self.reduce_type = reduce_type             # <<<<<<<<<<<<<<
 *         self.preamble = preamble
 * 
 */
  /*else*/ {
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_reduce_type, __pyx_v_reduce_type) < 0) __PYX_ERR(5, 354, __pyx_L1_error)
  }
  __pyx_L4:;

  /* "cupy/core/reduction.pxi":355
 *         else:
 *             self.reduce_type = reduce_type
 *         self.preamble = preamble             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, *args, **kwargs):
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_preamble, __pyx_v_preamble) < 0) __PYX_ERR(5, 355, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":327
 * 
 *     """
 *     def __init__(self, in_params, out_params,             # <<<<<<<<<<<<<<
 *                  map_expr, reduce_expr, post_map_expr,
 *                  identity, name='reduce_kernel', reduce_type=None,
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.ReductionKernel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":357
 *         self.preamble = preamble
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Compiles and invokes the reduction kernel.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_15ReductionKernel_3__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_15ReductionKernel_2__call__[] = "ReductionKernel.__call__(self, *args, **kwargs)\nCompiles and invokes the reduction kernel.\n\n        The compilation runs only if the kernel is not cached. Note that the\n        kernels with different argument dtypes, ndims, or axis are not\n        compatible. It means that single ReductionKernel object may be compiled\n        into multiple kernel binaries.\n\n        Args:\n            args: Arguments of the kernel.\n\n        Returns:\n            Arrays are returned according to the ``out_params`` argument of the\n            ``__init__`` method.\n\n        ";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_15ReductionKernel_3__call__ = {"__call__", (PyCFunction)__pyx_pw_4cupy_4core_4core_15ReductionKernel_3__call__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_15ReductionKernel_2__call__};
static PyObject *__pyx_pw_4cupy_4core_4core_15ReductionKernel_3__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_args);
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        default:
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "__call__") < 0)) __PYX_ERR(5, 357, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 357, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("cupy.core.core.ReductionKernel.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_15ReductionKernel_2__call__(__pyx_self, __pyx_v_self, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_15ReductionKernel_2__call__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_out = NULL;
  PyObject *__pyx_v_axis = NULL;
  PyObject *__pyx_v_keepdims = NULL;
  PyObject *__pyx_v_stream = NULL;
  Py_ssize_t __pyx_v_n_args;
  PyObject *__pyx_v_out_args = NULL;
  PyObject *__pyx_v_in_args = NULL;
  PyObject *__pyx_v_broad_shape = NULL;
  PyObject *__pyx_v_in_ndarray_types = NULL;
  PyObject *__pyx_v_out_ndarray_types = NULL;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  PyObject *__pyx_v_types = NULL;
  PyObject *__pyx_v_raxis = NULL;
  PyObject *__pyx_v_out_shape = NULL;
  PyObject *__pyx_v_in_shape = NULL;
  PyObject *__pyx_v_block_size = NULL;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_in_indexer = NULL;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_out_indexer = NULL;
  PyObject *__pyx_v_clp2_count = NULL;
  PyObject *__pyx_v_block_stride = NULL;
  PyObject *__pyx_v_inout_args = NULL;
  PyObject *__pyx_v_args_info = NULL;
  PyObject *__pyx_v_kern = NULL;
  PyObject *__pyx_v_shared_mem = NULL;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  struct __pyx_opt_args_4cupy_4core_4core__get_out_args_with_params __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  long __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "cupy/core/reduction.pxi":374
 *         """
 * 
 *         out = kwargs.pop('out', None)             # <<<<<<<<<<<<<<
 *         axis = kwargs.pop('axis', None)
 *         keepdims = kwargs.pop('keepdims', False)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__101, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_out = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":375
 * 
 *         out = kwargs.pop('out', None)
 *         axis = kwargs.pop('axis', None)             # <<<<<<<<<<<<<<
 *         keepdims = kwargs.pop('keepdims', False)
 *         stream = kwargs.pop('stream', None)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__102, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_axis = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":376
 *         out = kwargs.pop('out', None)
 *         axis = kwargs.pop('axis', None)
 *         keepdims = kwargs.pop('keepdims', False)             # <<<<<<<<<<<<<<
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__103, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_keepdims = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":377
 *         axis = kwargs.pop('axis', None)
 *         keepdims = kwargs.pop('keepdims', False)
 *         stream = kwargs.pop('stream', None)             # <<<<<<<<<<<<<<
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__104, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_stream = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":378
 *         keepdims = kwargs.pop('keepdims', False)
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(5, 378, __pyx_L1_error)
  if (__pyx_t_3) {

    /* "cupy/core/reduction.pxi":379
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)             # <<<<<<<<<<<<<<
 * 
 *         n_args = len(args)
 */
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_arguments_s, __pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 379, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 379, __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_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 379, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(5, 379, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":378
 *         keepdims = kwargs.pop('keepdims', False)
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  }

  /* "cupy/core/reduction.pxi":381
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 *         n_args = len(args)             # <<<<<<<<<<<<<<
 *         if n_args != self.nin and n_args != self.nargs:
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 */
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(5, 381, __pyx_L1_error)
  __pyx_v_n_args = __pyx_t_4;

  /* "cupy/core/reduction.pxi":382
 * 
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 * 
 */
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_n_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 382, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(5, 382, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_6) {
  } else {
    __pyx_t_3 = __pyx_t_6;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_n_args); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_5, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 382, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(5, 382, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_t_6;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_3) {

    /* "cupy/core/reduction.pxi":383
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:
 *             raise TypeError('Wrong number of arguments for %s' % self.name)             # <<<<<<<<<<<<<<
 * 
 *         out_args = list(args[self.nin:])
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 383, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_number_of_arguments_for_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 383, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 383, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 383, __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(5, 383, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":382
 * 
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 * 
 */
  }

  /* "cupy/core/reduction.pxi":385
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 * 
 *         out_args = list(args[self.nin:])             # <<<<<<<<<<<<<<
 *         if out is not None:
 *             if self.nout != 1:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 385, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyTuple_GetSlice(__pyx_v_args, __pyx_t_4, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PySequence_List(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_out_args = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":386
 * 
 *         out_args = list(args[self.nin:])
 *         if out is not None:             # <<<<<<<<<<<<<<
 *             if self.nout != 1:
 *                 raise NotImplementedError('')
 */
  __pyx_t_3 = (__pyx_v_out != Py_None);
  __pyx_t_6 = (__pyx_t_3 != 0);
  if (__pyx_t_6) {

    /* "cupy/core/reduction.pxi":387
 *         out_args = list(args[self.nin:])
 *         if out is not None:
 *             if self.nout != 1:             # <<<<<<<<<<<<<<
 *                 raise NotImplementedError('')
 *             if len(out_args) != 0:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nout); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_1, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 387, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(5, 387, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_6) {

      /* "cupy/core/reduction.pxi":388
 *         if out is not None:
 *             if self.nout != 1:
 *                 raise NotImplementedError('')             # <<<<<<<<<<<<<<
 *             if len(out_args) != 0:
 *                 raise ValueError("cannot specify 'out' as both "
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__105, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 388, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(5, 388, __pyx_L1_error)

      /* "cupy/core/reduction.pxi":387
 *         out_args = list(args[self.nin:])
 *         if out is not None:
 *             if self.nout != 1:             # <<<<<<<<<<<<<<
 *                 raise NotImplementedError('')
 *             if len(out_args) != 0:
 */
    }

    /* "cupy/core/reduction.pxi":389
 *             if self.nout != 1:
 *                 raise NotImplementedError('')
 *             if len(out_args) != 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError("cannot specify 'out' as both "
 *                                  "a positional and keyword argument")
 */
    __pyx_t_4 = PyList_GET_SIZE(__pyx_v_out_args); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(5, 389, __pyx_L1_error)
    __pyx_t_6 = ((__pyx_t_4 != 0) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/reduction.pxi":390
 *                 raise NotImplementedError('')
 *             if len(out_args) != 0:
 *                 raise ValueError("cannot specify 'out' as both "             # <<<<<<<<<<<<<<
 *                                  "a positional and keyword argument")
 *             out_args = [out]
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__106, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 390, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(5, 390, __pyx_L1_error)

      /* "cupy/core/reduction.pxi":389
 *             if self.nout != 1:
 *                 raise NotImplementedError('')
 *             if len(out_args) != 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError("cannot specify 'out' as both "
 *                                  "a positional and keyword argument")
 */
    }

    /* "cupy/core/reduction.pxi":392
 *                 raise ValueError("cannot specify 'out' as both "
 *                                  "a positional and keyword argument")
 *             out_args = [out]             # <<<<<<<<<<<<<<
 * 
 *         in_args = _preprocess_args(args[:self.nin])
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 392, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_out);
    __Pyx_GIVEREF(__pyx_v_out);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_v_out);
    __Pyx_DECREF_SET(__pyx_v_out_args, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":386
 * 
 *         out_args = list(args[self.nin:])
 *         if out is not None:             # <<<<<<<<<<<<<<
 *             if self.nout != 1:
 *                 raise NotImplementedError('')
 */
  }

  /* "cupy/core/reduction.pxi":394
 *             out_args = [out]
 * 
 *         in_args = _preprocess_args(args[:self.nin])             # <<<<<<<<<<<<<<
 *         out_args = _preprocess_args(out_args)
 *         in_args, broad_shape = _broadcast(in_args, self.in_params, False)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 394, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyTuple_GetSlice(__pyx_v_args, 0, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_in_args = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":395
 * 
 *         in_args = _preprocess_args(args[:self.nin])
 *         out_args = _preprocess_args(out_args)             # <<<<<<<<<<<<<<
 *         in_args, broad_shape = _broadcast(in_args, self.in_params, False)
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_v_out_args, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 395, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_out_args, ((PyObject*)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":396
 *         in_args = _preprocess_args(args[:self.nin])
 *         out_args = _preprocess_args(out_args)
 *         in_args, broad_shape = _broadcast(in_args, self.in_params, False)             # <<<<<<<<<<<<<<
 * 
 *         if self.identity is None and 0 in broad_shape:
 */
  if (!(likely(PyList_CheckExact(__pyx_v_in_args))||((__pyx_v_in_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_in_args)->tp_name), 0))) __PYX_ERR(5, 396, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(5, 396, __pyx_L1_error)
  __pyx_t_2 = __pyx_f_4cupy_4core_4core__broadcast(((PyObject*)__pyx_v_in_args), ((PyObject*)__pyx_t_1), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_2 != Py_None)) {
    PyObject* sequence = __pyx_t_2;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(5, 396, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 396, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 396, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(5, 396, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_in_args, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_broad_shape = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":398
 *         in_args, broad_shape = _broadcast(in_args, self.in_params, False)
 * 
 *         if self.identity is None and 0 in broad_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_identity); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = (__pyx_t_2 == Py_None);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_7 = (__pyx_t_3 != 0);
  if (__pyx_t_7) {
  } else {
    __pyx_t_6 = __pyx_t_7;
    goto __pyx_L11_bool_binop_done;
  }
  __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_int_0, __pyx_v_broad_shape, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(5, 398, __pyx_L1_error)
  __pyx_t_3 = (__pyx_t_7 != 0);
  __pyx_t_6 = __pyx_t_3;
  __pyx_L11_bool_binop_done:;
  if (__pyx_t_6) {

    /* "cupy/core/reduction.pxi":400
 *         if self.identity is None and 0 in broad_shape:
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)             # <<<<<<<<<<<<<<
 * 
 *         in_ndarray_types = tuple(
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 400, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_zero_size_array_to_reduction_ope, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 400, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":399
 * 
 *         if self.identity is None and 0 in broad_shape:
 *             raise ValueError(('zero-size array to reduction operation'             # <<<<<<<<<<<<<<
 *                               ' %s which has no identity') % self.name)
 * 
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 399, __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 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(5, 399, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":398
 *         in_args, broad_shape = _broadcast(in_args, self.in_params, False)
 * 
 *         if self.identity is None and 0 in broad_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)
 */
  }

  /* "cupy/core/reduction.pxi":403
 * 
 *         in_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None             # <<<<<<<<<<<<<<
 *              for a in in_args])
 *         out_ndarray_types = tuple(
 */
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/reduction.pxi":404
 *         in_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in in_args])             # <<<<<<<<<<<<<<
 *         out_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None
 */
  if (likely(PyList_CheckExact(__pyx_v_in_args)) || PyTuple_CheckExact(__pyx_v_in_args)) {
    __pyx_t_2 = __pyx_v_in_args; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_in_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 404, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 404, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 404, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 404, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 404, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 404, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_8(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(5, 404, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/reduction.pxi":403
 * 
 *         in_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None             # <<<<<<<<<<<<<<
 *              for a in in_args])
 *         out_ndarray_types = tuple(
 */
    __pyx_t_6 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
    if ((__pyx_t_6 != 0)) {
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 403, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_type); if (unlikely(!__pyx_t_10)) __PYX_ERR(5, 403, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_1 = __pyx_t_10;
      __pyx_t_10 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_t_1 = Py_None;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_1))) __PYX_ERR(5, 403, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/reduction.pxi":404
 *         in_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in in_args])             # <<<<<<<<<<<<<<
 *         out_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":402
 *                               ' %s which has no identity') % self.name)
 * 
 *         in_ndarray_types = tuple(             # <<<<<<<<<<<<<<
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in in_args])
 */
  __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_5)); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_in_ndarray_types = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":406
 *              for a in in_args])
 *         out_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None             # <<<<<<<<<<<<<<
 *              for a in out_args])
 *         in_types, out_types, types = _decide_params_type(
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/reduction.pxi":407
 *         out_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in out_args])             # <<<<<<<<<<<<<<
 *         in_types, out_types, types = _decide_params_type(
 *             self.in_params, self.out_params,
 */
  if (unlikely(__pyx_v_out_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(5, 407, __pyx_L1_error)
  }
  __pyx_t_5 = __pyx_v_out_args; __Pyx_INCREF(__pyx_t_5); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_5)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 407, __pyx_L1_error)
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/reduction.pxi":406
 *              for a in in_args])
 *         out_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None             # <<<<<<<<<<<<<<
 *              for a in out_args])
 *         in_types, out_types, types = _decide_params_type(
 */
    __pyx_t_6 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
    if ((__pyx_t_6 != 0)) {
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_10)) __PYX_ERR(5, 406, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 406, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_1 = __pyx_t_9;
      __pyx_t_9 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_t_1 = Py_None;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_1))) __PYX_ERR(5, 406, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/reduction.pxi":407
 *         out_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in out_args])             # <<<<<<<<<<<<<<
 *         in_types, out_types, types = _decide_params_type(
 *             self.in_params, self.out_params,
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":405
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in in_args])
 *         out_ndarray_types = tuple(             # <<<<<<<<<<<<<<
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in out_args])
 */
  __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 405, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_out_ndarray_types = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":408
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in out_args])
 *         in_types, out_types, types = _decide_params_type(             # <<<<<<<<<<<<<<
 *             self.in_params, self.out_params,
 *             in_ndarray_types, out_ndarray_types)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_decide_params_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/reduction.pxi":409
 *              for a in out_args])
 *         in_types, out_types, types = _decide_params_type(
 *             self.in_params, self.out_params,             # <<<<<<<<<<<<<<
 *             in_ndarray_types, out_ndarray_types)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_out_params); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "cupy/core/reduction.pxi":410
 *         in_types, out_types, types = _decide_params_type(
 *             self.in_params, self.out_params,
 *             in_ndarray_types, out_ndarray_types)             # <<<<<<<<<<<<<<
 * 
 *         axis, raxis = _get_axis(axis, len(broad_shape))
 */
  __pyx_t_10 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_1, __pyx_t_9, __pyx_v_in_ndarray_types, __pyx_v_out_ndarray_types};
    __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 408, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_1, __pyx_t_9, __pyx_v_in_ndarray_types, __pyx_v_out_ndarray_types};
    __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 408, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  {
    __pyx_t_12 = PyTuple_New(4+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_9);
    __Pyx_INCREF(__pyx_v_in_ndarray_types);
    __Pyx_GIVEREF(__pyx_v_in_ndarray_types);
    PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_v_in_ndarray_types);
    __Pyx_INCREF(__pyx_v_out_ndarray_types);
    __Pyx_GIVEREF(__pyx_v_out_ndarray_types);
    PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_11, __pyx_v_out_ndarray_types);
    __pyx_t_1 = 0;
    __pyx_t_9 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
    PyObject* sequence = __pyx_t_5;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(5, 408, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_12 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_9 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_12);
    __Pyx_INCREF(__pyx_t_9);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_9 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_1 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_13 = Py_TYPE(__pyx_t_1)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_13(__pyx_t_1); if (unlikely(!__pyx_t_2)) goto __pyx_L17_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_12 = __pyx_t_13(__pyx_t_1); if (unlikely(!__pyx_t_12)) goto __pyx_L17_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_12);
    index = 2; __pyx_t_9 = __pyx_t_13(__pyx_t_1); if (unlikely(!__pyx_t_9)) goto __pyx_L17_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_9);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_1), 3) < 0) __PYX_ERR(5, 408, __pyx_L1_error)
    __pyx_t_13 = NULL;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L18_unpacking_done;
    __pyx_L17_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_13 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(5, 408, __pyx_L1_error)
    __pyx_L18_unpacking_done:;
  }

  /* "cupy/core/reduction.pxi":408
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in out_args])
 *         in_types, out_types, types = _decide_params_type(             # <<<<<<<<<<<<<<
 *             self.in_params, self.out_params,
 *             in_ndarray_types, out_ndarray_types)
 */
  __pyx_v_in_types = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_out_types = __pyx_t_12;
  __pyx_t_12 = 0;
  __pyx_v_types = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":412
 *             in_ndarray_types, out_ndarray_types)
 * 
 *         axis, raxis = _get_axis(axis, len(broad_shape))             # <<<<<<<<<<<<<<
 *         out_shape = _get_out_shape(broad_shape, axis, raxis, keepdims)
 *         out_args = _get_out_args_with_params(
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_broad_shape); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(5, 412, __pyx_L1_error)
  __pyx_t_5 = __pyx_f_4cupy_4core_4core__get_axis(__pyx_v_axis, __pyx_t_4, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (likely(__pyx_t_5 != Py_None)) {
    PyObject* sequence = __pyx_t_5;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(5, 412, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_t_12);
    #else
    __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(5, 412, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_9);
  __pyx_t_9 = 0;
  __pyx_v_raxis = __pyx_t_12;
  __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":413
 * 
 *         axis, raxis = _get_axis(axis, len(broad_shape))
 *         out_shape = _get_out_shape(broad_shape, axis, raxis, keepdims)             # <<<<<<<<<<<<<<
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, out_shape, self.out_params, False)
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_broad_shape))||((__pyx_v_broad_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_broad_shape)->tp_name), 0))) __PYX_ERR(5, 413, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_axis))||((__pyx_v_axis) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_axis)->tp_name), 0))) __PYX_ERR(5, 413, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_raxis))||((__pyx_v_raxis) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_raxis)->tp_name), 0))) __PYX_ERR(5, 413, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_keepdims); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 413, __pyx_L1_error)
  __pyx_t_5 = __pyx_f_4cupy_4core_4core__get_out_shape(((PyObject*)__pyx_v_broad_shape), ((PyObject*)__pyx_v_axis), ((PyObject*)__pyx_v_raxis), __pyx_t_6, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_out_shape = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":415
 *         out_shape = _get_out_shape(broad_shape, axis, raxis, keepdims)
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, out_shape, self.out_params, False)             # <<<<<<<<<<<<<<
 *         if 0 in out_shape:
 *             return out_args[0]
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_out_types))||((__pyx_v_out_types) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_out_types)->tp_name), 0))) __PYX_ERR(5, 415, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_out_params); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (!(likely(PyTuple_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(5, 415, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":414
 *         axis, raxis = _get_axis(axis, len(broad_shape))
 *         out_shape = _get_out_shape(broad_shape, axis, raxis, keepdims)
 *         out_args = _get_out_args_with_params(             # <<<<<<<<<<<<<<
 *             out_args, out_types, out_shape, self.out_params, False)
 *         if 0 in out_shape:
 */
  __pyx_t_14.__pyx_n = 1;
  __pyx_t_14.is_size_specified = 0;
  __pyx_t_12 = __pyx_f_4cupy_4core_4core__get_out_args_with_params(__pyx_v_out_args, ((PyObject*)__pyx_v_out_types), __pyx_v_out_shape, ((PyObject*)__pyx_t_5), &__pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF_SET(__pyx_v_out_args, ((PyObject*)__pyx_t_12));
  __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":416
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, out_shape, self.out_params, False)
 *         if 0 in out_shape:             # <<<<<<<<<<<<<<
 *             return out_args[0]
 * 
 */
  __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_int_0, __pyx_v_out_shape, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(5, 416, __pyx_L1_error)
  __pyx_t_3 = (__pyx_t_6 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/reduction.pxi":417
 *             out_args, out_types, out_shape, self.out_params, False)
 *         if 0 in out_shape:
 *             return out_args[0]             # <<<<<<<<<<<<<<
 * 
 *         in_args = [x if isinstance(x, ndarray) else t(x)
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(5, 417, __pyx_L1_error)
    }
    __pyx_t_12 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_r = __pyx_t_12;
    __pyx_t_12 = 0;
    goto __pyx_L0;

    /* "cupy/core/reduction.pxi":416
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, out_shape, self.out_params, False)
 *         if 0 in out_shape:             # <<<<<<<<<<<<<<
 *             return out_args[0]
 * 
 */
  }

  /* "cupy/core/reduction.pxi":419
 *             return out_args[0]
 * 
 *         in_args = [x if isinstance(x, ndarray) else t(x)             # <<<<<<<<<<<<<<
 *                    for x, t in zip(in_args, in_types)]
 *         in_args, in_shape = _get_trans_args(
 */
  __pyx_t_12 = PyList_New(0); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/reduction.pxi":420
 * 
 *         in_args = [x if isinstance(x, ndarray) else t(x)
 *                    for x, t in zip(in_args, in_types)]             # <<<<<<<<<<<<<<
 *         in_args, in_shape = _get_trans_args(
 *             in_args, axis + raxis, broad_shape, self.in_params)
 */
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_in_args);
  __Pyx_GIVEREF(__pyx_v_in_args);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_in_args);
  __Pyx_INCREF(__pyx_v_in_types);
  __Pyx_GIVEREF(__pyx_v_in_types);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_in_types);
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_t_9)) || PyTuple_CheckExact(__pyx_t_9)) {
    __pyx_t_5 = __pyx_t_9; __Pyx_INCREF(__pyx_t_5); __pyx_t_4 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 420, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 420, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_4 >= 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_4); __Pyx_INCREF(__pyx_t_9); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 420, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 420, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_9); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 420, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 420, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      }
    } else {
      __pyx_t_9 = __pyx_t_8(__pyx_t_5);
      if (unlikely(!__pyx_t_9)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(5, 420, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_9);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) {
      PyObject* sequence = __pyx_t_9;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(5, 420, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      #else
      __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_10 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(5, 420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_13 = Py_TYPE(__pyx_t_10)->tp_iternext;
      index = 0; __pyx_t_2 = __pyx_t_13(__pyx_t_10); if (unlikely(!__pyx_t_2)) goto __pyx_L22_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      index = 1; __pyx_t_1 = __pyx_t_13(__pyx_t_10); if (unlikely(!__pyx_t_1)) goto __pyx_L22_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_10), 2) < 0) __PYX_ERR(5, 420, __pyx_L1_error)
      __pyx_t_13 = NULL;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L23_unpacking_done;
      __pyx_L22_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_13 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(5, 420, __pyx_L1_error)
      __pyx_L23_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/reduction.pxi":419
 *             return out_args[0]
 * 
 *         in_args = [x if isinstance(x, ndarray) else t(x)             # <<<<<<<<<<<<<<
 *                    for x, t in zip(in_args, in_types)]
 *         in_args, in_shape = _get_trans_args(
 */
    __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_x, __pyx_ptype_4cupy_4core_4core_ndarray); 
    if ((__pyx_t_3 != 0)) {
      __Pyx_INCREF(__pyx_v_x);
      __pyx_t_9 = __pyx_v_x;
    } else {
      __Pyx_INCREF(__pyx_v_t);
      __pyx_t_2 = __pyx_v_t; __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 419, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_x};
          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 419, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_x};
          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 419, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else
        #endif
        {
          __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 419, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_INCREF(__pyx_v_x);
          __Pyx_GIVEREF(__pyx_v_x);
          PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_v_x);
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 419, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_9 = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_12, (PyObject*)__pyx_t_9))) __PYX_ERR(5, 419, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "cupy/core/reduction.pxi":420
 * 
 *         in_args = [x if isinstance(x, ndarray) else t(x)
 *                    for x, t in zip(in_args, in_types)]             # <<<<<<<<<<<<<<
 *         in_args, in_shape = _get_trans_args(
 *             in_args, axis + raxis, broad_shape, self.in_params)
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF_SET(__pyx_v_in_args, __pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":422
 *                    for x, t in zip(in_args, in_types)]
 *         in_args, in_shape = _get_trans_args(
 *             in_args, axis + raxis, broad_shape, self.in_params)             # <<<<<<<<<<<<<<
 * 
 *         block_size = 512
 */
  if (!(likely(PyList_CheckExact(__pyx_v_in_args))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_in_args)->tp_name), 0))) __PYX_ERR(5, 422, __pyx_L1_error)
  __pyx_t_12 = PyNumber_Add(__pyx_v_axis, __pyx_v_raxis); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (!(likely(PyTuple_CheckExact(__pyx_t_12))||((__pyx_t_12) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_12)->tp_name), 0))) __PYX_ERR(5, 422, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_broad_shape))||((__pyx_v_broad_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_broad_shape)->tp_name), 0))) __PYX_ERR(5, 422, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_params); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (!(likely(PyTuple_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(5, 422, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":421
 *         in_args = [x if isinstance(x, ndarray) else t(x)
 *                    for x, t in zip(in_args, in_types)]
 *         in_args, in_shape = _get_trans_args(             # <<<<<<<<<<<<<<
 *             in_args, axis + raxis, broad_shape, self.in_params)
 * 
 */
  __pyx_t_9 = __pyx_f_4cupy_4core_4core__get_trans_args(((PyObject*)__pyx_v_in_args), ((PyObject*)__pyx_t_12), ((PyObject*)__pyx_v_broad_shape), ((PyObject*)__pyx_t_5), 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(__pyx_t_9 != Py_None)) {
    PyObject* sequence = __pyx_t_9;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(5, 421, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_12);
    #else
    __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    #endif
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(5, 421, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_in_args, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_v_in_shape = __pyx_t_12;
  __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":424
 *             in_args, axis + raxis, broad_shape, self.in_params)
 * 
 *         block_size = 512             # <<<<<<<<<<<<<<
 *         in_indexer = Indexer(in_shape)
 *         out_indexer = Indexer(out_shape)
 */
  __Pyx_INCREF(__pyx_int_512);
  __pyx_v_block_size = __pyx_int_512;

  /* "cupy/core/reduction.pxi":425
 * 
 *         block_size = 512
 *         in_indexer = Indexer(in_shape)             # <<<<<<<<<<<<<<
 *         out_indexer = Indexer(out_shape)
 *         # Rounding Up to the Next Power of 2
 */
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_v_in_shape);
  __Pyx_GIVEREF(__pyx_v_in_shape);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_in_shape);
  __pyx_t_12 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_t_9, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_in_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":426
 *         block_size = 512
 *         in_indexer = Indexer(in_shape)
 *         out_indexer = Indexer(out_shape)             # <<<<<<<<<<<<<<
 *         # Rounding Up to the Next Power of 2
 *         # clp2_count >= in_indexer.size // out_indexer.size
 */
  __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_INCREF(__pyx_v_out_shape);
  __Pyx_GIVEREF(__pyx_v_out_shape);
  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_out_shape);
  __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_t_12, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_v_out_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":429
 *         # Rounding Up to the Next Power of 2
 *         # clp2_count >= in_indexer.size // out_indexer.size
 *         clp2_count = 1 << int.bit_length(             # <<<<<<<<<<<<<<
 *             int(in_indexer.size // out_indexer.size - 1))
 *         block_stride = max(1, block_size // clp2_count)
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyInt_Type)), __pyx_n_s_bit_length); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/reduction.pxi":430
 *         # clp2_count >= in_indexer.size // out_indexer.size
 *         clp2_count = 1 << int.bit_length(
 *             int(in_indexer.size // out_indexer.size - 1))             # <<<<<<<<<<<<<<
 *         block_stride = max(1, block_size // clp2_count)
 * 
 */
  if (unlikely(__pyx_v_out_indexer->size == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(5, 430, __pyx_L1_error)
  }
  else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_out_indexer->size == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_in_indexer->size))) {
    PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
    __PYX_ERR(5, 430, __pyx_L1_error)
  }
  __pyx_t_5 = PyInt_FromSsize_t((__Pyx_div_Py_ssize_t(__pyx_v_in_indexer->size, __pyx_v_out_indexer->size) - 1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 429, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_5};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 429, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_5};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 429, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 429, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_2, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 429, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":429
 *         # Rounding Up to the Next Power of 2
 *         # clp2_count >= in_indexer.size // out_indexer.size
 *         clp2_count = 1 << int.bit_length(             # <<<<<<<<<<<<<<
 *             int(in_indexer.size // out_indexer.size - 1))
 *         block_stride = max(1, block_size // clp2_count)
 */
  __pyx_t_12 = PyNumber_Lshift(__pyx_int_1, __pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_clp2_count = __pyx_t_12;
  __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":431
 *         clp2_count = 1 << int.bit_length(
 *             int(in_indexer.size // out_indexer.size - 1))
 *         block_stride = max(1, block_size // clp2_count)             # <<<<<<<<<<<<<<
 * 
 *         inout_args = _get_inout_args(
 */
  __pyx_t_12 = PyNumber_FloorDivide(__pyx_v_block_size, __pyx_v_clp2_count); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_16 = 1;
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_t_16); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_12, __pyx_t_2, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 431, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(5, 431, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_3) {
    __Pyx_INCREF(__pyx_t_12);
    __pyx_t_9 = __pyx_t_12;
  } else {
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_t_16); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 431, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = __pyx_t_5;
    __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = __pyx_t_9;
  __Pyx_INCREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_block_stride = __pyx_t_12;
  __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":434
 * 
 *         inout_args = _get_inout_args(
 *             in_args, out_args, in_indexer, out_indexer, block_stride,             # <<<<<<<<<<<<<<
 *             self.params, self.reduce_dims)
 *         args_info = _get_args_info(inout_args)
 */
  if (!(likely(PyList_CheckExact(__pyx_v_in_args))||((__pyx_v_in_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_in_args)->tp_name), 0))) __PYX_ERR(5, 434, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":435
 *         inout_args = _get_inout_args(
 *             in_args, out_args, in_indexer, out_indexer, block_stride,
 *             self.params, self.reduce_dims)             # <<<<<<<<<<<<<<
 *         args_info = _get_args_info(inout_args)
 * 
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 435, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (!(likely(PyTuple_CheckExact(__pyx_t_12))||((__pyx_t_12) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_12)->tp_name), 0))) __PYX_ERR(5, 435, __pyx_L1_error)
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reduce_dims); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 435, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 435, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":433
 *         block_stride = max(1, block_size // clp2_count)
 * 
 *         inout_args = _get_inout_args(             # <<<<<<<<<<<<<<
 *             in_args, out_args, in_indexer, out_indexer, block_stride,
 *             self.params, self.reduce_dims)
 */
  __pyx_t_9 = __pyx_f_4cupy_4core_4core__get_inout_args(((PyObject*)__pyx_v_in_args), __pyx_v_out_args, __pyx_v_in_indexer, __pyx_v_out_indexer, __pyx_v_block_stride, ((PyObject*)__pyx_t_12), __pyx_t_3, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_v_inout_args = ((PyObject*)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":436
 *             in_args, out_args, in_indexer, out_indexer, block_stride,
 *             self.params, self.reduce_dims)
 *         args_info = _get_args_info(inout_args)             # <<<<<<<<<<<<<<
 * 
 *         kern = _get_reduction_kernel(
 */
  __pyx_t_9 = __pyx_f_4cupy_4core_4core__get_args_info(__pyx_v_inout_args, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 436, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_v_args_info = ((PyObject*)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":438
 *         args_info = _get_args_info(inout_args)
 * 
 *         kern = _get_reduction_kernel(             # <<<<<<<<<<<<<<
 *             self.params, args_info, types,
 *             self.name, block_size, self.reduce_type, self.identity,
 */
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_reduction_kernel); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/reduction.pxi":439
 * 
 *         kern = _get_reduction_kernel(
 *             self.params, args_info, types,             # <<<<<<<<<<<<<<
 *             self.name, block_size, self.reduce_type, self.identity,
 *             self.map_expr, self.reduce_expr, self.post_map_expr,
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/reduction.pxi":440
 *         kern = _get_reduction_kernel(
 *             self.params, args_info, types,
 *             self.name, block_size, self.reduce_type, self.identity,             # <<<<<<<<<<<<<<
 *             self.map_expr, self.reduce_expr, self.post_map_expr,
 *             self.preamble, self.options)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reduce_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_identity); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);

  /* "cupy/core/reduction.pxi":441
 *             self.params, args_info, types,
 *             self.name, block_size, self.reduce_type, self.identity,
 *             self.map_expr, self.reduce_expr, self.post_map_expr,             # <<<<<<<<<<<<<<
 *             self.preamble, self.options)
 * 
 */
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_map_expr); if (unlikely(!__pyx_t_10)) __PYX_ERR(5, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reduce_expr); if (unlikely(!__pyx_t_17)) __PYX_ERR(5, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_post_map_expr); if (unlikely(!__pyx_t_18)) __PYX_ERR(5, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);

  /* "cupy/core/reduction.pxi":442
 *             self.name, block_size, self.reduce_type, self.identity,
 *             self.map_expr, self.reduce_expr, self.post_map_expr,
 *             self.preamble, self.options)             # <<<<<<<<<<<<<<
 * 
 *         # TODO(okuta) set actual size
 */
  __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_preamble); if (unlikely(!__pyx_t_19)) __PYX_ERR(5, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_options); if (unlikely(!__pyx_t_20)) __PYX_ERR(5, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __pyx_t_21 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_21)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_21);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_12)) {
    PyObject *__pyx_temp[13] = {__pyx_t_21, __pyx_t_5, __pyx_v_args_info, __pyx_v_types, __pyx_t_2, __pyx_v_block_size, __pyx_t_1, __pyx_t_15, __pyx_t_10, __pyx_t_17, __pyx_t_18, __pyx_t_19, __pyx_t_20};
    __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_11, 12+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 438, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
    PyObject *__pyx_temp[13] = {__pyx_t_21, __pyx_t_5, __pyx_v_args_info, __pyx_v_types, __pyx_t_2, __pyx_v_block_size, __pyx_t_1, __pyx_t_15, __pyx_t_10, __pyx_t_17, __pyx_t_18, __pyx_t_19, __pyx_t_20};
    __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_11, 12+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 438, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  } else
  #endif
  {
    __pyx_t_22 = PyTuple_New(12+__pyx_t_11); if (unlikely(!__pyx_t_22)) __PYX_ERR(5, 438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    if (__pyx_t_21) {
      __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_21); __pyx_t_21 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_22, 0+__pyx_t_11, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_args_info);
    __Pyx_GIVEREF(__pyx_v_args_info);
    PyTuple_SET_ITEM(__pyx_t_22, 1+__pyx_t_11, __pyx_v_args_info);
    __Pyx_INCREF(__pyx_v_types);
    __Pyx_GIVEREF(__pyx_v_types);
    PyTuple_SET_ITEM(__pyx_t_22, 2+__pyx_t_11, __pyx_v_types);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_22, 3+__pyx_t_11, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_block_size);
    __Pyx_GIVEREF(__pyx_v_block_size);
    PyTuple_SET_ITEM(__pyx_t_22, 4+__pyx_t_11, __pyx_v_block_size);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_22, 5+__pyx_t_11, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_15);
    PyTuple_SET_ITEM(__pyx_t_22, 6+__pyx_t_11, __pyx_t_15);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_22, 7+__pyx_t_11, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_17);
    PyTuple_SET_ITEM(__pyx_t_22, 8+__pyx_t_11, __pyx_t_17);
    __Pyx_GIVEREF(__pyx_t_18);
    PyTuple_SET_ITEM(__pyx_t_22, 9+__pyx_t_11, __pyx_t_18);
    __Pyx_GIVEREF(__pyx_t_19);
    PyTuple_SET_ITEM(__pyx_t_22, 10+__pyx_t_11, __pyx_t_19);
    __Pyx_GIVEREF(__pyx_t_20);
    PyTuple_SET_ITEM(__pyx_t_22, 11+__pyx_t_11, __pyx_t_20);
    __pyx_t_5 = 0;
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_15 = 0;
    __pyx_t_10 = 0;
    __pyx_t_17 = 0;
    __pyx_t_18 = 0;
    __pyx_t_19 = 0;
    __pyx_t_20 = 0;
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_22, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_v_kern = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":445
 * 
 *         # TODO(okuta) set actual size
 *         shared_mem = 32 * block_size             # <<<<<<<<<<<<<<
 * 
 *         kern.linear_launch(
 */
  __pyx_t_9 = PyNumber_Multiply(__pyx_int_32, __pyx_v_block_size); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_v_shared_mem = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":447
 *         shared_mem = 32 * block_size
 * 
 *         kern.linear_launch(             # <<<<<<<<<<<<<<
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,
 *             inout_args, shared_mem, block_size, stream)
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_kern, __pyx_n_s_linear_launch); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/reduction.pxi":448
 * 
 *         kern.linear_launch(
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,             # <<<<<<<<<<<<<<
 *             inout_args, shared_mem, block_size, stream)
 *         return out_args[0]
 */
  __pyx_t_22 = PyInt_FromSsize_t(__pyx_v_out_indexer->size); if (unlikely(!__pyx_t_22)) __PYX_ERR(5, 448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __pyx_t_20 = PyNumber_Add(__pyx_t_22, __pyx_v_block_stride); if (unlikely(!__pyx_t_20)) __PYX_ERR(5, 448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  __pyx_t_22 = __Pyx_PyInt_SubtractObjC(__pyx_t_20, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_22)) __PYX_ERR(5, 448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  __pyx_t_20 = PyNumber_FloorDivide(__pyx_t_22, __pyx_v_block_stride); if (unlikely(!__pyx_t_20)) __PYX_ERR(5, 448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  __pyx_t_22 = PyNumber_Multiply(__pyx_t_20, __pyx_v_block_size); if (unlikely(!__pyx_t_22)) __PYX_ERR(5, 448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;

  /* "cupy/core/reduction.pxi":449
 *         kern.linear_launch(
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,
 *             inout_args, shared_mem, block_size, stream)             # <<<<<<<<<<<<<<
 *         return out_args[0]
 * 
 */
  __pyx_t_20 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_20)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_20);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_12)) {
    PyObject *__pyx_temp[6] = {__pyx_t_20, __pyx_t_22, __pyx_v_inout_args, __pyx_v_shared_mem, __pyx_v_block_size, __pyx_v_stream};
    __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 447, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
    PyObject *__pyx_temp[6] = {__pyx_t_20, __pyx_t_22, __pyx_v_inout_args, __pyx_v_shared_mem, __pyx_v_block_size, __pyx_v_stream};
    __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 447, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  } else
  #endif
  {
    __pyx_t_19 = PyTuple_New(5+__pyx_t_11); if (unlikely(!__pyx_t_19)) __PYX_ERR(5, 447, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    if (__pyx_t_20) {
      __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_20); __pyx_t_20 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_22);
    PyTuple_SET_ITEM(__pyx_t_19, 0+__pyx_t_11, __pyx_t_22);
    __Pyx_INCREF(__pyx_v_inout_args);
    __Pyx_GIVEREF(__pyx_v_inout_args);
    PyTuple_SET_ITEM(__pyx_t_19, 1+__pyx_t_11, __pyx_v_inout_args);
    __Pyx_INCREF(__pyx_v_shared_mem);
    __Pyx_GIVEREF(__pyx_v_shared_mem);
    PyTuple_SET_ITEM(__pyx_t_19, 2+__pyx_t_11, __pyx_v_shared_mem);
    __Pyx_INCREF(__pyx_v_block_size);
    __Pyx_GIVEREF(__pyx_v_block_size);
    PyTuple_SET_ITEM(__pyx_t_19, 3+__pyx_t_11, __pyx_v_block_size);
    __Pyx_INCREF(__pyx_v_stream);
    __Pyx_GIVEREF(__pyx_v_stream);
    PyTuple_SET_ITEM(__pyx_t_19, 4+__pyx_t_11, __pyx_v_stream);
    __pyx_t_22 = 0;
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_19, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 447, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":450
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,
 *             inout_args, shared_mem, block_size, stream)
 *         return out_args[0]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_out_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(5, 450, __pyx_L1_error)
  }
  __pyx_t_9 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 450, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_r = __pyx_t_9;
  __pyx_t_9 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":357
 *         self.preamble = preamble
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Compiles and invokes the reduction kernel.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_AddTraceback("cupy.core.core.ReductionKernel.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_out);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XDECREF(__pyx_v_keepdims);
  __Pyx_XDECREF(__pyx_v_stream);
  __Pyx_XDECREF(__pyx_v_out_args);
  __Pyx_XDECREF(__pyx_v_in_args);
  __Pyx_XDECREF(__pyx_v_broad_shape);
  __Pyx_XDECREF(__pyx_v_in_ndarray_types);
  __Pyx_XDECREF(__pyx_v_out_ndarray_types);
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XDECREF(__pyx_v_types);
  __Pyx_XDECREF(__pyx_v_raxis);
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XDECREF(__pyx_v_in_shape);
  __Pyx_XDECREF(__pyx_v_block_size);
  __Pyx_XDECREF((PyObject *)__pyx_v_in_indexer);
  __Pyx_XDECREF((PyObject *)__pyx_v_out_indexer);
  __Pyx_XDECREF(__pyx_v_clp2_count);
  __Pyx_XDECREF(__pyx_v_block_stride);
  __Pyx_XDECREF(__pyx_v_inout_args);
  __Pyx_XDECREF(__pyx_v_args_info);
  __Pyx_XDECREF(__pyx_v_kern);
  __Pyx_XDECREF(__pyx_v_shared_mem);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":453
 * 
 * 
 * cpdef create_reduction_func(name, ops, routine=None, identity=None,             # <<<<<<<<<<<<<<
 *                             preamble=''):
 *     _ops = []
 */

static PyObject *__pyx_pw_4cupy_4core_4core_49create_reduction_func(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_create_reduction_func(PyObject *__pyx_v_name, PyObject *__pyx_v_ops, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_create_reduction_func *__pyx_optional_args) {
  PyObject *__pyx_v_routine = ((PyObject *)Py_None);
  PyObject *__pyx_v_identity = ((PyObject *)Py_None);
  PyObject *__pyx_v_preamble = ((PyObject *)__pyx_kp_s__5);
  PyObject *__pyx_v__ops = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_typ = NULL;
  PyObject *__pyx_v_rt = NULL;
  PyObject *__pyx_v_types = NULL;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_j = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  int __pyx_t_16;
  __Pyx_RefNannySetupContext("create_reduction_func", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_routine = __pyx_optional_args->routine;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_identity = __pyx_optional_args->identity;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_preamble = __pyx_optional_args->preamble;
        }
      }
    }
  }

  /* "cupy/core/reduction.pxi":455
 * cpdef create_reduction_func(name, ops, routine=None, identity=None,
 *                             preamble=''):
 *     _ops = []             # <<<<<<<<<<<<<<
 *     for t in ops:
 *         if not isinstance(t, tuple):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__ops = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":456
 *                             preamble=''):
 *     _ops = []
 *     for t in ops:             # <<<<<<<<<<<<<<
 *         if not isinstance(t, tuple):
 *             typ = t
 */
  if (likely(PyList_CheckExact(__pyx_v_ops)) || PyTuple_CheckExact(__pyx_v_ops)) {
    __pyx_t_1 = __pyx_v_ops; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_ops); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 456, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(5, 456, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 456, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(5, 456, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 456, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(5, 456, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":457
 *     _ops = []
 *     for t in ops:
 *         if not isinstance(t, tuple):             # <<<<<<<<<<<<<<
 *             typ = t
 *             rt = routine
 */
    __pyx_t_5 = PyTuple_Check(__pyx_v_t); 
    __pyx_t_6 = ((!(__pyx_t_5 != 0)) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/reduction.pxi":458
 *     for t in ops:
 *         if not isinstance(t, tuple):
 *             typ = t             # <<<<<<<<<<<<<<
 *             rt = routine
 *         else:
 */
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_XDECREF_SET(__pyx_v_typ, __pyx_v_t);

      /* "cupy/core/reduction.pxi":459
 *         if not isinstance(t, tuple):
 *             typ = t
 *             rt = routine             # <<<<<<<<<<<<<<
 *         else:
 *             typ, rt = t
 */
      __Pyx_INCREF(__pyx_v_routine);
      __Pyx_XDECREF_SET(__pyx_v_rt, __pyx_v_routine);

      /* "cupy/core/reduction.pxi":457
 *     _ops = []
 *     for t in ops:
 *         if not isinstance(t, tuple):             # <<<<<<<<<<<<<<
 *             typ = t
 *             rt = routine
 */
      goto __pyx_L5;
    }

    /* "cupy/core/reduction.pxi":461
 *             rt = routine
 *         else:
 *             typ, rt = t             # <<<<<<<<<<<<<<
 *             rt = tuple([i or j for i, j in zip(rt, routine)])
 * 
 */
    /*else*/ {
      if ((likely(PyTuple_CheckExact(__pyx_v_t))) || (PyList_CheckExact(__pyx_v_t))) {
        PyObject* sequence = __pyx_v_t;
        #if !CYTHON_COMPILING_IN_PYPY
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(5, 461, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_7);
        #else
        __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 461, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 461, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      } else {
        Py_ssize_t index = -1;
        __pyx_t_8 = PyObject_GetIter(__pyx_v_t); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 461, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
        index = 0; __pyx_t_4 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(5, 461, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(5, 461, __pyx_L1_error)
        __pyx_L7_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_typ, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_rt, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "cupy/core/reduction.pxi":462
 *         else:
 *             typ, rt = t
 *             rt = tuple([i or j for i, j in zip(rt, routine)])             # <<<<<<<<<<<<<<
 * 
 *         types = typ.split('->')
 */
      __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 462, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 462, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_rt);
      __Pyx_GIVEREF(__pyx_v_rt);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_rt);
      __Pyx_INCREF(__pyx_v_routine);
      __Pyx_GIVEREF(__pyx_v_routine);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_routine);
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 462, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (likely(PyList_CheckExact(__pyx_t_8)) || PyTuple_CheckExact(__pyx_t_8)) {
        __pyx_t_4 = __pyx_t_8; __Pyx_INCREF(__pyx_t_4); __pyx_t_10 = 0;
        __pyx_t_11 = NULL;
      } else {
        __pyx_t_10 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 462, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_11 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 462, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      for (;;) {
        if (likely(!__pyx_t_11)) {
          if (likely(PyList_CheckExact(__pyx_t_4))) {
            if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_4)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_8 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(5, 462, __pyx_L1_error)
            #else
            __pyx_t_8 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 462, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_8);
            #endif
          } else {
            if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(5, 462, __pyx_L1_error)
            #else
            __pyx_t_8 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 462, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_8);
            #endif
          }
        } else {
          __pyx_t_8 = __pyx_t_11(__pyx_t_4);
          if (unlikely(!__pyx_t_8)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(5, 462, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_8);
        }
        if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
          PyObject* sequence = __pyx_t_8;
          #if !CYTHON_COMPILING_IN_PYPY
          Py_ssize_t size = Py_SIZE(sequence);
          #else
          Py_ssize_t size = PySequence_Size(sequence);
          #endif
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(5, 462, __pyx_L1_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_12 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_13 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_12 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_13 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_13);
          #else
          __pyx_t_12 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 462, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_13 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(5, 462, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          #endif
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_14 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 462, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __pyx_t_9 = Py_TYPE(__pyx_t_14)->tp_iternext;
          index = 0; __pyx_t_12 = __pyx_t_9(__pyx_t_14); if (unlikely(!__pyx_t_12)) goto __pyx_L10_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_12);
          index = 1; __pyx_t_13 = __pyx_t_9(__pyx_t_14); if (unlikely(!__pyx_t_13)) goto __pyx_L10_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_13);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_14), 2) < 0) __PYX_ERR(5, 462, __pyx_L1_error)
          __pyx_t_9 = NULL;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          goto __pyx_L11_unpacking_done;
          __pyx_L10_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __pyx_t_9 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(5, 462, __pyx_L1_error)
          __pyx_L11_unpacking_done:;
        }
        __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_12);
        __pyx_t_12 = 0;
        __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_13);
        __pyx_t_13 = 0;
        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_i); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(5, 462, __pyx_L1_error)
        if (!__pyx_t_6) {
        } else {
          __Pyx_INCREF(__pyx_v_i);
          __pyx_t_8 = __pyx_v_i;
          goto __pyx_L12_bool_binop_done;
        }
        __Pyx_INCREF(__pyx_v_j);
        __pyx_t_8 = __pyx_v_j;
        __pyx_L12_bool_binop_done:;
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_7, (PyObject*)__pyx_t_8))) __PYX_ERR(5, 462, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyList_AsTuple(((PyObject*)__pyx_t_7)); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 462, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF_SET(__pyx_v_rt, __pyx_t_4);
      __pyx_t_4 = 0;
    }
    __pyx_L5:;

    /* "cupy/core/reduction.pxi":464
 *             rt = tuple([i or j for i, j in zip(rt, routine)])
 * 
 *         types = typ.split('->')             # <<<<<<<<<<<<<<
 *         if len(types) == 1:
 *             in_types = out_types = tuple(types)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_typ, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__107, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_types, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/reduction.pxi":465
 * 
 *         types = typ.split('->')
 *         if len(types) == 1:             # <<<<<<<<<<<<<<
 *             in_types = out_types = tuple(types)
 *         else:
 */
    __pyx_t_10 = PyObject_Length(__pyx_v_types); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(5, 465, __pyx_L1_error)
    __pyx_t_6 = ((__pyx_t_10 == 1) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/reduction.pxi":466
 *         types = typ.split('->')
 *         if len(types) == 1:
 *             in_types = out_types = tuple(types)             # <<<<<<<<<<<<<<
 *         else:
 *             in_types, out_types = map(tuple, types)
 */
      __pyx_t_7 = PySequence_Tuple(__pyx_v_types); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_XDECREF_SET(__pyx_v_in_types, __pyx_t_7);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_XDECREF_SET(__pyx_v_out_types, __pyx_t_7);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "cupy/core/reduction.pxi":465
 * 
 *         types = typ.split('->')
 *         if len(types) == 1:             # <<<<<<<<<<<<<<
 *             in_types = out_types = tuple(types)
 *         else:
 */
      goto __pyx_L14;
    }

    /* "cupy/core/reduction.pxi":468
 *             in_types = out_types = tuple(types)
 *         else:
 *             in_types, out_types = map(tuple, types)             # <<<<<<<<<<<<<<
 *         in_types = tuple([numpy.dtype(t).type for t in in_types])
 *         out_types = tuple([numpy.dtype(t).type for t in out_types])
 */
    /*else*/ {
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 468, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(((PyObject *)(&PyTuple_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyTuple_Type)));
      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)(&PyTuple_Type)));
      __Pyx_INCREF(__pyx_v_types);
      __Pyx_GIVEREF(__pyx_v_types);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_types);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 468, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
        PyObject* sequence = __pyx_t_4;
        #if !CYTHON_COMPILING_IN_PYPY
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(5, 468, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        #else
        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 468, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 468, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_13 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_13)) __PYX_ERR(5, 468, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_13)->tp_iternext;
        index = 0; __pyx_t_7 = __pyx_t_9(__pyx_t_13); if (unlikely(!__pyx_t_7)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        index = 1; __pyx_t_8 = __pyx_t_9(__pyx_t_13); if (unlikely(!__pyx_t_8)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_8);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_13), 2) < 0) __PYX_ERR(5, 468, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L16_unpacking_done;
        __pyx_L15_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(5, 468, __pyx_L1_error)
        __pyx_L16_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_in_types, __pyx_t_7);
      __pyx_t_7 = 0;
      __Pyx_XDECREF_SET(__pyx_v_out_types, __pyx_t_8);
      __pyx_t_8 = 0;
    }
    __pyx_L14:;

    /* "cupy/core/reduction.pxi":469
 *         else:
 *             in_types, out_types = map(tuple, types)
 *         in_types = tuple([numpy.dtype(t).type for t in in_types])             # <<<<<<<<<<<<<<
 *         out_types = tuple([numpy.dtype(t).type for t in out_types])
 *         _ops.append((in_types, out_types, rt))
 */
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 469, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (likely(PyList_CheckExact(__pyx_v_in_types)) || PyTuple_CheckExact(__pyx_v_in_types)) {
      __pyx_t_8 = __pyx_v_in_types; __Pyx_INCREF(__pyx_t_8); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_in_types); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 469, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_11 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 469, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_11)) {
        if (likely(PyList_CheckExact(__pyx_t_8))) {
          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_8)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_10); __Pyx_INCREF(__pyx_t_7); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(5, 469, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 469, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_10); __Pyx_INCREF(__pyx_t_7); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(5, 469, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 469, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        }
      } else {
        __pyx_t_7 = __pyx_t_11(__pyx_t_8);
        if (unlikely(!__pyx_t_7)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(5, 469, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_13)) __PYX_ERR(5, 469, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_dtype); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 469, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
        }
      }
      if (!__pyx_t_13) {
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_t); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 469, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_v_t};
          __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 469, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_v_t};
          __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 469, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else
        #endif
        {
          __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 469, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_v_t);
          __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_14, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 469, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_type); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 469, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_12))) __PYX_ERR(5, 469, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyList_AsTuple(((PyObject*)__pyx_t_4)); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 469, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_in_types, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/reduction.pxi":470
 *             in_types, out_types = map(tuple, types)
 *         in_types = tuple([numpy.dtype(t).type for t in in_types])
 *         out_types = tuple([numpy.dtype(t).type for t in out_types])             # <<<<<<<<<<<<<<
 *         _ops.append((in_types, out_types, rt))
 * 
 */
    __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 470, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (likely(PyList_CheckExact(__pyx_v_out_types)) || PyTuple_CheckExact(__pyx_v_out_types)) {
      __pyx_t_4 = __pyx_v_out_types; __Pyx_INCREF(__pyx_t_4); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_out_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 470, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_11 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 470, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_11)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_12 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_12); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(5, 470, __pyx_L1_error)
          #else
          __pyx_t_12 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 470, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_12); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(5, 470, __pyx_L1_error)
          #else
          __pyx_t_12 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 470, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          #endif
        }
      } else {
        __pyx_t_12 = __pyx_t_11(__pyx_t_4);
        if (unlikely(!__pyx_t_12)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(5, 470, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_12);
      }
      __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_12);
      __pyx_t_12 = 0;
      __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 470, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 470, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_14);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_14, function);
        }
      }
      if (!__pyx_t_7) {
        __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_v_t); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 470, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_14)) {
          PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_t};
          __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 470, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_GOTREF(__pyx_t_12);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
          PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_t};
          __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 470, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_GOTREF(__pyx_t_12);
        } else
        #endif
        {
          __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(5, 470, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_7); __pyx_t_7 = NULL;
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_v_t);
          __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_13, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 470, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_type); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 470, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_8, (PyObject*)__pyx_t_14))) __PYX_ERR(5, 470, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyList_AsTuple(((PyObject*)__pyx_t_8)); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 470, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF_SET(__pyx_v_out_types, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":471
 *         in_types = tuple([numpy.dtype(t).type for t in in_types])
 *         out_types = tuple([numpy.dtype(t).type for t in out_types])
 *         _ops.append((in_types, out_types, rt))             # <<<<<<<<<<<<<<
 * 
 *     return simple_reduction_function(name, _ops, identity, preamble)
 */
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 471, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_in_types);
    __Pyx_GIVEREF(__pyx_v_in_types);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_in_types);
    __Pyx_INCREF(__pyx_v_out_types);
    __Pyx_GIVEREF(__pyx_v_out_types);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_out_types);
    __Pyx_INCREF(__pyx_v_rt);
    __Pyx_GIVEREF(__pyx_v_rt);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_rt);
    __pyx_t_15 = __Pyx_PyList_Append(__pyx_v__ops, __pyx_t_4); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(5, 471, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":456
 *                             preamble=''):
 *     _ops = []
 *     for t in ops:             # <<<<<<<<<<<<<<
 *         if not isinstance(t, tuple):
 *             typ = t
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":473
 *         _ops.append((in_types, out_types, rt))
 * 
 *     return simple_reduction_function(name, _ops, identity, preamble)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_simple_reduction_function); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 473, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = NULL;
  __pyx_t_16 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_16 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_v_name, __pyx_v__ops, __pyx_v_identity, __pyx_v_preamble};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_16, 4+__pyx_t_16); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 473, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_v_name, __pyx_v__ops, __pyx_v_identity, __pyx_v_preamble};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_16, 4+__pyx_t_16); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 473, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_14 = PyTuple_New(4+__pyx_t_16); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 473, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_INCREF(__pyx_v_name);
    __Pyx_GIVEREF(__pyx_v_name);
    PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_16, __pyx_v_name);
    __Pyx_INCREF(__pyx_v__ops);
    __Pyx_GIVEREF(__pyx_v__ops);
    PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_16, __pyx_v__ops);
    __Pyx_INCREF(__pyx_v_identity);
    __Pyx_GIVEREF(__pyx_v_identity);
    PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_16, __pyx_v_identity);
    __Pyx_INCREF(__pyx_v_preamble);
    __Pyx_GIVEREF(__pyx_v_preamble);
    PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_16, __pyx_v_preamble);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 473, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":453
 * 
 * 
 * cpdef create_reduction_func(name, ops, routine=None, identity=None,             # <<<<<<<<<<<<<<
 *                             preamble=''):
 *     _ops = []
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("cupy.core.core.create_reduction_func", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__ops);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_typ);
  __Pyx_XDECREF(__pyx_v_rt);
  __Pyx_XDECREF(__pyx_v_types);
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_49create_reduction_func(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_48create_reduction_func[] = "create_reduction_func(name, ops, routine=None, identity=None, preamble='')";
static PyObject *__pyx_pw_4cupy_4core_4core_49create_reduction_func(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_ops = 0;
  PyObject *__pyx_v_routine = 0;
  PyObject *__pyx_v_identity = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_reduction_func (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,&__pyx_n_s_ops,&__pyx_n_s_routine,&__pyx_n_s_identity,&__pyx_n_s_preamble,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)__pyx_kp_s__5);
    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] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ops)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_reduction_func", 0, 2, 5, 1); __PYX_ERR(5, 453, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_routine);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_identity);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_preamble);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_reduction_func") < 0)) __PYX_ERR(5, 453, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_name = values[0];
    __pyx_v_ops = values[1];
    __pyx_v_routine = values[2];
    __pyx_v_identity = values[3];
    __pyx_v_preamble = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_reduction_func", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 453, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.create_reduction_func", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_48create_reduction_func(__pyx_self, __pyx_v_name, __pyx_v_ops, __pyx_v_routine, __pyx_v_identity, __pyx_v_preamble);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_48create_reduction_func(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_ops, PyObject *__pyx_v_routine, PyObject *__pyx_v_identity, PyObject *__pyx_v_preamble) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_create_reduction_func __pyx_t_2;
  __Pyx_RefNannySetupContext("create_reduction_func", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.routine = __pyx_v_routine;
  __pyx_t_2.identity = __pyx_v_identity;
  __pyx_t_2.preamble = __pyx_v_preamble;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_v_name, __pyx_v_ops, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 453, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.create_reduction_func", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2085
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, str order='K',             # <<<<<<<<<<<<<<
 *                     bint subok=False, Py_ssize_t ndmin=0):
 *     # TODO(beam2d): Support subok options
 */

static PyObject *__pyx_pw_4cupy_4core_4core_51array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_array(PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_array *__pyx_optional_args) {
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  int __pyx_v_copy = ((int)1);
  PyObject *__pyx_v_order = ((PyObject*)__pyx_n_s_K);

  /* "cupy/core/core.pyx":2086
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, str order='K',
 *                     bint subok=False, Py_ssize_t ndmin=0):             # <<<<<<<<<<<<<<
 *     # TODO(beam2d): Support subok options
 *     cdef Py_ssize_t nvidem
 */
  int __pyx_v_subok = ((int)0);
  Py_ssize_t __pyx_v_ndmin = ((Py_ssize_t)0);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_src = 0;
  struct __pyx_obj_4cupy_4cuda_6device_Device *__pyx_v_dev = NULL;
  PyObject *__pyx_v_ndim = NULL;
  PyObject *__pyx_v_a_cpu = NULL;
  PyObject *__pyx_v_a_dtype = NULL;
  struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer *__pyx_v_mem = NULL;
  PyObject *__pyx_v_src_cpu = NULL;
  PyObject *__pyx_v_stream = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set __pyx_t_14;
  __Pyx_RefNannySetupContext("array", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_dtype = __pyx_optional_args->dtype;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_copy = __pyx_optional_args->copy;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_order = __pyx_optional_args->order;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_subok = __pyx_optional_args->subok;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_ndmin = __pyx_optional_args->ndmin;
            }
          }
        }
      }
    }
  }
  __Pyx_INCREF(__pyx_v_dtype);
  __Pyx_INCREF(__pyx_v_order);

  /* "cupy/core/core.pyx":2090
 *     cdef Py_ssize_t nvidem
 *     cdef ndarray a, src
 *     if subok:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 *     if isinstance(obj, ndarray):
 */
  __pyx_t_1 = (__pyx_v_subok != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2091
 *     cdef ndarray a, src
 *     if subok:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 *     if isinstance(obj, ndarray):
 *         src = obj
 */
    __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
    __PYX_ERR(0, 2091, __pyx_L1_error)

    /* "cupy/core/core.pyx":2090
 *     cdef Py_ssize_t nvidem
 *     cdef ndarray a, src
 *     if subok:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 *     if isinstance(obj, ndarray):
 */
  }

  /* "cupy/core/core.pyx":2092
 *     if subok:
 *         raise NotImplementedError
 *     if isinstance(obj, ndarray):             # <<<<<<<<<<<<<<
 *         src = obj
 *         if dtype is None:
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_4cupy_4core_4core_ndarray); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2093
 *         raise NotImplementedError
 *     if isinstance(obj, ndarray):
 *         src = obj             # <<<<<<<<<<<<<<
 *         if dtype is None:
 *             dtype = src.dtype
 */
    if (!(likely(((__pyx_v_obj) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_obj, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2093, __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":2094
 *     if isinstance(obj, ndarray):
 *         src = obj
 *         if dtype is None:             # <<<<<<<<<<<<<<
 *             dtype = src.dtype
 *         dev = src.data.device
 */
    __pyx_t_2 = (__pyx_v_dtype == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":2095
 *         src = obj
 *         if dtype is None:
 *             dtype = src.dtype             # <<<<<<<<<<<<<<
 *         dev = src.data.device
 *         if dev is None or dev.id == device.get_device_id():
 */
      __pyx_t_3 = __pyx_v_src->dtype;
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":2094
 *     if isinstance(obj, ndarray):
 *         src = obj
 *         if dtype is None:             # <<<<<<<<<<<<<<
 *             dtype = src.dtype
 *         dev = src.data.device
 */
    }

    /* "cupy/core/core.pyx":2096
 *         if dtype is None:
 *             dtype = src.dtype
 *         dev = src.data.device             # <<<<<<<<<<<<<<
 *         if dev is None or dev.id == device.get_device_id():
 *             a = src.astype(dtype, order=order, copy=copy)
 */
    __pyx_t_3 = ((PyObject *)__pyx_v_src->data->device);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_dev = ((struct __pyx_obj_4cupy_4cuda_6device_Device *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2097
 *             dtype = src.dtype
 *         dev = src.data.device
 *         if dev is None or dev.id == device.get_device_id():             # <<<<<<<<<<<<<<
 *             a = src.astype(dtype, order=order, copy=copy)
 *         else:
 */
    __pyx_t_2 = (((PyObject *)__pyx_v_dev) == Py_None);
    __pyx_t_4 = (__pyx_t_2 != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_1 = __pyx_t_4;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_5 = __pyx_f_4cupy_4cuda_6device_get_device_id(0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2097, __pyx_L1_error)
    __pyx_t_4 = ((__pyx_v_dev->id == __pyx_t_5) != 0);
    __pyx_t_1 = __pyx_t_4;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":2098
 *         dev = src.data.device
 *         if dev is None or dev.id == device.get_device_id():
 *             a = src.astype(dtype, order=order, copy=copy)             # <<<<<<<<<<<<<<
 *         else:
 *             a = src.copy(order=order).astype(dtype, copy=False)
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_src), __pyx_n_s_astype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2098, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2098, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_dtype);
      __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2098, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 2098, __pyx_L1_error)
      __pyx_t_8 = __Pyx_PyBool_FromLong(__pyx_v_copy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2098, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_copy, __pyx_t_8) < 0) __PYX_ERR(0, 2098, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2098, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2098, __pyx_L1_error)
      __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8);
      __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":2097
 *             dtype = src.dtype
 *         dev = src.data.device
 *         if dev is None or dev.id == device.get_device_id():             # <<<<<<<<<<<<<<
 *             a = src.astype(dtype, order=order, copy=copy)
 *         else:
 */
      goto __pyx_L6;
    }

    /* "cupy/core/core.pyx":2100
 *             a = src.astype(dtype, order=order, copy=copy)
 *         else:
 *             a = src.copy(order=order).astype(dtype, copy=False)             # <<<<<<<<<<<<<<
 * 
 *         ndim = a._shape.size()
 */
    /*else*/ {
      __pyx_t_9.__pyx_n = 1;
      __pyx_t_9.order = __pyx_v_order;
      __pyx_t_8 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_src->__pyx_vtab)->copy(__pyx_v_src, 0, &__pyx_t_9)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2100, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_astype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2100, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2100, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_dtype);
      __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2100, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 2100, __pyx_L1_error)
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2100, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2100, __pyx_L1_error)
      __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
      __pyx_t_3 = 0;
    }
    __pyx_L6:;

    /* "cupy/core/core.pyx":2102
 *             a = src.copy(order=order).astype(dtype, copy=False)
 * 
 *         ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *         if ndmin > ndim:
 *             if a is obj:
 */
    __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_a->_shape.size()); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2102, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_ndim = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2103
 * 
 *         ndim = a._shape.size()
 *         if ndmin > ndim:             # <<<<<<<<<<<<<<
 *             if a is obj:
 *                 # When `copy` is False, `a` is same as `obj`.
 */
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ndmin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2103, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_3, __pyx_v_ndim, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2103, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2103, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":2104
 *         ndim = a._shape.size()
 *         if ndmin > ndim:
 *             if a is obj:             # <<<<<<<<<<<<<<
 *                 # When `copy` is False, `a` is same as `obj`.
 *                 a = a.view()
 */
      __pyx_t_1 = (((PyObject *)__pyx_v_a) == __pyx_v_obj);
      __pyx_t_4 = (__pyx_t_1 != 0);
      if (__pyx_t_4) {

        /* "cupy/core/core.pyx":2106
 *             if a is obj:
 *                 # When `copy` is False, `a` is same as `obj`.
 *                 a = a.view()             # <<<<<<<<<<<<<<
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 *     else:
 */
        __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2106, __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":2104
 *         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":2107
 *                 # When `copy` is False, `a` is same as `obj`.
 *                 a = a.view()
 *             a.shape = (1,) * (ndmin - ndim) + a.shape             # <<<<<<<<<<<<<<
 *     else:
 *         if order == 'K':
 */
      __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_ndmin); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2107, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = PyNumber_Subtract(__pyx_t_6, __pyx_v_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2107, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyNumber_Multiply(__pyx_tuple__108, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2107, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2107, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = PyNumber_Add(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2107, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape, __pyx_t_8) < 0) __PYX_ERR(0, 2107, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":2103
 * 
 *         ndim = a._shape.size()
 *         if ndmin > ndim:             # <<<<<<<<<<<<<<
 *             if a is obj:
 *                 # When `copy` is False, `a` is same as `obj`.
 */
    }

    /* "cupy/core/core.pyx":2092
 *     if subok:
 *         raise NotImplementedError
 *     if isinstance(obj, ndarray):             # <<<<<<<<<<<<<<
 *         src = obj
 *         if dtype is None:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":2109
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 *     else:
 *         if order == 'K':             # <<<<<<<<<<<<<<
 *             order = 'A'
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,
 */
  /*else*/ {
    __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_order, __pyx_n_s_K, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2109, __pyx_L1_error)
    __pyx_t_1 = (__pyx_t_4 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":2110
 *     else:
 *         if order == 'K':
 *             order = 'A'             # <<<<<<<<<<<<<<
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,
 *                             ndmin=ndmin)
 */
      __Pyx_INCREF(__pyx_n_s_A);
      __Pyx_DECREF_SET(__pyx_v_order, __pyx_n_s_A);

      /* "cupy/core/core.pyx":2109
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 *     else:
 *         if order == 'K':             # <<<<<<<<<<<<<<
 *             order = 'A'
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,
 */
    }

    /* "cupy/core/core.pyx":2111
 *         if order == 'K':
 *             order = 'A'
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,             # <<<<<<<<<<<<<<
 *                             ndmin=ndmin)
 *         order = 'C' if a_cpu.flags.c_contiguous else 'F'
 */
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2111, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2111, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2111, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v_obj);
    __Pyx_GIVEREF(__pyx_v_obj);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj);
    __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2111, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 2111, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 2111, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 2111, __pyx_L1_error)

    /* "cupy/core/core.pyx":2112
 *             order = 'A'
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,
 *                             ndmin=ndmin)             # <<<<<<<<<<<<<<
 *         order = 'C' if a_cpu.flags.c_contiguous else 'F'
 *         a_dtype = a_cpu.dtype
 */
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_ndmin); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_ndmin, __pyx_t_7) < 0) __PYX_ERR(0, 2111, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2111
 *         if order == 'K':
 *             order = 'A'
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,             # <<<<<<<<<<<<<<
 *                             ndmin=ndmin)
 *         order = 'C' if a_cpu.flags.c_contiguous else 'F'
 */
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2111, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_a_cpu = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2113
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,
 *                             ndmin=ndmin)
 *         order = 'C' if a_cpu.flags.c_contiguous else 'F'             # <<<<<<<<<<<<<<
 *         a_dtype = a_cpu.dtype
 *         if a_dtype.char not in '?bhilqBHILQefdFD':
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_flags); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_c_contiguous); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2113, __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, 2113, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (__pyx_t_1) {
      __Pyx_INCREF(__pyx_n_s_C);
      __pyx_t_7 = __pyx_n_s_C;
    } else {
      __Pyx_INCREF(__pyx_n_s_F);
      __pyx_t_7 = __pyx_n_s_F;
    }
    __Pyx_DECREF_SET(__pyx_v_order, ((PyObject*)__pyx_t_7));
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2114
 *                             ndmin=ndmin)
 *         order = 'C' if a_cpu.flags.c_contiguous else 'F'
 *         a_dtype = a_cpu.dtype             # <<<<<<<<<<<<<<
 *         if a_dtype.char not in '?bhilqBHILQefdFD':
 *             raise ValueError('Unsupported dtype %s' % a_dtype)
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2114, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_v_a_dtype = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2115
 *         order = 'C' if a_cpu.flags.c_contiguous else 'F'
 *         a_dtype = a_cpu.dtype
 *         if a_dtype.char not in '?bhilqBHILQefdFD':             # <<<<<<<<<<<<<<
 *             raise ValueError('Unsupported dtype %s' % a_dtype)
 *         a = ndarray(a_cpu.shape, dtype=a_dtype, order=order)
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_dtype, __pyx_n_s_char); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2115, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_t_7, __pyx_kp_s_bhilqBHILQefdFD, Py_NE)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2115, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_4 = (__pyx_t_1 != 0);
    if (__pyx_t_4) {

      /* "cupy/core/core.pyx":2116
 *         a_dtype = a_cpu.dtype
 *         if a_dtype.char not in '?bhilqBHILQefdFD':
 *             raise ValueError('Unsupported dtype %s' % a_dtype)             # <<<<<<<<<<<<<<
 *         a = ndarray(a_cpu.shape, dtype=a_dtype, order=order)
 *         if a_cpu.ndim == 0:
 */
      __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Unsupported_dtype_s, __pyx_v_a_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2116, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2116, __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_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2116, __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, 2116, __pyx_L1_error)

      /* "cupy/core/core.pyx":2115
 *         order = 'C' if a_cpu.flags.c_contiguous else 'F'
 *         a_dtype = a_cpu.dtype
 *         if a_dtype.char not in '?bhilqBHILQefdFD':             # <<<<<<<<<<<<<<
 *             raise ValueError('Unsupported dtype %s' % a_dtype)
 *         a = ndarray(a_cpu.shape, dtype=a_dtype, order=order)
 */
    }

    /* "cupy/core/core.pyx":2117
 *         if a_dtype.char not in '?bhilqBHILQefdFD':
 *             raise ValueError('Unsupported dtype %s' % a_dtype)
 *         a = ndarray(a_cpu.shape, dtype=a_dtype, order=order)             # <<<<<<<<<<<<<<
 *         if a_cpu.ndim == 0:
 *             a.fill(a_cpu[()])
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_shape); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2117, __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 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2117, __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, 2117, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 2117, __pyx_L1_error)
    __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __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_6);
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2118
 *             raise ValueError('Unsupported dtype %s' % a_dtype)
 *         a = ndarray(a_cpu.shape, dtype=a_dtype, order=order)
 *         if a_cpu.ndim == 0:             # <<<<<<<<<<<<<<
 *             a.fill(a_cpu[()])
 *             return a
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2118, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyInt_EqObjC(__pyx_t_6, __pyx_int_0, 0, 0); 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_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2118, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_4) {

      /* "cupy/core/core.pyx":2119
 *         a = ndarray(a_cpu.shape, dtype=a_dtype, order=order)
 *         if a_cpu.ndim == 0:
 *             a.fill(a_cpu[()])             # <<<<<<<<<<<<<<
 *             return a
 *         mem = pinned_memory.alloc_pinned_memory(a.nbytes)
 */
      __pyx_t_7 = PyObject_GetItem(__pyx_v_a_cpu, __pyx_empty_tuple); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2119, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->fill(__pyx_v_a, __pyx_t_7, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2119, __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;

      /* "cupy/core/core.pyx":2120
 *         if a_cpu.ndim == 0:
 *             a.fill(a_cpu[()])
 *             return a             # <<<<<<<<<<<<<<
 *         mem = pinned_memory.alloc_pinned_memory(a.nbytes)
 *         src_cpu = numpy.frombuffer(mem, a_cpu.dtype,
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __pyx_r = __pyx_v_a;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2118
 *             raise ValueError('Unsupported dtype %s' % a_dtype)
 *         a = ndarray(a_cpu.shape, dtype=a_dtype, order=order)
 *         if a_cpu.ndim == 0:             # <<<<<<<<<<<<<<
 *             a.fill(a_cpu[()])
 *             return a
 */
    }

    /* "cupy/core/core.pyx":2121
 *             a.fill(a_cpu[()])
 *             return a
 *         mem = pinned_memory.alloc_pinned_memory(a.nbytes)             # <<<<<<<<<<<<<<
 *         src_cpu = numpy.frombuffer(mem, a_cpu.dtype,
 *                                    a_cpu.size).reshape(a_cpu.shape)
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2121, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = ((PyObject *)__pyx_f_4cupy_4cuda_13pinned_memory_alloc_pinned_memory(__pyx_t_10, 0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_mem = ((struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer *)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2122
 *             return a
 *         mem = pinned_memory.alloc_pinned_memory(a.nbytes)
 *         src_cpu = numpy.frombuffer(mem, a_cpu.dtype,             # <<<<<<<<<<<<<<
 *                                    a_cpu.size).reshape(a_cpu.shape)
 *         src_cpu[...] = a_cpu
 */
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);

    /* "cupy/core/core.pyx":2123
 *         mem = pinned_memory.alloc_pinned_memory(a.nbytes)
 *         src_cpu = numpy.frombuffer(mem, a_cpu.dtype,
 *                                    a_cpu.size).reshape(a_cpu.shape)             # <<<<<<<<<<<<<<
 *         src_cpu[...] = a_cpu
 *         stream = cuda.Stream.null
 */
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_size); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[4] = {__pyx_t_12, ((PyObject *)__pyx_v_mem), __pyx_t_8, __pyx_t_11};
      __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2122, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[4] = {__pyx_t_12, ((PyObject *)__pyx_v_mem), __pyx_t_8, __pyx_t_11};
      __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2122, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    {
      __pyx_t_13 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2122, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (__pyx_t_12) {
        __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __pyx_t_12 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_mem));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_mem));
      PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_5, ((PyObject *)__pyx_v_mem));
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_5, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_5, __pyx_t_11);
      __pyx_t_8 = 0;
      __pyx_t_11 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_13, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2122, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_shape); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_13 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_13)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_13) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2123, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_7};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2123, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_7};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2123, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2123, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_13); __pyx_t_13 = NULL;
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2123, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_src_cpu = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2124
 *         src_cpu = numpy.frombuffer(mem, a_cpu.dtype,
 *                                    a_cpu.size).reshape(a_cpu.shape)
 *         src_cpu[...] = a_cpu             # <<<<<<<<<<<<<<
 *         stream = cuda.Stream.null
 *         a.set(src_cpu, stream)
 */
    if (unlikely(PyObject_SetItem(__pyx_v_src_cpu, Py_Ellipsis, __pyx_v_a_cpu) < 0)) __PYX_ERR(0, 2124, __pyx_L1_error)

    /* "cupy/core/core.pyx":2125
 *                                    a_cpu.size).reshape(a_cpu.shape)
 *         src_cpu[...] = a_cpu
 *         stream = cuda.Stream.null             # <<<<<<<<<<<<<<
 *         a.set(src_cpu, stream)
 *         pinned_memory._add_to_watch_list(stream.record(), mem)
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2125, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_Stream); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2125, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_null); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2125, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_stream = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2126
 *         src_cpu[...] = a_cpu
 *         stream = cuda.Stream.null
 *         a.set(src_cpu, stream)             # <<<<<<<<<<<<<<
 *         pinned_memory._add_to_watch_list(stream.record(), mem)
 *     return a
 */
    __pyx_t_14.__pyx_n = 1;
    __pyx_t_14.stream = __pyx_v_stream;
    __pyx_t_6 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->set(__pyx_v_a, __pyx_v_src_cpu, 0, &__pyx_t_14); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2126, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2127
 *         stream = cuda.Stream.null
 *         a.set(src_cpu, stream)
 *         pinned_memory._add_to_watch_list(stream.record(), mem)             # <<<<<<<<<<<<<<
 *     return a
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_stream, __pyx_n_s_record); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2127, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_11) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2127, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else {
      __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2127, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __pyx_f_4cupy_4cuda_13pinned_memory__add_to_watch_list(__pyx_t_6, ((PyObject *)__pyx_v_mem), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2127, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":2128
 *         a.set(src_cpu, stream)
 *         pinned_memory._add_to_watch_list(stream.record(), mem)
 *     return a             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_a));
  __pyx_r = __pyx_v_a;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2085
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, str order='K',             # <<<<<<<<<<<<<<
 *                     bint subok=False, Py_ssize_t ndmin=0):
 *     # TODO(beam2d): Support subok options
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("cupy.core.core.array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF((PyObject *)__pyx_v_src);
  __Pyx_XDECREF((PyObject *)__pyx_v_dev);
  __Pyx_XDECREF(__pyx_v_ndim);
  __Pyx_XDECREF(__pyx_v_a_cpu);
  __Pyx_XDECREF(__pyx_v_a_dtype);
  __Pyx_XDECREF((PyObject *)__pyx_v_mem);
  __Pyx_XDECREF(__pyx_v_src_cpu);
  __Pyx_XDECREF(__pyx_v_stream);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_order);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_51array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_50array[] = "array(obj, dtype=None, bool copy=True, str order='K', bool subok=False, Py_ssize_t ndmin=0) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_51array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_obj = 0;
  PyObject *__pyx_v_dtype = 0;
  int __pyx_v_copy;
  PyObject *__pyx_v_order = 0;
  int __pyx_v_subok;
  Py_ssize_t __pyx_v_ndmin;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("array (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_dtype,&__pyx_n_s_copy,&__pyx_n_s_order,&__pyx_n_s_subok,&__pyx_n_s_ndmin,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[3] = ((PyObject*)__pyx_n_s_K);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__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 = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_copy);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_order);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_subok);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 2085, __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, 2085, __pyx_L3_error)
    } else {
      __pyx_v_copy = ((int)1);
    }
    __pyx_v_order = ((PyObject*)values[3]);
    if (values[4]) {
      __pyx_v_subok = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_subok == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2086, __pyx_L3_error)
    } else {

      /* "cupy/core/core.pyx":2086
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, str order='K',
 *                     bint subok=False, Py_ssize_t ndmin=0):             # <<<<<<<<<<<<<<
 *     # TODO(beam2d): Support subok options
 *     cdef Py_ssize_t nvidem
 */
      __pyx_v_subok = ((int)0);
    }
    if (values[5]) {
      __pyx_v_ndmin = __Pyx_PyIndex_AsSsize_t(values[5]); if (unlikely((__pyx_v_ndmin == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2086, __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, 2085, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_order), (&PyString_Type), 1, "order", 1))) __PYX_ERR(0, 2085, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_50array(__pyx_self, __pyx_v_obj, __pyx_v_dtype, __pyx_v_copy, __pyx_v_order, __pyx_v_subok, __pyx_v_ndmin);

  /* "cupy/core/core.pyx":2085
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, str order='K',             # <<<<<<<<<<<<<<
 *                     bint subok=False, Py_ssize_t ndmin=0):
 *     # TODO(beam2d): Support subok options
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_50array(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, 2085, __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":2131
 * 
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         if a._c_contiguous:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_53ascontiguousarray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_ascontiguousarray(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray *__pyx_optional_args) {
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_newarray = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __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":2132
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         if a._c_contiguous:
 *             return a
 */
  __pyx_t_1 = (__pyx_v_dtype == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2133
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):
 *     if dtype is None:
 *         if a._c_contiguous:             # <<<<<<<<<<<<<<
 *             return a
 *         dtype = a.dtype
 */
    __pyx_t_2 = (__pyx_v_a->_c_contiguous != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2134
 *     if dtype is None:
 *         if a._c_contiguous:
 *             return a             # <<<<<<<<<<<<<<
 *         dtype = a.dtype
 *     else:
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __pyx_r = __pyx_v_a;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2133
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):
 *     if dtype is None:
 *         if a._c_contiguous:             # <<<<<<<<<<<<<<
 *             return a
 *         dtype = a.dtype
 */
    }

    /* "cupy/core/core.pyx":2135
 *         if a._c_contiguous:
 *             return a
 *         dtype = a.dtype             # <<<<<<<<<<<<<<
 *     else:
 *         dtype = numpy.dtype(dtype)
 */
    __pyx_t_3 = __pyx_v_a->dtype;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2132
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         if a._c_contiguous:
 *             return a
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":2137
 *         dtype = a.dtype
 *     else:
 *         dtype = numpy.dtype(dtype)             # <<<<<<<<<<<<<<
 *         if a._c_contiguous and dtype == a.dtype:
 *             return a
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2137, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2137, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2137, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_dtype};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2137, __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_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_dtype};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2137, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2137, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_dtype);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2137, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2138
 *     else:
 *         dtype = numpy.dtype(dtype)
 *         if a._c_contiguous and dtype == a.dtype:             # <<<<<<<<<<<<<<
 *             return a
 * 
 */
    __pyx_t_1 = (__pyx_v_a->_c_contiguous != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_dtype, __pyx_v_a->dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2138, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2138, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __pyx_t_1;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2139
 *         dtype = numpy.dtype(dtype)
 *         if a._c_contiguous and dtype == a.dtype:
 *             return a             # <<<<<<<<<<<<<<
 * 
 *     newarray = ndarray(a.shape, dtype)
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __pyx_r = __pyx_v_a;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2138
 *     else:
 *         dtype = numpy.dtype(dtype)
 *         if a._c_contiguous and dtype == a.dtype:             # <<<<<<<<<<<<<<
 *             return a
 * 
 */
    }
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":2141
 *             return a
 * 
 *     newarray = ndarray(a.shape, dtype)             # <<<<<<<<<<<<<<
 *     elementwise_copy(a, newarray)
 *     return newarray
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2141, __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_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_dtype);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2142
 * 
 *     newarray = ndarray(a.shape, dtype)
 *     elementwise_copy(a, newarray)             # <<<<<<<<<<<<<<
 *     return newarray
 * 
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __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, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2142, __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_5)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2142, __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_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2142, __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_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_4, 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_4, 1+__pyx_t_7, ((PyObject *)__pyx_v_newarray));
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2142, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2143
 *     newarray = ndarray(a.shape, dtype)
 *     elementwise_copy(a, newarray)
 *     return newarray             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
  __pyx_r = __pyx_v_newarray;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2131
 * 
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         if a._c_contiguous:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ascontiguousarray", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_newarray);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_53ascontiguousarray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_52ascontiguousarray[] = "ascontiguousarray(ndarray a, dtype=None) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_53ascontiguousarray(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] = PyDict_GetItem(__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 = PyDict_GetItem(__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, 2131, __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, 2131, __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, 2131, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_52ascontiguousarray(__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_52ascontiguousarray(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, 2131, __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":2146
 * 
 * 
 * cpdef ndarray asfortranarray(ndarray a, dtype=None):             # <<<<<<<<<<<<<<
 *     cdef ndarray newarray
 *     cdef int m, n
 */

static PyObject *__pyx_pw_4cupy_4core_4core_55asfortranarray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_asfortranarray(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_asfortranarray *__pyx_optional_args) {
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_newarray = 0;
  int __pyx_v_m;
  int __pyx_v_n;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  __Pyx_RefNannySetupContext("asfortranarray", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_dtype = __pyx_optional_args->dtype;
    }
  }
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/core.pyx":2150
 *     cdef int m, n
 * 
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         if a._f_contiguous:
 *             return a
 */
  __pyx_t_1 = (__pyx_v_dtype == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2151
 * 
 *     if dtype is None:
 *         if a._f_contiguous:             # <<<<<<<<<<<<<<
 *             return a
 *         dtype = a.dtype
 */
    __pyx_t_2 = (__pyx_v_a->_f_contiguous != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2152
 *     if dtype is None:
 *         if a._f_contiguous:
 *             return a             # <<<<<<<<<<<<<<
 *         dtype = a.dtype
 *     else:
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __pyx_r = __pyx_v_a;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2151
 * 
 *     if dtype is None:
 *         if a._f_contiguous:             # <<<<<<<<<<<<<<
 *             return a
 *         dtype = a.dtype
 */
    }

    /* "cupy/core/core.pyx":2153
 *         if a._f_contiguous:
 *             return a
 *         dtype = a.dtype             # <<<<<<<<<<<<<<
 *     else:
 *         dtype = numpy.dtype(dtype)
 */
    __pyx_t_3 = __pyx_v_a->dtype;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2150
 *     cdef int m, n
 * 
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         if a._f_contiguous:
 *             return a
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":2155
 *         dtype = a.dtype
 *     else:
 *         dtype = numpy.dtype(dtype)             # <<<<<<<<<<<<<<
 *         if a._f_contiguous and dtype == a.dtype:
 *             return a
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2155, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2155, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2155, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_dtype};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2155, __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_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_dtype};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2155, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2155, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_dtype);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2155, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2156
 *     else:
 *         dtype = numpy.dtype(dtype)
 *         if a._f_contiguous and dtype == a.dtype:             # <<<<<<<<<<<<<<
 *             return a
 * 
 */
    __pyx_t_1 = (__pyx_v_a->_f_contiguous != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_dtype, __pyx_v_a->dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2156, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2156, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __pyx_t_1;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2157
 *         dtype = numpy.dtype(dtype)
 *         if a._f_contiguous and dtype == a.dtype:
 *             return a             # <<<<<<<<<<<<<<
 * 
 *     newarray = ndarray(a.shape, dtype, order='F')
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __pyx_r = __pyx_v_a;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2156
 *     else:
 *         dtype = numpy.dtype(dtype)
 *         if a._f_contiguous and dtype == a.dtype:             # <<<<<<<<<<<<<<
 *             return a
 * 
 */
    }
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":2159
 *             return a
 * 
 *     newarray = ndarray(a.shape, dtype, order='F')             # <<<<<<<<<<<<<<
 *     if (a.flags.c_contiguous and
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64) and
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2159, __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_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_dtype);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_order, __pyx_n_s_F) < 0) __PYX_ERR(0, 2159, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":2160
 * 
 *     newarray = ndarray(a.shape, dtype, order='F')
 *     if (a.flags.c_contiguous and             # <<<<<<<<<<<<<<
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64) and
 *             a.ndim == 2 and dtype == a.dtype):
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_flags); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_c_contiguous); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2160, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L9_bool_binop_done;
  }

  /* "cupy/core/core.pyx":2161
 *     newarray = ndarray(a.shape, dtype, order='F')
 *     if (a.flags.c_contiguous and
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64) and             # <<<<<<<<<<<<<<
 *             a.ndim == 2 and dtype == a.dtype):
 *         m, n = a.shape
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float32); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_a->dtype, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2161, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2161, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!__pyx_t_1) {
  } else {
    goto __pyx_L11_next_and;
  }
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_a->dtype, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2161, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2161, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_L11_next_and:;

  /* "cupy/core/core.pyx":2162
 *     if (a.flags.c_contiguous and
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64) and
 *             a.ndim == 2 and dtype == a.dtype):             # <<<<<<<<<<<<<<
 *         m, n = a.shape
 *         if a.dtype == numpy.float32:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2162, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_6 = PyObject_RichCompare(__pyx_v_dtype, __pyx_v_a->dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2162, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2162, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_2 = __pyx_t_1;
  __pyx_L9_bool_binop_done:;

  /* "cupy/core/core.pyx":2160
 * 
 *     newarray = ndarray(a.shape, dtype, order='F')
 *     if (a.flags.c_contiguous and             # <<<<<<<<<<<<<<
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64) and
 *             a.ndim == 2 and dtype == a.dtype):
 */
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2163
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64) and
 *             a.ndim == 2 and dtype == a.dtype):
 *         m, n = a.shape             # <<<<<<<<<<<<<<
 *         if a.dtype == numpy.float32:
 *             cuda.cublas.sgeam(
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2163, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
      PyObject* sequence = __pyx_t_6;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 2163, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2163, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2163, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      #endif
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_4 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2163, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_7(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L14_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_5 = __pyx_t_7(__pyx_t_4); if (unlikely(!__pyx_t_5)) goto __pyx_L14_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_4), 2) < 0) __PYX_ERR(0, 2163, __pyx_L1_error)
      __pyx_t_7 = NULL;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L15_unpacking_done;
      __pyx_L14_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 2163, __pyx_L1_error)
      __pyx_L15_unpacking_done:;
    }
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2163, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2163, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_m = __pyx_t_8;
    __pyx_v_n = __pyx_t_9;

    /* "cupy/core/core.pyx":2164
 *             a.ndim == 2 and dtype == a.dtype):
 *         m, n = a.shape
 *         if a.dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *             cuda.cublas.sgeam(
 *                 cuda.Device().cublas_handle,
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_float32); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_RichCompare(__pyx_v_a->dtype, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2164, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2164, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2165
 *         m, n = a.shape
 *         if a.dtype == numpy.float32:
 *             cuda.cublas.sgeam(             # <<<<<<<<<<<<<<
 *                 cuda.Device().cublas_handle,
 *                 1,  # transpose a
 */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2165, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_cublas); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2165, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sgeam); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2165, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":2166
 *         if a.dtype == numpy.float32:
 *             cuda.cublas.sgeam(
 *                 cuda.Device().cublas_handle,             # <<<<<<<<<<<<<<
 *                 1,  # transpose a
 *                 1,  # transpose newarray
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2166, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_Device); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2166, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2166, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2166, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_cublas_handle); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2166, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":2169
 *                 1,  # transpose a
 *                 1,  # transpose newarray
 *                 m, n, 1., a.data.ptr, n, 0., a.data.ptr, n,             # <<<<<<<<<<<<<<
 *                 newarray.data.ptr, m)
 *         elif a.dtype == numpy.float64:
 */
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_m); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2169, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2169, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_11 = __Pyx_PyInt_FromSize_t(__pyx_v_a->data->ptr); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2169, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2169, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = __Pyx_PyInt_FromSize_t(__pyx_v_a->data->ptr); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2169, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2169, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);

      /* "cupy/core/core.pyx":2170
 *                 1,  # transpose newarray
 *                 m, n, 1., a.data.ptr, n, 0., a.data.ptr, n,
 *                 newarray.data.ptr, m)             # <<<<<<<<<<<<<<
 *         elif a.dtype == numpy.float64:
 *             cuda.cublas.dgeam(
 */
      __pyx_t_15 = __Pyx_PyInt_FromSize_t(__pyx_v_newarray->data->ptr); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2170, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_16 = __Pyx_PyInt_From_int(__pyx_v_m); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 2170, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_17 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_17)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_17);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_9 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[14] = {__pyx_t_17, __pyx_t_10, __pyx_int_1, __pyx_int_1, __pyx_t_3, __pyx_t_4, __pyx_float_1_, __pyx_t_11, __pyx_t_12, __pyx_float_0_, __pyx_t_13, __pyx_t_14, __pyx_t_15, __pyx_t_16};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 13+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2165, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[14] = {__pyx_t_17, __pyx_t_10, __pyx_int_1, __pyx_int_1, __pyx_t_3, __pyx_t_4, __pyx_float_1_, __pyx_t_11, __pyx_t_12, __pyx_float_0_, __pyx_t_13, __pyx_t_14, __pyx_t_15, __pyx_t_16};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 13+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2165, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      } else
      #endif
      {
        __pyx_t_18 = PyTuple_New(13+__pyx_t_9); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2165, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_18);
        if (__pyx_t_17) {
          __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_17); __pyx_t_17 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_18, 0+__pyx_t_9, __pyx_t_10);
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_18, 1+__pyx_t_9, __pyx_int_1);
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_18, 2+__pyx_t_9, __pyx_int_1);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_18, 3+__pyx_t_9, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_18, 4+__pyx_t_9, __pyx_t_4);
        __Pyx_INCREF(__pyx_float_1_);
        __Pyx_GIVEREF(__pyx_float_1_);
        PyTuple_SET_ITEM(__pyx_t_18, 5+__pyx_t_9, __pyx_float_1_);
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_18, 6+__pyx_t_9, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_18, 7+__pyx_t_9, __pyx_t_12);
        __Pyx_INCREF(__pyx_float_0_);
        __Pyx_GIVEREF(__pyx_float_0_);
        PyTuple_SET_ITEM(__pyx_t_18, 8+__pyx_t_9, __pyx_float_0_);
        __Pyx_GIVEREF(__pyx_t_13);
        PyTuple_SET_ITEM(__pyx_t_18, 9+__pyx_t_9, __pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_18, 10+__pyx_t_9, __pyx_t_14);
        __Pyx_GIVEREF(__pyx_t_15);
        PyTuple_SET_ITEM(__pyx_t_18, 11+__pyx_t_9, __pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_16);
        PyTuple_SET_ITEM(__pyx_t_18, 12+__pyx_t_9, __pyx_t_16);
        __pyx_t_10 = 0;
        __pyx_t_3 = 0;
        __pyx_t_4 = 0;
        __pyx_t_11 = 0;
        __pyx_t_12 = 0;
        __pyx_t_13 = 0;
        __pyx_t_14 = 0;
        __pyx_t_15 = 0;
        __pyx_t_16 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_18, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2165, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/core.pyx":2164
 *             a.ndim == 2 and dtype == a.dtype):
 *         m, n = a.shape
 *         if a.dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *             cuda.cublas.sgeam(
 *                 cuda.Device().cublas_handle,
 */
      goto __pyx_L16;
    }

    /* "cupy/core/core.pyx":2171
 *                 m, n, 1., a.data.ptr, n, 0., a.data.ptr, n,
 *                 newarray.data.ptr, m)
 *         elif a.dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *             cuda.cublas.dgeam(
 *                 cuda.Device().cublas_handle,
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2171, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2171, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_RichCompare(__pyx_v_a->dtype, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2171, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2171, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2172
 *                 newarray.data.ptr, m)
 *         elif a.dtype == numpy.float64:
 *             cuda.cublas.dgeam(             # <<<<<<<<<<<<<<
 *                 cuda.Device().cublas_handle,
 *                 1,  # transpose a
 */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2172, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_cublas); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2172, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_n_s_dgeam); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2172, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

      /* "cupy/core/core.pyx":2173
 *         elif a.dtype == numpy.float64:
 *             cuda.cublas.dgeam(
 *                 cuda.Device().cublas_handle,             # <<<<<<<<<<<<<<
 *                 1,  # transpose a
 *                 1,  # transpose newarray
 */
      __pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 2173, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_Device); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2173, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_16 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
        __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_15);
        if (likely(__pyx_t_16)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_16);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_15, function);
        }
      }
      if (__pyx_t_16) {
        __pyx_t_18 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_16); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2173, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      } else {
        __pyx_t_18 = __Pyx_PyObject_CallNoArg(__pyx_t_15); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2173, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_18);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_n_s_cublas_handle); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2173, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

      /* "cupy/core/core.pyx":2176
 *                 1,  # transpose a
 *                 1,  # transpose newarray
 *                 m, n, 1., a.data.ptr, n, 0., a.data.ptr, n,             # <<<<<<<<<<<<<<
 *                 newarray.data.ptr, m)
 *         return newarray
 */
      __pyx_t_18 = __Pyx_PyInt_From_int(__pyx_v_m); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2176, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      __pyx_t_16 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 2176, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_14 = __Pyx_PyInt_FromSize_t(__pyx_v_a->data->ptr); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2176, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2176, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_12 = __Pyx_PyInt_FromSize_t(__pyx_v_a->data->ptr); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2176, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2176, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);

      /* "cupy/core/core.pyx":2177
 *                 1,  # transpose newarray
 *                 m, n, 1., a.data.ptr, n, 0., a.data.ptr, n,
 *                 newarray.data.ptr, m)             # <<<<<<<<<<<<<<
 *         return newarray
 *     else:
 */
      __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_newarray->data->ptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2177, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_m); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2177, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_9 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[14] = {__pyx_t_10, __pyx_t_15, __pyx_int_1, __pyx_int_1, __pyx_t_18, __pyx_t_16, __pyx_float_1_, __pyx_t_14, __pyx_t_13, __pyx_float_0_, __pyx_t_12, __pyx_t_11, __pyx_t_4, __pyx_t_3};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 13+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2172, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[14] = {__pyx_t_10, __pyx_t_15, __pyx_int_1, __pyx_int_1, __pyx_t_18, __pyx_t_16, __pyx_float_1_, __pyx_t_14, __pyx_t_13, __pyx_float_0_, __pyx_t_12, __pyx_t_11, __pyx_t_4, __pyx_t_3};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 13+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2172, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      {
        __pyx_t_17 = PyTuple_New(13+__pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2172, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_17);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_15);
        PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_9, __pyx_t_15);
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_9, __pyx_int_1);
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_17, 2+__pyx_t_9, __pyx_int_1);
        __Pyx_GIVEREF(__pyx_t_18);
        PyTuple_SET_ITEM(__pyx_t_17, 3+__pyx_t_9, __pyx_t_18);
        __Pyx_GIVEREF(__pyx_t_16);
        PyTuple_SET_ITEM(__pyx_t_17, 4+__pyx_t_9, __pyx_t_16);
        __Pyx_INCREF(__pyx_float_1_);
        __Pyx_GIVEREF(__pyx_float_1_);
        PyTuple_SET_ITEM(__pyx_t_17, 5+__pyx_t_9, __pyx_float_1_);
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_17, 6+__pyx_t_9, __pyx_t_14);
        __Pyx_GIVEREF(__pyx_t_13);
        PyTuple_SET_ITEM(__pyx_t_17, 7+__pyx_t_9, __pyx_t_13);
        __Pyx_INCREF(__pyx_float_0_);
        __Pyx_GIVEREF(__pyx_float_0_);
        PyTuple_SET_ITEM(__pyx_t_17, 8+__pyx_t_9, __pyx_float_0_);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_17, 9+__pyx_t_9, __pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_17, 10+__pyx_t_9, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_17, 11+__pyx_t_9, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_17, 12+__pyx_t_9, __pyx_t_3);
        __pyx_t_15 = 0;
        __pyx_t_18 = 0;
        __pyx_t_16 = 0;
        __pyx_t_14 = 0;
        __pyx_t_13 = 0;
        __pyx_t_12 = 0;
        __pyx_t_11 = 0;
        __pyx_t_4 = 0;
        __pyx_t_3 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_17, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2172, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/core.pyx":2171
 *                 m, n, 1., a.data.ptr, n, 0., a.data.ptr, n,
 *                 newarray.data.ptr, m)
 *         elif a.dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *             cuda.cublas.dgeam(
 *                 cuda.Device().cublas_handle,
 */
    }
    __pyx_L16:;

    /* "cupy/core/core.pyx":2178
 *                 m, n, 1., a.data.ptr, n, 0., a.data.ptr, n,
 *                 newarray.data.ptr, m)
 *         return newarray             # <<<<<<<<<<<<<<
 *     else:
 *         elementwise_copy(a, newarray)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
    __pyx_r = __pyx_v_newarray;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2160
 * 
 *     newarray = ndarray(a.shape, dtype, order='F')
 *     if (a.flags.c_contiguous and             # <<<<<<<<<<<<<<
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64) and
 *             a.ndim == 2 and dtype == a.dtype):
 */
  }

  /* "cupy/core/core.pyx":2180
 *         return newarray
 *     else:
 *         elementwise_copy(a, newarray)             # <<<<<<<<<<<<<<
 *         return newarray
 * 
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2180, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_17 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_17)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_17);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[3] = {__pyx_t_17, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2180, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[3] = {__pyx_t_17, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2180, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2180, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_17) {
        __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_17); __pyx_t_17 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, ((PyObject *)__pyx_v_a));
      __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_newarray));
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, ((PyObject *)__pyx_v_newarray));
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2180, __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_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2181
 *     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":2146
 * 
 * 
 * cpdef ndarray asfortranarray(ndarray a, dtype=None):             # <<<<<<<<<<<<<<
 *     cdef ndarray newarray
 *     cdef int m, n
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_AddTraceback("cupy.core.core.asfortranarray", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_newarray);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_55asfortranarray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_54asfortranarray[] = "asfortranarray(ndarray a, dtype=None) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_55asfortranarray(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] = PyDict_GetItem(__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 = PyDict_GetItem(__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, 2146, __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, 2146, __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, 2146, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_54asfortranarray(__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_54asfortranarray(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, 2146, __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":2188
 * # -----------------------------------------------------------------------------
 * 
 * def _has_element(vector.vector[Py_ssize_t] source, Py_ssize_t n):             # <<<<<<<<<<<<<<
 *     for elem in source:
 *         if elem == n:
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_57_has_element(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_56_has_element[] = "_has_element(vector[Py_ssize_t] source, Py_ssize_t n)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_57_has_element = {"_has_element", (PyCFunction)__pyx_pw_4cupy_4core_4core_57_has_element, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_56_has_element};
static PyObject *__pyx_pw_4cupy_4core_4core_57_has_element(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  std::vector<Py_ssize_t>  __pyx_v_source;
  Py_ssize_t __pyx_v_n;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_has_element (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_source,&__pyx_n_s_n,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_source)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_has_element", 1, 2, 2, 1); __PYX_ERR(0, 2188, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_has_element") < 0)) __PYX_ERR(0, 2188, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_source = __pyx_convert_vector_from_py_Py_ssize_t(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2188, __pyx_L3_error)
    __pyx_v_n = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_n == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2188, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_has_element", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2188, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._has_element", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_56_has_element(__pyx_self, __pyx_v_source, __pyx_v_n);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_56_has_element(CYTHON_UNUSED PyObject *__pyx_self, std::vector<Py_ssize_t>  __pyx_v_source, Py_ssize_t __pyx_v_n) {
  Py_ssize_t __pyx_v_elem;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  std::vector<Py_ssize_t> ::iterator __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("_has_element", 0);

  /* "cupy/core/core.pyx":2189
 * 
 * def _has_element(vector.vector[Py_ssize_t] source, Py_ssize_t n):
 *     for elem in source:             # <<<<<<<<<<<<<<
 *         if elem == n:
 *             return True
 */
  __pyx_t_1 = __pyx_v_source.begin();
  for (;;) {
    if (!(__pyx_t_1 != __pyx_v_source.end())) break;
    __pyx_t_2 = *__pyx_t_1;
    ++__pyx_t_1;
    __pyx_v_elem = __pyx_t_2;

    /* "cupy/core/core.pyx":2190
 * def _has_element(vector.vector[Py_ssize_t] source, Py_ssize_t n):
 *     for elem in source:
 *         if elem == n:             # <<<<<<<<<<<<<<
 *             return True
 *     return False
 */
    __pyx_t_3 = ((__pyx_v_elem == __pyx_v_n) != 0);
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":2191
 *     for elem in source:
 *         if elem == n:
 *             return True             # <<<<<<<<<<<<<<
 *     return False
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2190
 * def _has_element(vector.vector[Py_ssize_t] source, Py_ssize_t n):
 *     for elem in source:
 *         if elem == n:             # <<<<<<<<<<<<<<
 *             return True
 *     return False
 */
    }

    /* "cupy/core/core.pyx":2189
 * 
 * def _has_element(vector.vector[Py_ssize_t] source, Py_ssize_t n):
 *     for elem in source:             # <<<<<<<<<<<<<<
 *         if elem == n:
 *             return True
 */
  }

  /* "cupy/core/core.pyx":2192
 *         if elem == n:
 *             return True
 *     return False             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_False);
  __pyx_r = Py_False;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2188
 * # -----------------------------------------------------------------------------
 * 
 * def _has_element(vector.vector[Py_ssize_t] source, Py_ssize_t n):             # <<<<<<<<<<<<<<
 *     for elem in source:
 *         if elem == n:
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2195
 * 
 * 
 * cpdef vector.vector[Py_ssize_t] normalize_axis_tuple(axis, Py_ssize_t ndim) \             # <<<<<<<<<<<<<<
 *         except *:
 *     """Normalizes an axis argument into a tuple of non-negative integer axes.
 */

static PyObject *__pyx_pw_4cupy_4core_4core_59normalize_axis_tuple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static std::vector<Py_ssize_t>  __pyx_f_4cupy_4core_4core_normalize_axis_tuple(PyObject *__pyx_v_axis, Py_ssize_t __pyx_v_ndim, CYTHON_UNUSED int __pyx_skip_dispatch) {
  std::vector<Py_ssize_t>  __pyx_v_ret;
  PyObject *__pyx_v_ax = NULL;
  std::vector<Py_ssize_t>  __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  Py_ssize_t __pyx_t_14;
  __Pyx_RefNannySetupContext("normalize_axis_tuple", 0);
  __Pyx_INCREF(__pyx_v_axis);

  /* "cupy/core/core.pyx":2200
 * 
 *     """
 *     if numpy.isscalar(axis):             # <<<<<<<<<<<<<<
 *         axis = (axis,)
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_isscalar); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_axis); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2200, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_axis};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2200, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_axis};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2200, __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, 2200, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_axis);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2200, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2200, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":2201
 *     """
 *     if numpy.isscalar(axis):
 *         axis = (axis,)             # <<<<<<<<<<<<<<
 * 
 *     cdef vector.vector[Py_ssize_t] ret
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2201, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_axis);
    __Pyx_GIVEREF(__pyx_v_axis);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_axis);
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2200
 * 
 *     """
 *     if numpy.isscalar(axis):             # <<<<<<<<<<<<<<
 *         axis = (axis,)
 * 
 */
  }

  /* "cupy/core/core.pyx":2204
 * 
 *     cdef vector.vector[Py_ssize_t] ret
 *     for ax in axis:             # <<<<<<<<<<<<<<
 *         if ax >= ndim or ax < -ndim:
 *             raise _AxisError('axis {} is out of bounds for array of '
 */
  if (likely(PyList_CheckExact(__pyx_v_axis)) || PyTuple_CheckExact(__pyx_v_axis)) {
    __pyx_t_1 = __pyx_v_axis; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_axis); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2204, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2204, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 2204, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2204, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 2204, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2204, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2204, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_ax, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2205
 *     cdef vector.vector[Py_ssize_t] ret
 *     for ax in axis:
 *         if ax >= ndim or ax < -ndim:             # <<<<<<<<<<<<<<
 *             raise _AxisError('axis {} is out of bounds for array of '
 *                              'dimension {}'.format(ax, ndim))
 */
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2205, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_ax, __pyx_t_3, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2205, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 2205, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!__pyx_t_8) {
    } else {
      __pyx_t_5 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_4 = PyInt_FromSsize_t((-__pyx_v_ndim)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2205, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_ax, __pyx_t_4, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2205, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 2205, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = __pyx_t_8;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_5) {

      /* "cupy/core/core.pyx":2206
 *     for ax in axis:
 *         if ax >= ndim or ax < -ndim:
 *             raise _AxisError('axis {} is out of bounds for array of '             # <<<<<<<<<<<<<<
 *                              'dimension {}'.format(ax, ndim))
 *         ret.push_back(ax % ndim)
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2206, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);

      /* "cupy/core/core.pyx":2207
 *         if ax >= ndim or ax < -ndim:
 *             raise _AxisError('axis {} is out of bounds for array of '
 *                              'dimension {}'.format(ax, ndim))             # <<<<<<<<<<<<<<
 *         ret.push_back(ax % ndim)
 *     return ret
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_axis_is_out_of_bounds_for_array, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2207, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2207, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = NULL;
      __pyx_t_12 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_12 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_v_ax, __pyx_t_10};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2207, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_v_ax, __pyx_t_10};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2207, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else
      #endif
      {
        __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2207, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        if (__pyx_t_11) {
          __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11); __pyx_t_11 = NULL;
        }
        __Pyx_INCREF(__pyx_v_ax);
        __Pyx_GIVEREF(__pyx_v_ax);
        PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_v_ax);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_10);
        __pyx_t_10 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2207, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_9) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2206, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_2};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2206, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_2};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2206, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        } else
        #endif
        {
          __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2206, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_9); __pyx_t_9 = NULL;
          __Pyx_GIVEREF(__pyx_t_2);
          PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_2);
          __pyx_t_2 = 0;
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2206, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 2206, __pyx_L1_error)

      /* "cupy/core/core.pyx":2205
 *     cdef vector.vector[Py_ssize_t] ret
 *     for ax in axis:
 *         if ax >= ndim or ax < -ndim:             # <<<<<<<<<<<<<<
 *             raise _AxisError('axis {} is out of bounds for array of '
 *                              'dimension {}'.format(ax, ndim))
 */
    }

    /* "cupy/core/core.pyx":2208
 *             raise _AxisError('axis {} is out of bounds for array of '
 *                              'dimension {}'.format(ax, ndim))
 *         ret.push_back(ax % ndim)             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2208, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Remainder(__pyx_v_ax, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2208, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2208, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    try {
      __pyx_v_ret.push_back(__pyx_t_14);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2208, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2204
 * 
 *     cdef vector.vector[Py_ssize_t] ret
 *     for ax in axis:             # <<<<<<<<<<<<<<
 *         if ax >= ndim or ax < -ndim:
 *             raise _AxisError('axis {} is out of bounds for array of '
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2209
 *                              'dimension {}'.format(ax, ndim))
 *         ret.push_back(ax % ndim)
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2195
 * 
 * 
 * cpdef vector.vector[Py_ssize_t] normalize_axis_tuple(axis, Py_ssize_t ndim) \             # <<<<<<<<<<<<<<
 *         except *:
 *     """Normalizes an axis argument into a tuple of non-negative integer axes.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("cupy.core.core.normalize_axis_tuple", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ax);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_59normalize_axis_tuple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_58normalize_axis_tuple[] = "normalize_axis_tuple(axis, Py_ssize_t ndim) -> vector[Py_ssize_t]\nNormalizes an axis argument into a tuple of non-negative integer axes.\n\n    ";
static PyObject *__pyx_pw_4cupy_4core_4core_59normalize_axis_tuple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  Py_ssize_t __pyx_v_ndim;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("normalize_axis_tuple (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_ndim,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ndim)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("normalize_axis_tuple", 1, 2, 2, 1); __PYX_ERR(0, 2195, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "normalize_axis_tuple") < 0)) __PYX_ERR(0, 2195, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_axis = values[0];
    __pyx_v_ndim = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_ndim == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2195, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("normalize_axis_tuple", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2195, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.normalize_axis_tuple", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_58normalize_axis_tuple(__pyx_self, __pyx_v_axis, __pyx_v_ndim);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_58normalize_axis_tuple(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_axis, Py_ssize_t __pyx_v_ndim) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  std::vector<Py_ssize_t>  __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("normalize_axis_tuple", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_normalize_axis_tuple(__pyx_v_axis, __pyx_v_ndim, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2195, __pyx_L1_error)
  __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.normalize_axis_tuple", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2212
 * 
 * 
 * cpdef ndarray moveaxis(ndarray a, source, destination):             # <<<<<<<<<<<<<<
 *     cdef vector.vector[Py_ssize_t] src = normalize_axis_tuple(source, a.ndim)
 *     cdef vector.vector[Py_ssize_t] dest = normalize_axis_tuple(destination,
 */

static PyObject *__pyx_pw_4cupy_4core_4core_61moveaxis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_moveaxis(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_source, PyObject *__pyx_v_destination, CYTHON_UNUSED int __pyx_skip_dispatch) {
  std::vector<Py_ssize_t>  __pyx_v_src;
  std::vector<Py_ssize_t>  __pyx_v_dest;
  std::vector<Py_ssize_t>  __pyx_v_order;
  Py_ssize_t __pyx_v_n;
  PyObject *__pyx_v_i = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  std::vector<Py_ssize_t>  __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  __Pyx_RefNannySetupContext("moveaxis", 0);

  /* "cupy/core/core.pyx":2213
 * 
 * cpdef ndarray moveaxis(ndarray a, source, destination):
 *     cdef vector.vector[Py_ssize_t] src = normalize_axis_tuple(source, a.ndim)             # <<<<<<<<<<<<<<
 *     cdef vector.vector[Py_ssize_t] dest = normalize_axis_tuple(destination,
 *                                                                a.ndim)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2213, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_f_4cupy_4core_4core_normalize_axis_tuple(__pyx_v_source, __pyx_t_2, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2213, __pyx_L1_error)
  __pyx_v_src = __pyx_t_3;

  /* "cupy/core/core.pyx":2215
 *     cdef vector.vector[Py_ssize_t] src = normalize_axis_tuple(source, a.ndim)
 *     cdef vector.vector[Py_ssize_t] dest = normalize_axis_tuple(destination,
 *                                                                a.ndim)             # <<<<<<<<<<<<<<
 * 
 *     if len(src) != len(dest):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2215, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2215, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2214
 * cpdef ndarray moveaxis(ndarray a, source, destination):
 *     cdef vector.vector[Py_ssize_t] src = normalize_axis_tuple(source, a.ndim)
 *     cdef vector.vector[Py_ssize_t] dest = normalize_axis_tuple(destination,             # <<<<<<<<<<<<<<
 *                                                                a.ndim)
 * 
 */
  __pyx_t_3 = __pyx_f_4cupy_4core_4core_normalize_axis_tuple(__pyx_v_destination, __pyx_t_2, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2214, __pyx_L1_error)
  __pyx_v_dest = __pyx_t_3;

  /* "cupy/core/core.pyx":2217
 *                                                                a.ndim)
 * 
 *     if len(src) != len(dest):             # <<<<<<<<<<<<<<
 *         raise ValueError('`source` and `destination` arguments must have '
 *                          'the same number of elements')
 */
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_src); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 2217, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_dest); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 2217, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((__pyx_t_2 != __pyx_t_4) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":2218
 * 
 *     if len(src) != len(dest):
 *         raise ValueError('`source` and `destination` arguments must have '             # <<<<<<<<<<<<<<
 *                          'the same number of elements')
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__109, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2218, __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, 2218, __pyx_L1_error)

    /* "cupy/core/core.pyx":2217
 *                                                                a.ndim)
 * 
 *     if len(src) != len(dest):             # <<<<<<<<<<<<<<
 *         raise ValueError('`source` and `destination` arguments must have '
 *                          'the same number of elements')
 */
  }

  /* "cupy/core/core.pyx":2222
 * 
 *     cdef vector.vector[Py_ssize_t] order
 *     cdef Py_ssize_t n = 0             # <<<<<<<<<<<<<<
 *     for i in range(a.ndim):
 *         n = <Py_ssize_t>i
 */
  __pyx_v_n = 0;

  /* "cupy/core/core.pyx":2223
 *     cdef vector.vector[Py_ssize_t] order
 *     cdef Py_ssize_t n = 0
 *     for i in range(a.ndim):             # <<<<<<<<<<<<<<
 *         n = <Py_ssize_t>i
 *         if not _has_element(src, n):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_6 = __pyx_t_1; __Pyx_INCREF(__pyx_t_6); __pyx_t_4 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2223, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2223, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_6))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2223, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2223, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2223, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2223, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_7(__pyx_t_6);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2223, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2224
 *     cdef Py_ssize_t n = 0
 *     for i in range(a.ndim):
 *         n = <Py_ssize_t>i             # <<<<<<<<<<<<<<
 *         if not _has_element(src, n):
 *             order.push_back(n)
 */
    __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2224, __pyx_L1_error)
    __pyx_v_n = ((Py_ssize_t)__pyx_t_2);

    /* "cupy/core/core.pyx":2225
 *     for i in range(a.ndim):
 *         n = <Py_ssize_t>i
 *         if not _has_element(src, n):             # <<<<<<<<<<<<<<
 *             order.push_back(n)
 * 
 */
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_has_element); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2225, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_src); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2225, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2225, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = NULL;
    __pyx_t_12 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
        __pyx_t_12 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_9, __pyx_t_10};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2225, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_9, __pyx_t_10};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2225, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    {
      __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2225, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (__pyx_t_11) {
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11); __pyx_t_11 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_10);
      __pyx_t_9 = 0;
      __pyx_t_10 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2225, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2225, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_14 = ((!__pyx_t_5) != 0);
    if (__pyx_t_14) {

      /* "cupy/core/core.pyx":2226
 *         n = <Py_ssize_t>i
 *         if not _has_element(src, n):
 *             order.push_back(n)             # <<<<<<<<<<<<<<
 * 
 *     for i in range(len(src)):
 */
      try {
        __pyx_v_order.push_back(__pyx_v_n);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 2226, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":2225
 *     for i in range(a.ndim):
 *         n = <Py_ssize_t>i
 *         if not _has_element(src, n):             # <<<<<<<<<<<<<<
 *             order.push_back(n)
 * 
 */
    }

    /* "cupy/core/core.pyx":2223
 *     cdef vector.vector[Py_ssize_t] order
 *     cdef Py_ssize_t n = 0
 *     for i in range(a.ndim):             # <<<<<<<<<<<<<<
 *         n = <Py_ssize_t>i
 *         if not _has_element(src, n):
 */
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":2228
 *             order.push_back(n)
 * 
 *     for i in range(len(src)):             # <<<<<<<<<<<<<<
 *         n = <Py_ssize_t>i
 *         order.insert(order.begin() + dest[n], src[n])
 */
  __pyx_t_6 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_src); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = PyObject_Length(__pyx_t_6); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 2228, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_6)) || PyTuple_CheckExact(__pyx_t_6)) {
    __pyx_t_1 = __pyx_t_6; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2228, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2228, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2228, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2228, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2228, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2228, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2228, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2229
 * 
 *     for i in range(len(src)):
 *         n = <Py_ssize_t>i             # <<<<<<<<<<<<<<
 *         order.insert(order.begin() + dest[n], src[n])
 * 
 */
    __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2229, __pyx_L1_error)
    __pyx_v_n = ((Py_ssize_t)__pyx_t_2);

    /* "cupy/core/core.pyx":2230
 *     for i in range(len(src)):
 *         n = <Py_ssize_t>i
 *         order.insert(order.begin() + dest[n], src[n])             # <<<<<<<<<<<<<<
 * 
 *     return a.transpose(order)
 */
    try {
      __pyx_v_order.insert((__pyx_v_order.begin() + (__pyx_v_dest[__pyx_v_n])), (__pyx_v_src[__pyx_v_n]));
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2230, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2228
 *             order.push_back(n)
 * 
 *     for i in range(len(src)):             # <<<<<<<<<<<<<<
 *         n = <Py_ssize_t>i
 *         order.insert(order.begin() + dest[n], src[n])
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2232
 *         order.insert(order.begin() + dest[n], src[n])
 * 
 *     return a.transpose(order)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_transpose_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2232, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_order); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2232, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_13 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_13) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2232, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_8};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2232, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_8};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2232, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2232, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_13); __pyx_t_13 = NULL;
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2232, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2232, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2212
 * 
 * 
 * cpdef ndarray moveaxis(ndarray a, source, destination):             # <<<<<<<<<<<<<<
 *     cdef vector.vector[Py_ssize_t] src = normalize_axis_tuple(source, a.ndim)
 *     cdef vector.vector[Py_ssize_t] dest = normalize_axis_tuple(destination,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("cupy.core.core.moveaxis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_61moveaxis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_60moveaxis[] = "moveaxis(ndarray a, source, destination) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_61moveaxis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_source = 0;
  PyObject *__pyx_v_destination = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("moveaxis (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_source,&__pyx_n_s_destination,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_source)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("moveaxis", 1, 3, 3, 1); __PYX_ERR(0, 2212, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_destination)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("moveaxis", 1, 3, 3, 2); __PYX_ERR(0, 2212, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "moveaxis") < 0)) __PYX_ERR(0, 2212, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_source = values[1];
    __pyx_v_destination = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("moveaxis", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2212, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.moveaxis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 2212, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_60moveaxis(__pyx_self, __pyx_v_a, __pyx_v_source, __pyx_v_destination);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_60moveaxis(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_source, PyObject *__pyx_v_destination) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("moveaxis", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_moveaxis(__pyx_v_a, __pyx_v_source, __pyx_v_destination, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.moveaxis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2235
 * 
 * 
 * cpdef ndarray rollaxis(ndarray a, Py_ssize_t axis, Py_ssize_t start=0):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, ndim = a.ndim
 *     cdef vector.vector[Py_ssize_t] axes
 */

static PyObject *__pyx_pw_4cupy_4core_4core_63rollaxis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_rollaxis(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, Py_ssize_t __pyx_v_axis, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_rollaxis *__pyx_optional_args) {
  Py_ssize_t __pyx_v_start = ((Py_ssize_t)0);
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_ndim;
  std::vector<Py_ssize_t>  __pyx_v_axes;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("rollaxis", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_start = __pyx_optional_args->start;
    }
  }

  /* "cupy/core/core.pyx":2236
 * 
 * cpdef ndarray rollaxis(ndarray a, Py_ssize_t axis, Py_ssize_t start=0):
 *     cdef Py_ssize_t i, ndim = a.ndim             # <<<<<<<<<<<<<<
 *     cdef vector.vector[Py_ssize_t] axes
 *     if axis < 0:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2236, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2236, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_2;

  /* "cupy/core/core.pyx":2238
 *     cdef Py_ssize_t i, ndim = a.ndim
 *     cdef vector.vector[Py_ssize_t] axes
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += ndim
 *     if start < 0:
 */
  __pyx_t_3 = ((__pyx_v_axis < 0) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2239
 *     cdef vector.vector[Py_ssize_t] axes
 *     if axis < 0:
 *         axis += ndim             # <<<<<<<<<<<<<<
 *     if start < 0:
 *         start += ndim
 */
    __pyx_v_axis = (__pyx_v_axis + __pyx_v_ndim);

    /* "cupy/core/core.pyx":2238
 *     cdef Py_ssize_t i, ndim = a.ndim
 *     cdef vector.vector[Py_ssize_t] axes
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += ndim
 *     if start < 0:
 */
  }

  /* "cupy/core/core.pyx":2240
 *     if axis < 0:
 *         axis += ndim
 *     if start < 0:             # <<<<<<<<<<<<<<
 *         start += ndim
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 */
  __pyx_t_3 = ((__pyx_v_start < 0) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2241
 *         axis += ndim
 *     if start < 0:
 *         start += ndim             # <<<<<<<<<<<<<<
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 *         raise ValueError('Axis out of range')
 */
    __pyx_v_start = (__pyx_v_start + __pyx_v_ndim);

    /* "cupy/core/core.pyx":2240
 *     if axis < 0:
 *         axis += ndim
 *     if start < 0:             # <<<<<<<<<<<<<<
 *         start += ndim
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 */
  }

  /* "cupy/core/core.pyx":2242
 *     if start < 0:
 *         start += ndim
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):             # <<<<<<<<<<<<<<
 *         raise ValueError('Axis out of range')
 *     if axis < start:
 */
  __pyx_t_4 = (0 <= __pyx_v_axis);
  if (__pyx_t_4) {
    __pyx_t_4 = (__pyx_v_axis < __pyx_v_ndim);
  }
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_5 = (0 <= __pyx_v_start);
  if (__pyx_t_5) {
    __pyx_t_5 = (__pyx_v_start <= __pyx_v_ndim);
  }
  __pyx_t_4 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L6_bool_binop_done:;
  __pyx_t_4 = ((!__pyx_t_3) != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":2243
 *         start += ndim
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 *         raise ValueError('Axis out of range')             # <<<<<<<<<<<<<<
 *     if axis < start:
 *         start -= 1
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__110, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2243, __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, 2243, __pyx_L1_error)

    /* "cupy/core/core.pyx":2242
 *     if start < 0:
 *         start += ndim
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):             # <<<<<<<<<<<<<<
 *         raise ValueError('Axis out of range')
 *     if axis < start:
 */
  }

  /* "cupy/core/core.pyx":2244
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 *         raise ValueError('Axis out of range')
 *     if axis < start:             # <<<<<<<<<<<<<<
 *         start -= 1
 *     if axis == start:
 */
  __pyx_t_4 = ((__pyx_v_axis < __pyx_v_start) != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":2245
 *         raise ValueError('Axis out of range')
 *     if axis < start:
 *         start -= 1             # <<<<<<<<<<<<<<
 *     if axis == start:
 *         return a
 */
    __pyx_v_start = (__pyx_v_start - 1);

    /* "cupy/core/core.pyx":2244
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 *         raise ValueError('Axis out of range')
 *     if axis < start:             # <<<<<<<<<<<<<<
 *         start -= 1
 *     if axis == start:
 */
  }

  /* "cupy/core/core.pyx":2246
 *     if axis < start:
 *         start -= 1
 *     if axis == start:             # <<<<<<<<<<<<<<
 *         return a
 *     if ndim == 2:
 */
  __pyx_t_4 = ((__pyx_v_axis == __pyx_v_start) != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":2247
 *         start -= 1
 *     if axis == start:
 *         return a             # <<<<<<<<<<<<<<
 *     if ndim == 2:
 *         return a._transpose(axes)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2246
 *     if axis < start:
 *         start -= 1
 *     if axis == start:             # <<<<<<<<<<<<<<
 *         return a
 *     if ndim == 2:
 */
  }

  /* "cupy/core/core.pyx":2248
 *     if axis == start:
 *         return a
 *     if ndim == 2:             # <<<<<<<<<<<<<<
 *         return a._transpose(axes)
 * 
 */
  __pyx_t_4 = ((__pyx_v_ndim == 2) != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":2249
 *         return a
 *     if ndim == 2:
 *         return a._transpose(axes)             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim):
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->_transpose(__pyx_v_a, __pyx_v_axes, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2249, __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":2248
 *     if axis == start:
 *         return a
 *     if ndim == 2:             # <<<<<<<<<<<<<<
 *         return a._transpose(axes)
 * 
 */
  }

  /* "cupy/core/core.pyx":2251
 *         return a._transpose(axes)
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         axes.push_back(i)
 *     axes.erase(axes.begin() + axis)
 */
  __pyx_t_2 = __pyx_v_ndim;
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_2; __pyx_t_6+=1) {
    __pyx_v_i = __pyx_t_6;

    /* "cupy/core/core.pyx":2252
 * 
 *     for i in range(ndim):
 *         axes.push_back(i)             # <<<<<<<<<<<<<<
 *     axes.erase(axes.begin() + axis)
 *     axes.insert(axes.begin() + start, axis)
 */
    try {
      __pyx_v_axes.push_back(__pyx_v_i);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2252, __pyx_L1_error)
    }
  }

  /* "cupy/core/core.pyx":2253
 *     for i in range(ndim):
 *         axes.push_back(i)
 *     axes.erase(axes.begin() + axis)             # <<<<<<<<<<<<<<
 *     axes.insert(axes.begin() + start, axis)
 *     return a._transpose(axes)
 */
  __pyx_v_axes.erase((__pyx_v_axes.begin() + __pyx_v_axis));

  /* "cupy/core/core.pyx":2254
 *         axes.push_back(i)
 *     axes.erase(axes.begin() + axis)
 *     axes.insert(axes.begin() + start, axis)             # <<<<<<<<<<<<<<
 *     return a._transpose(axes)
 * 
 */
  try {
    __pyx_v_axes.insert((__pyx_v_axes.begin() + __pyx_v_start), __pyx_v_axis);
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 2254, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":2255
 *     axes.erase(axes.begin() + axis)
 *     axes.insert(axes.begin() + start, axis)
 *     return a._transpose(axes)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->_transpose(__pyx_v_a, __pyx_v_axes, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2255, __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":2235
 * 
 * 
 * cpdef ndarray rollaxis(ndarray a, Py_ssize_t axis, Py_ssize_t start=0):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, ndim = a.ndim
 *     cdef vector.vector[Py_ssize_t] axes
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.rollaxis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_63rollaxis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_62rollaxis[] = "rollaxis(ndarray a, Py_ssize_t axis, Py_ssize_t start=0) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_63rollaxis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  Py_ssize_t __pyx_v_axis;
  Py_ssize_t __pyx_v_start;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rollaxis (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_axis,&__pyx_n_s_start,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rollaxis", 0, 2, 3, 1); __PYX_ERR(0, 2235, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rollaxis") < 0)) __PYX_ERR(0, 2235, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_axis = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_axis == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2235, __pyx_L3_error)
    if (values[2]) {
      __pyx_v_start = __Pyx_PyIndex_AsSsize_t(values[2]); if (unlikely((__pyx_v_start == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2235, __pyx_L3_error)
    } else {
      __pyx_v_start = ((Py_ssize_t)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("rollaxis", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2235, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.rollaxis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 2235, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_62rollaxis(__pyx_self, __pyx_v_a, __pyx_v_axis, __pyx_v_start);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_62rollaxis(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, Py_ssize_t __pyx_v_axis, Py_ssize_t __pyx_v_start) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_rollaxis __pyx_t_2;
  __Pyx_RefNannySetupContext("rollaxis", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.start = __pyx_v_start;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_rollaxis(__pyx_v_a, __pyx_v_axis, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2235, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.rollaxis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2258
 * 
 * 
 * def array_split(ndarray ary, indices_or_sections, Py_ssize_t axis):             # <<<<<<<<<<<<<<
 * 
 *     cdef Py_ssize_t i, ndim, size, each_size, index, prev, offset, stride
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_65array_split(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_64array_split[] = "array_split(ndarray ary, indices_or_sections, Py_ssize_t axis)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_65array_split = {"array_split", (PyCFunction)__pyx_pw_4cupy_4core_4core_65array_split, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_64array_split};
static PyObject *__pyx_pw_4cupy_4core_4core_65array_split(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ary = 0;
  PyObject *__pyx_v_indices_or_sections = 0;
  Py_ssize_t __pyx_v_axis;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("array_split (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ary,&__pyx_n_s_indices_or_sections,&__pyx_n_s_axis,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ary)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_indices_or_sections)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("array_split", 1, 3, 3, 1); __PYX_ERR(0, 2258, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("array_split", 1, 3, 3, 2); __PYX_ERR(0, 2258, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "array_split") < 0)) __PYX_ERR(0, 2258, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_ary = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_indices_or_sections = values[1];
    __pyx_v_axis = __Pyx_PyIndex_AsSsize_t(values[2]); if (unlikely((__pyx_v_axis == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2258, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("array_split", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2258, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.array_split", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ary), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "ary", 0))) __PYX_ERR(0, 2258, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_64array_split(__pyx_self, __pyx_v_ary, __pyx_v_indices_or_sections, __pyx_v_axis);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_64array_split(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ary, PyObject *__pyx_v_indices_or_sections, Py_ssize_t __pyx_v_axis) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_size;
  Py_ssize_t __pyx_v_each_size;
  Py_ssize_t __pyx_v_index;
  Py_ssize_t __pyx_v_prev;
  Py_ssize_t __pyx_v_stride;
  std::vector<Py_ssize_t>  __pyx_v_shape;
  PyObject *__pyx_v_indices = NULL;
  PyObject *__pyx_v_ret = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  long __pyx_t_8;
  std::vector<Py_ssize_t>  __pyx_t_9;
  PyObject *(*__pyx_t_10)(PyObject *);
  Py_ssize_t __pyx_t_11;
  int __pyx_t_12;
  __Pyx_RefNannySetupContext("array_split", 0);

  /* "cupy/core/core.pyx":2263
 *     cdef vector.vector[Py_ssize_t] shape
 * 
 *     ndim = ary.ndim             # <<<<<<<<<<<<<<
 *     if -ndim > axis or ndim <= axis:
 *         raise IndexError('Axis exceeds ndim')
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ary), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2263, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_2;

  /* "cupy/core/core.pyx":2264
 * 
 *     ndim = ary.ndim
 *     if -ndim > axis or ndim <= axis:             # <<<<<<<<<<<<<<
 *         raise IndexError('Axis exceeds ndim')
 *     if axis < 0:
 */
  __pyx_t_4 = (((-__pyx_v_ndim) > __pyx_v_axis) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_ndim <= __pyx_v_axis) != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2265
 *     ndim = ary.ndim
 *     if -ndim > axis or ndim <= axis:
 *         raise IndexError('Axis exceeds ndim')             # <<<<<<<<<<<<<<
 *     if axis < 0:
 *         axis += ndim
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__111, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2265, __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, 2265, __pyx_L1_error)

    /* "cupy/core/core.pyx":2264
 * 
 *     ndim = ary.ndim
 *     if -ndim > axis or ndim <= axis:             # <<<<<<<<<<<<<<
 *         raise IndexError('Axis exceeds ndim')
 *     if axis < 0:
 */
  }

  /* "cupy/core/core.pyx":2266
 *     if -ndim > axis or ndim <= axis:
 *         raise IndexError('Axis exceeds ndim')
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += ndim
 *     size = ary._shape[axis]
 */
  __pyx_t_3 = ((__pyx_v_axis < 0) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2267
 *         raise IndexError('Axis exceeds ndim')
 *     if axis < 0:
 *         axis += ndim             # <<<<<<<<<<<<<<
 *     size = ary._shape[axis]
 * 
 */
    __pyx_v_axis = (__pyx_v_axis + __pyx_v_ndim);

    /* "cupy/core/core.pyx":2266
 *     if -ndim > axis or ndim <= axis:
 *         raise IndexError('Axis exceeds ndim')
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += ndim
 *     size = ary._shape[axis]
 */
  }

  /* "cupy/core/core.pyx":2268
 *     if axis < 0:
 *         axis += ndim
 *     size = ary._shape[axis]             # <<<<<<<<<<<<<<
 * 
 *     if numpy.isscalar(indices_or_sections):
 */
  __pyx_v_size = (__pyx_v_ary->_shape[__pyx_v_axis]);

  /* "cupy/core/core.pyx":2270
 *     size = ary._shape[axis]
 * 
 *     if numpy.isscalar(indices_or_sections):             # <<<<<<<<<<<<<<
 *         each_size = (size - 1) // indices_or_sections + 1
 *         indices = [i * each_size
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_isscalar); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_indices_or_sections); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2270, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_indices_or_sections};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2270, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_indices_or_sections};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2270, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2270, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_INCREF(__pyx_v_indices_or_sections);
      __Pyx_GIVEREF(__pyx_v_indices_or_sections);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_indices_or_sections);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2270, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2270, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2271
 * 
 *     if numpy.isscalar(indices_or_sections):
 *         each_size = (size - 1) // indices_or_sections + 1             # <<<<<<<<<<<<<<
 *         indices = [i * each_size
 *                    for i in range(1, indices_or_sections)]
 */
    __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_size - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2271, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyNumber_FloorDivide(__pyx_t_1, __pyx_v_indices_or_sections); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2271, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_6, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2271, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2271, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_each_size = __pyx_t_2;

    /* "cupy/core/core.pyx":2272
 *     if numpy.isscalar(indices_or_sections):
 *         each_size = (size - 1) // indices_or_sections + 1
 *         indices = [i * each_size             # <<<<<<<<<<<<<<
 *                    for i in range(1, indices_or_sections)]
 *     else:
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2272, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "cupy/core/core.pyx":2273
 *         each_size = (size - 1) // indices_or_sections + 1
 *         indices = [i * each_size
 *                    for i in range(1, indices_or_sections)]             # <<<<<<<<<<<<<<
 *     else:
 *         indices = indices_or_sections
 */
    __pyx_t_8 = __Pyx_PyInt_As_long(__pyx_v_indices_or_sections); if (unlikely((__pyx_t_8 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 2273, __pyx_L1_error)
    for (__pyx_t_2 = 1; __pyx_t_2 < __pyx_t_8; __pyx_t_2+=1) {
      __pyx_v_i = __pyx_t_2;

      /* "cupy/core/core.pyx":2272
 *     if numpy.isscalar(indices_or_sections):
 *         each_size = (size - 1) // indices_or_sections + 1
 *         indices = [i * each_size             # <<<<<<<<<<<<<<
 *                    for i in range(1, indices_or_sections)]
 *     else:
 */
      __pyx_t_6 = PyInt_FromSsize_t((__pyx_v_i * __pyx_v_each_size)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2272, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 2272, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __pyx_v_indices = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2270
 *     size = ary._shape[axis]
 * 
 *     if numpy.isscalar(indices_or_sections):             # <<<<<<<<<<<<<<
 *         each_size = (size - 1) // indices_or_sections + 1
 *         indices = [i * each_size
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":2275
 *                    for i in range(1, indices_or_sections)]
 *     else:
 *         indices = indices_or_sections             # <<<<<<<<<<<<<<
 * 
 *     if len(indices) == 0:
 */
  /*else*/ {
    __Pyx_INCREF(__pyx_v_indices_or_sections);
    __pyx_v_indices = __pyx_v_indices_or_sections;
  }
  __pyx_L7:;

  /* "cupy/core/core.pyx":2277
 *         indices = indices_or_sections
 * 
 *     if len(indices) == 0:             # <<<<<<<<<<<<<<
 *         return [ary]
 * 
 */
  __pyx_t_2 = PyObject_Length(__pyx_v_indices); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 2277, __pyx_L1_error)
  __pyx_t_3 = ((__pyx_t_2 == 0) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2278
 * 
 *     if len(indices) == 0:
 *         return [ary]             # <<<<<<<<<<<<<<
 * 
 *     # Make a copy of shape for each view
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2278, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_ary));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_ary));
    PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_ary));
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2277
 *         indices = indices_or_sections
 * 
 *     if len(indices) == 0:             # <<<<<<<<<<<<<<
 *         return [ary]
 * 
 */
  }

  /* "cupy/core/core.pyx":2281
 * 
 *     # Make a copy of shape for each view
 *     shape = ary._shape             # <<<<<<<<<<<<<<
 * 
 *     prev = 0
 */
  __pyx_t_9 = __pyx_v_ary->_shape;
  __pyx_v_shape = __pyx_t_9;

  /* "cupy/core/core.pyx":2283
 *     shape = ary._shape
 * 
 *     prev = 0             # <<<<<<<<<<<<<<
 *     ret = []
 *     stride = ary._strides[axis]
 */
  __pyx_v_prev = 0;

  /* "cupy/core/core.pyx":2284
 * 
 *     prev = 0
 *     ret = []             # <<<<<<<<<<<<<<
 *     stride = ary._strides[axis]
 *     for index in indices:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2285
 *     prev = 0
 *     ret = []
 *     stride = ary._strides[axis]             # <<<<<<<<<<<<<<
 *     for index in indices:
 *         shape[axis] = index - prev
 */
  __pyx_v_stride = (__pyx_v_ary->_strides[__pyx_v_axis]);

  /* "cupy/core/core.pyx":2286
 *     ret = []
 *     stride = ary._strides[axis]
 *     for index in indices:             # <<<<<<<<<<<<<<
 *         shape[axis] = index - prev
 *         v = ary.view()
 */
  if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) {
    __pyx_t_1 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_10 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2286, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2286, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_10)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_6); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2286, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2286, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_6); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2286, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2286, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_10(__pyx_t_1);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2286, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __pyx_t_11 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_11 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2286, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_index = __pyx_t_11;

    /* "cupy/core/core.pyx":2287
 *     stride = ary._strides[axis]
 *     for index in indices:
 *         shape[axis] = index - prev             # <<<<<<<<<<<<<<
 *         v = ary.view()
 *         v.data = ary.data + prev * stride
 */
    (__pyx_v_shape[__pyx_v_axis]) = (__pyx_v_index - __pyx_v_prev);

    /* "cupy/core/core.pyx":2288
 *     for index in indices:
 *         shape[axis] = index - prev
 *         v = ary.view()             # <<<<<<<<<<<<<<
 *         v.data = ary.data + prev * stride
 *         v._set_shape_and_strides(shape, ary._strides)
 */
    __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ary->__pyx_vtab)->view(__pyx_v_ary, 0, NULL)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2288, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF_SET(__pyx_v_v, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6));
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2289
 *         shape[axis] = index - prev
 *         v = ary.view()
 *         v.data = ary.data + prev * stride             # <<<<<<<<<<<<<<
 *         v._set_shape_and_strides(shape, ary._strides)
 *         ret.append(v)
 */
    __pyx_t_6 = PyInt_FromSsize_t((__pyx_v_prev * __pyx_v_stride)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2289, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyNumber_Add(((PyObject *)__pyx_v_ary->data), __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2289, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer))))) __PYX_ERR(0, 2289, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_7);
    __Pyx_GOTREF(__pyx_v_v->data);
    __Pyx_DECREF(((PyObject *)__pyx_v_v->data));
    __pyx_v_v->data = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2290
 *         v = ary.view()
 *         v.data = ary.data + prev * stride
 *         v._set_shape_and_strides(shape, ary._strides)             # <<<<<<<<<<<<<<
 *         ret.append(v)
 * 
 */
    __pyx_t_7 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_v->__pyx_vtab)->_set_shape_and_strides(__pyx_v_v, __pyx_v_shape, __pyx_v_ary->_strides, 0, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2291
 *         v.data = ary.data + prev * stride
 *         v._set_shape_and_strides(shape, ary._strides)
 *         ret.append(v)             # <<<<<<<<<<<<<<
 * 
 *         prev = index
 */
    __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_ret, ((PyObject *)__pyx_v_v)); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 2291, __pyx_L1_error)

    /* "cupy/core/core.pyx":2293
 *         ret.append(v)
 * 
 *         prev = index             # <<<<<<<<<<<<<<
 * 
 *     shape[axis] = size - prev
 */
    __pyx_v_prev = __pyx_v_index;

    /* "cupy/core/core.pyx":2286
 *     ret = []
 *     stride = ary._strides[axis]
 *     for index in indices:             # <<<<<<<<<<<<<<
 *         shape[axis] = index - prev
 *         v = ary.view()
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2295
 *         prev = index
 * 
 *     shape[axis] = size - prev             # <<<<<<<<<<<<<<
 *     v = ary.view()
 *     v.data = ary.data + prev * stride
 */
  (__pyx_v_shape[__pyx_v_axis]) = (__pyx_v_size - __pyx_v_prev);

  /* "cupy/core/core.pyx":2296
 * 
 *     shape[axis] = size - prev
 *     v = ary.view()             # <<<<<<<<<<<<<<
 *     v.data = ary.data + prev * stride
 *     v._set_shape_and_strides(shape, ary._strides)
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ary->__pyx_vtab)->view(__pyx_v_ary, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XDECREF_SET(__pyx_v_v, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2297
 *     shape[axis] = size - prev
 *     v = ary.view()
 *     v.data = ary.data + prev * stride             # <<<<<<<<<<<<<<
 *     v._set_shape_and_strides(shape, ary._strides)
 *     ret.append(v)
 */
  __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_prev * __pyx_v_stride)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyNumber_Add(((PyObject *)__pyx_v_ary->data), __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer))))) __PYX_ERR(0, 2297, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_7);
  __Pyx_GOTREF(__pyx_v_v->data);
  __Pyx_DECREF(((PyObject *)__pyx_v_v->data));
  __pyx_v_v->data = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2298
 *     v = ary.view()
 *     v.data = ary.data + prev * stride
 *     v._set_shape_and_strides(shape, ary._strides)             # <<<<<<<<<<<<<<
 *     ret.append(v)
 * 
 */
  __pyx_t_7 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_v->__pyx_vtab)->_set_shape_and_strides(__pyx_v_v, __pyx_v_shape, __pyx_v_ary->_strides, 0, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2299
 *     v.data = ary.data + prev * stride
 *     v._set_shape_and_strides(shape, ary._strides)
 *     ret.append(v)             # <<<<<<<<<<<<<<
 * 
 *     return ret
 */
  __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_ret, ((PyObject *)__pyx_v_v)); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 2299, __pyx_L1_error)

  /* "cupy/core/core.pyx":2301
 *     ret.append(v)
 * 
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ret);
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2258
 * 
 * 
 * def array_split(ndarray ary, indices_or_sections, Py_ssize_t axis):             # <<<<<<<<<<<<<<
 * 
 *     cdef Py_ssize_t i, ndim, size, each_size, index, prev, offset, stride
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core.array_split", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_indices);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF((PyObject *)__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2332
 *         readonly Py_ssize_t nd
 * 
 *     def __init__(self, *arrays):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i, j, s, smin, smax, a_ndim, a_sh
 *         cdef vector.vector[Py_ssize_t] shape, strides, r_shape, r_strides
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_9broadcast_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_4core_4core_9broadcast_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_arrays = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_arrays = __pyx_args;
  __pyx_r = __pyx_pf_4cupy_4core_4core_9broadcast___init__(((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_v_self), __pyx_v_arrays);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_arrays);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_9broadcast___init__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self, PyObject *__pyx_v_arrays) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_j;
  Py_ssize_t __pyx_v_s;
  Py_ssize_t __pyx_v_smin;
  Py_ssize_t __pyx_v_smax;
  Py_ssize_t __pyx_v_a_ndim;
  Py_ssize_t __pyx_v_a_sh;
  std::vector<Py_ssize_t>  __pyx_v_shape;
  std::vector<Py_ssize_t>  __pyx_v_strides;
  std::vector<Py_ssize_t>  __pyx_v_r_shape;
  std::vector<Py_ssize_t>  __pyx_v_r_strides;
  std::vector<std::vector<Py_ssize_t> >  __pyx_v_shape_arr;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_view = 0;
  CYTHON_UNUSED PyObject *__pyx_v_rev = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_broadcasted = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  int __pyx_t_12;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/core.pyx":2337
 *         cdef vector.vector[vector.vector[Py_ssize_t]] shape_arr
 *         cdef ndarray a, view
 *         rev = slice(None, None, -1)             # <<<<<<<<<<<<<<
 * 
 *         self.nd = 0
 */
  __pyx_t_1 = __pyx_slice__112;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_rev = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2339
 *         rev = slice(None, None, -1)
 * 
 *         self.nd = 0             # <<<<<<<<<<<<<<
 *         for x in arrays:
 *             if not isinstance(x, ndarray):
 */
  __pyx_v_self->nd = 0;

  /* "cupy/core/core.pyx":2340
 * 
 *         self.nd = 0
 *         for x in arrays:             # <<<<<<<<<<<<<<
 *             if not isinstance(x, ndarray):
 *                 continue
 */
  __pyx_t_1 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2340, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2340, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2341
 *         self.nd = 0
 *         for x in arrays:
 *             if not isinstance(x, ndarray):             # <<<<<<<<<<<<<<
 *                 continue
 *             a = x
 */
    __pyx_t_4 = __Pyx_TypeCheck(__pyx_v_x, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_5 = ((!(__pyx_t_4 != 0)) != 0);
    if (__pyx_t_5) {

      /* "cupy/core/core.pyx":2342
 *         for x in arrays:
 *             if not isinstance(x, ndarray):
 *                 continue             # <<<<<<<<<<<<<<
 *             a = x
 *             self.nd = max(self.nd, <Py_ssize_t>a._shape.size())
 */
      goto __pyx_L3_continue;

      /* "cupy/core/core.pyx":2341
 *         self.nd = 0
 *         for x in arrays:
 *             if not isinstance(x, ndarray):             # <<<<<<<<<<<<<<
 *                 continue
 *             a = x
 */
    }

    /* "cupy/core/core.pyx":2343
 *             if not isinstance(x, ndarray):
 *                 continue
 *             a = x             # <<<<<<<<<<<<<<
 *             self.nd = max(self.nd, <Py_ssize_t>a._shape.size())
 *             r_shape.assign(a._shape.rbegin(), a._shape.rend())
 */
    if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2343, __pyx_L1_error)
    __pyx_t_3 = __pyx_v_x;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2344
 *                 continue
 *             a = x
 *             self.nd = max(self.nd, <Py_ssize_t>a._shape.size())             # <<<<<<<<<<<<<<
 *             r_shape.assign(a._shape.rbegin(), a._shape.rend())
 *             shape_arr.push_back(r_shape)
 */
    __pyx_t_6 = ((Py_ssize_t)__pyx_v_a->_shape.size());
    __pyx_t_7 = __pyx_v_self->nd;
    if (((__pyx_t_6 > __pyx_t_7) != 0)) {
      __pyx_t_8 = __pyx_t_6;
    } else {
      __pyx_t_8 = __pyx_t_7;
    }
    __pyx_v_self->nd = __pyx_t_8;

    /* "cupy/core/core.pyx":2345
 *             a = x
 *             self.nd = max(self.nd, <Py_ssize_t>a._shape.size())
 *             r_shape.assign(a._shape.rbegin(), a._shape.rend())             # <<<<<<<<<<<<<<
 *             shape_arr.push_back(r_shape)
 * 
 */
    try {
      __pyx_v_r_shape.assign(__pyx_v_a->_shape.rbegin(), __pyx_v_a->_shape.rend());
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2345, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2346
 *             self.nd = max(self.nd, <Py_ssize_t>a._shape.size())
 *             r_shape.assign(a._shape.rbegin(), a._shape.rend())
 *             shape_arr.push_back(r_shape)             # <<<<<<<<<<<<<<
 * 
 *         r_shape.clear()
 */
    try {
      __pyx_v_shape_arr.push_back(__pyx_v_r_shape);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2346, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2340
 * 
 *         self.nd = 0
 *         for x in arrays:             # <<<<<<<<<<<<<<
 *             if not isinstance(x, ndarray):
 *                 continue
 */
    __pyx_L3_continue:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2348
 *             shape_arr.push_back(r_shape)
 * 
 *         r_shape.clear()             # <<<<<<<<<<<<<<
 *         for i in range(self.nd):
 *             smin = PY_SSIZE_T_MAX
 */
  __pyx_v_r_shape.clear();

  /* "cupy/core/core.pyx":2349
 * 
 *         r_shape.clear()
 *         for i in range(self.nd):             # <<<<<<<<<<<<<<
 *             smin = PY_SSIZE_T_MAX
 *             smax = 0
 */
  __pyx_t_2 = __pyx_v_self->nd;
  for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_2; __pyx_t_8+=1) {
    __pyx_v_i = __pyx_t_8;

    /* "cupy/core/core.pyx":2350
 *         r_shape.clear()
 *         for i in range(self.nd):
 *             smin = PY_SSIZE_T_MAX             # <<<<<<<<<<<<<<
 *             smax = 0
 *             for j in range(<Py_ssize_t>shape_arr.size()):
 */
    __pyx_v_smin = __pyx_v_4cupy_4core_4core_PY_SSIZE_T_MAX;

    /* "cupy/core/core.pyx":2351
 *         for i in range(self.nd):
 *             smin = PY_SSIZE_T_MAX
 *             smax = 0             # <<<<<<<<<<<<<<
 *             for j in range(<Py_ssize_t>shape_arr.size()):
 *                 if i < <Py_ssize_t>shape_arr[j].size():
 */
    __pyx_v_smax = 0;

    /* "cupy/core/core.pyx":2352
 *             smin = PY_SSIZE_T_MAX
 *             smax = 0
 *             for j in range(<Py_ssize_t>shape_arr.size()):             # <<<<<<<<<<<<<<
 *                 if i < <Py_ssize_t>shape_arr[j].size():
 *                     s = shape_arr[j][i]
 */
    __pyx_t_6 = ((Py_ssize_t)__pyx_v_shape_arr.size());
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
      __pyx_v_j = __pyx_t_7;

      /* "cupy/core/core.pyx":2353
 *             smax = 0
 *             for j in range(<Py_ssize_t>shape_arr.size()):
 *                 if i < <Py_ssize_t>shape_arr[j].size():             # <<<<<<<<<<<<<<
 *                     s = shape_arr[j][i]
 *                     smin = min(smin, s)
 */
      __pyx_t_5 = ((__pyx_v_i < ((Py_ssize_t)(__pyx_v_shape_arr[__pyx_v_j]).size())) != 0);
      if (__pyx_t_5) {

        /* "cupy/core/core.pyx":2354
 *             for j in range(<Py_ssize_t>shape_arr.size()):
 *                 if i < <Py_ssize_t>shape_arr[j].size():
 *                     s = shape_arr[j][i]             # <<<<<<<<<<<<<<
 *                     smin = min(smin, s)
 *                     smax = max(smax, s)
 */
        __pyx_v_s = ((__pyx_v_shape_arr[__pyx_v_j])[__pyx_v_i]);

        /* "cupy/core/core.pyx":2355
 *                 if i < <Py_ssize_t>shape_arr[j].size():
 *                     s = shape_arr[j][i]
 *                     smin = min(smin, s)             # <<<<<<<<<<<<<<
 *                     smax = max(smax, s)
 *             if smin == 0 and smax > 1:
 */
        __pyx_t_9 = __pyx_v_s;
        __pyx_t_10 = __pyx_v_smin;
        if (((__pyx_t_9 < __pyx_t_10) != 0)) {
          __pyx_t_11 = __pyx_t_9;
        } else {
          __pyx_t_11 = __pyx_t_10;
        }
        __pyx_v_smin = __pyx_t_11;

        /* "cupy/core/core.pyx":2356
 *                     s = shape_arr[j][i]
 *                     smin = min(smin, s)
 *                     smax = max(smax, s)             # <<<<<<<<<<<<<<
 *             if smin == 0 and smax > 1:
 *                 raise ValueError(
 */
        __pyx_t_11 = __pyx_v_s;
        __pyx_t_9 = __pyx_v_smax;
        if (((__pyx_t_11 > __pyx_t_9) != 0)) {
          __pyx_t_10 = __pyx_t_11;
        } else {
          __pyx_t_10 = __pyx_t_9;
        }
        __pyx_v_smax = __pyx_t_10;

        /* "cupy/core/core.pyx":2353
 *             smax = 0
 *             for j in range(<Py_ssize_t>shape_arr.size()):
 *                 if i < <Py_ssize_t>shape_arr[j].size():             # <<<<<<<<<<<<<<
 *                     s = shape_arr[j][i]
 *                     smin = min(smin, s)
 */
      }
    }

    /* "cupy/core/core.pyx":2357
 *                     smin = min(smin, s)
 *                     smax = max(smax, s)
 *             if smin == 0 and smax > 1:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'shape mismatch: objects cannot be broadcast to a '
 */
    __pyx_t_4 = ((__pyx_v_smin == 0) != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L12_bool_binop_done;
    }
    __pyx_t_4 = ((__pyx_v_smax > 1) != 0);
    __pyx_t_5 = __pyx_t_4;
    __pyx_L12_bool_binop_done:;
    if (__pyx_t_5) {

      /* "cupy/core/core.pyx":2358
 *                     smax = max(smax, s)
 *             if smin == 0 and smax > 1:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'shape mismatch: objects cannot be broadcast to a '
 *                     'single shape')
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__113, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2358, __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, 2358, __pyx_L1_error)

      /* "cupy/core/core.pyx":2357
 *                     smin = min(smin, s)
 *                     smax = max(smax, s)
 *             if smin == 0 and smax > 1:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'shape mismatch: objects cannot be broadcast to a '
 */
    }

    /* "cupy/core/core.pyx":2361
 *                     'shape mismatch: objects cannot be broadcast to a '
 *                     'single shape')
 *             r_shape.push_back(0 if smin == 0 else smax)             # <<<<<<<<<<<<<<
 * 
 *         shape.assign(r_shape.rbegin(), r_shape.rend())
 */
    if (((__pyx_v_smin == 0) != 0)) {
      __pyx_t_6 = 0;
    } else {
      __pyx_t_6 = __pyx_v_smax;
    }
    try {
      __pyx_v_r_shape.push_back(__pyx_t_6);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2361, __pyx_L1_error)
    }
  }

  /* "cupy/core/core.pyx":2363
 *             r_shape.push_back(0 if smin == 0 else smax)
 * 
 *         shape.assign(r_shape.rbegin(), r_shape.rend())             # <<<<<<<<<<<<<<
 *         self.shape = tuple(shape)
 *         self.size = internal.prod_ssize_t(shape)
 */
  try {
    __pyx_v_shape.assign(__pyx_v_r_shape.rbegin(), __pyx_v_r_shape.rend());
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 2363, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":2364
 * 
 *         shape.assign(r_shape.rbegin(), r_shape.rend())
 *         self.shape = tuple(shape)             # <<<<<<<<<<<<<<
 *         self.size = internal.prod_ssize_t(shape)
 * 
 */
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->shape);
  __Pyx_DECREF(__pyx_v_self->shape);
  __pyx_v_self->shape = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2365
 *         shape.assign(r_shape.rbegin(), r_shape.rend())
 *         self.shape = tuple(shape)
 *         self.size = internal.prod_ssize_t(shape)             # <<<<<<<<<<<<<<
 * 
 *         broadcasted = []
 */
  __pyx_v_self->size = __pyx_f_4cupy_4core_8internal_prod_ssize_t(__pyx_v_shape, 0, NULL);

  /* "cupy/core/core.pyx":2367
 *         self.size = internal.prod_ssize_t(shape)
 * 
 *         broadcasted = []             # <<<<<<<<<<<<<<
 *         for x in arrays:
 *             if not isinstance(x, ndarray):
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_broadcasted = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2368
 * 
 *         broadcasted = []
 *         for x in arrays:             # <<<<<<<<<<<<<<
 *             if not isinstance(x, ndarray):
 *                 broadcasted.append(x)
 */
  __pyx_t_3 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2368, __pyx_L1_error)
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2368, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2369
 *         broadcasted = []
 *         for x in arrays:
 *             if not isinstance(x, ndarray):             # <<<<<<<<<<<<<<
 *                 broadcasted.append(x)
 *                 continue
 */
    __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_x, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_4 = ((!(__pyx_t_5 != 0)) != 0);
    if (__pyx_t_4) {

      /* "cupy/core/core.pyx":2370
 *         for x in arrays:
 *             if not isinstance(x, ndarray):
 *                 broadcasted.append(x)             # <<<<<<<<<<<<<<
 *                 continue
 *             a = x
 */
      __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_broadcasted, __pyx_v_x); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 2370, __pyx_L1_error)

      /* "cupy/core/core.pyx":2371
 *             if not isinstance(x, ndarray):
 *                 broadcasted.append(x)
 *                 continue             # <<<<<<<<<<<<<<
 *             a = x
 *             if internal.vector_equal(a._shape, shape):
 */
      goto __pyx_L14_continue;

      /* "cupy/core/core.pyx":2369
 *         broadcasted = []
 *         for x in arrays:
 *             if not isinstance(x, ndarray):             # <<<<<<<<<<<<<<
 *                 broadcasted.append(x)
 *                 continue
 */
    }

    /* "cupy/core/core.pyx":2372
 *                 broadcasted.append(x)
 *                 continue
 *             a = x             # <<<<<<<<<<<<<<
 *             if internal.vector_equal(a._shape, shape):
 *                 broadcasted.append(a)
 */
    if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2372, __pyx_L1_error)
    __pyx_t_1 = __pyx_v_x;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2373
 *                 continue
 *             a = x
 *             if internal.vector_equal(a._shape, shape):             # <<<<<<<<<<<<<<
 *                 broadcasted.append(a)
 *                 continue
 */
    __pyx_t_4 = (__pyx_f_4cupy_4core_8internal_vector_equal(__pyx_v_a->_shape, __pyx_v_shape, 0) != 0);
    if (__pyx_t_4) {

      /* "cupy/core/core.pyx":2374
 *             a = x
 *             if internal.vector_equal(a._shape, shape):
 *                 broadcasted.append(a)             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
      __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_broadcasted, ((PyObject *)__pyx_v_a)); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 2374, __pyx_L1_error)

      /* "cupy/core/core.pyx":2375
 *             if internal.vector_equal(a._shape, shape):
 *                 broadcasted.append(a)
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *             r_strides.assign(self.nd, <Py_ssize_t>0)
 */
      goto __pyx_L14_continue;

      /* "cupy/core/core.pyx":2373
 *                 continue
 *             a = x
 *             if internal.vector_equal(a._shape, shape):             # <<<<<<<<<<<<<<
 *                 broadcasted.append(a)
 *                 continue
 */
    }

    /* "cupy/core/core.pyx":2377
 *                 continue
 * 
 *             r_strides.assign(self.nd, <Py_ssize_t>0)             # <<<<<<<<<<<<<<
 *             a_ndim = a._shape.size()
 *             for i in range(a_ndim):
 */
    try {
      __pyx_v_r_strides.assign(__pyx_v_self->nd, ((Py_ssize_t)0));
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2377, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2378
 * 
 *             r_strides.assign(self.nd, <Py_ssize_t>0)
 *             a_ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *             for i in range(a_ndim):
 *                 a_sh = a._shape[a_ndim - i - 1]
 */
    __pyx_v_a_ndim = __pyx_v_a->_shape.size();

    /* "cupy/core/core.pyx":2379
 *             r_strides.assign(self.nd, <Py_ssize_t>0)
 *             a_ndim = a._shape.size()
 *             for i in range(a_ndim):             # <<<<<<<<<<<<<<
 *                 a_sh = a._shape[a_ndim - i - 1]
 *                 if a_sh == r_shape[i]:
 */
    __pyx_t_8 = __pyx_v_a_ndim;
    for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_8; __pyx_t_6+=1) {
      __pyx_v_i = __pyx_t_6;

      /* "cupy/core/core.pyx":2380
 *             a_ndim = a._shape.size()
 *             for i in range(a_ndim):
 *                 a_sh = a._shape[a_ndim - i - 1]             # <<<<<<<<<<<<<<
 *                 if a_sh == r_shape[i]:
 *                     r_strides[i] = a._strides[a_ndim - i - 1]
 */
      __pyx_v_a_sh = (__pyx_v_a->_shape[((__pyx_v_a_ndim - __pyx_v_i) - 1)]);

      /* "cupy/core/core.pyx":2381
 *             for i in range(a_ndim):
 *                 a_sh = a._shape[a_ndim - i - 1]
 *                 if a_sh == r_shape[i]:             # <<<<<<<<<<<<<<
 *                     r_strides[i] = a._strides[a_ndim - i - 1]
 *                 elif a_sh != 1:
 */
      __pyx_t_4 = ((__pyx_v_a_sh == (__pyx_v_r_shape[__pyx_v_i])) != 0);
      if (__pyx_t_4) {

        /* "cupy/core/core.pyx":2382
 *                 a_sh = a._shape[a_ndim - i - 1]
 *                 if a_sh == r_shape[i]:
 *                     r_strides[i] = a._strides[a_ndim - i - 1]             # <<<<<<<<<<<<<<
 *                 elif a_sh != 1:
 *                     raise ValueError('Broadcasting failed')
 */
        (__pyx_v_r_strides[__pyx_v_i]) = (__pyx_v_a->_strides[((__pyx_v_a_ndim - __pyx_v_i) - 1)]);

        /* "cupy/core/core.pyx":2381
 *             for i in range(a_ndim):
 *                 a_sh = a._shape[a_ndim - i - 1]
 *                 if a_sh == r_shape[i]:             # <<<<<<<<<<<<<<
 *                     r_strides[i] = a._strides[a_ndim - i - 1]
 *                 elif a_sh != 1:
 */
        goto __pyx_L20;
      }

      /* "cupy/core/core.pyx":2383
 *                 if a_sh == r_shape[i]:
 *                     r_strides[i] = a._strides[a_ndim - i - 1]
 *                 elif a_sh != 1:             # <<<<<<<<<<<<<<
 *                     raise ValueError('Broadcasting failed')
 * 
 */
      __pyx_t_4 = ((__pyx_v_a_sh != 1) != 0);
      if (__pyx_t_4) {

        /* "cupy/core/core.pyx":2384
 *                     r_strides[i] = a._strides[a_ndim - i - 1]
 *                 elif a_sh != 1:
 *                     raise ValueError('Broadcasting failed')             # <<<<<<<<<<<<<<
 * 
 *             strides.assign(r_strides.rbegin(), r_strides.rend())
 */
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__114, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2384, __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, 2384, __pyx_L1_error)

        /* "cupy/core/core.pyx":2383
 *                 if a_sh == r_shape[i]:
 *                     r_strides[i] = a._strides[a_ndim - i - 1]
 *                 elif a_sh != 1:             # <<<<<<<<<<<<<<
 *                     raise ValueError('Broadcasting failed')
 * 
 */
      }
      __pyx_L20:;
    }

    /* "cupy/core/core.pyx":2386
 *                     raise ValueError('Broadcasting failed')
 * 
 *             strides.assign(r_strides.rbegin(), r_strides.rend())             # <<<<<<<<<<<<<<
 *             view = a.view()
 *             view._set_shape_and_strides(shape, strides)
 */
    try {
      __pyx_v_strides.assign(__pyx_v_r_strides.rbegin(), __pyx_v_r_strides.rend());
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2386, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2387
 * 
 *             strides.assign(r_strides.rbegin(), r_strides.rend())
 *             view = a.view()             # <<<<<<<<<<<<<<
 *             view._set_shape_and_strides(shape, strides)
 *             broadcasted.append(view)
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_view, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2388
 *             strides.assign(r_strides.rbegin(), r_strides.rend())
 *             view = a.view()
 *             view._set_shape_and_strides(shape, strides)             # <<<<<<<<<<<<<<
 *             broadcasted.append(view)
 * 
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_v_shape, __pyx_v_strides, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2388, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2389
 *             view = a.view()
 *             view._set_shape_and_strides(shape, strides)
 *             broadcasted.append(view)             # <<<<<<<<<<<<<<
 * 
 *         self.values = tuple(broadcasted)
 */
    __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_broadcasted, ((PyObject *)__pyx_v_view)); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 2389, __pyx_L1_error)

    /* "cupy/core/core.pyx":2368
 * 
 *         broadcasted = []
 *         for x in arrays:             # <<<<<<<<<<<<<<
 *             if not isinstance(x, ndarray):
 *                 broadcasted.append(x)
 */
    __pyx_L14_continue:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2391
 *             broadcasted.append(view)
 * 
 *         self.values = tuple(broadcasted)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = PyList_AsTuple(__pyx_v_broadcasted); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->values);
  __Pyx_DECREF(__pyx_v_self->values);
  __pyx_v_self->values = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2332
 *         readonly Py_ssize_t nd
 * 
 *     def __init__(self, *arrays):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i, j, s, smin, smax, a_ndim, a_sh
 *         cdef vector.vector[Py_ssize_t] shape, strides, r_shape, r_strides
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core.broadcast.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF((PyObject *)__pyx_v_view);
  __Pyx_XDECREF(__pyx_v_rev);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_broadcasted);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2327
 * 
 *     cdef:
 *         readonly tuple values             # <<<<<<<<<<<<<<
 *         readonly tuple shape
 *         readonly Py_ssize_t size
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_6values_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_6values_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_9broadcast_6values___get__(((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_6values___get__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->values);
  __pyx_r = __pyx_v_self->values;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2328
 *     cdef:
 *         readonly tuple values
 *         readonly tuple shape             # <<<<<<<<<<<<<<
 *         readonly Py_ssize_t size
 *         readonly Py_ssize_t nd
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_5shape_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_5shape_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_9broadcast_5shape___get__(((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_5shape___get__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->shape);
  __pyx_r = __pyx_v_self->shape;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2329
 *         readonly tuple values
 *         readonly tuple shape
 *         readonly Py_ssize_t size             # <<<<<<<<<<<<<<
 *         readonly Py_ssize_t nd
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_4size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_4size_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_9broadcast_4size___get__(((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_4size___get__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2329, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.broadcast.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2330
 *         readonly tuple shape
 *         readonly Py_ssize_t size
 *         readonly Py_ssize_t nd             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, *arrays):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_2nd_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_2nd_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_9broadcast_2nd___get__(((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_2nd___get__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->nd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.broadcast.nd.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.nd, self.shape, self.size, self.values)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_9broadcast_2__reduce_cython__[] = "broadcast.__reduce_cython__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_9broadcast_2__reduce_cython__(((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_2__reduce_cython__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.nd, self.shape, self.size, self.values)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->nd); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->shape);
  __Pyx_GIVEREF(__pyx_v_self->shape);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->shape);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->values);
  __Pyx_GIVEREF(__pyx_v_self->values);
  PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_self->values);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.nd, self.shape, self.size, self.values)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v__dict = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":5
 *     state = (self.nd, self.shape, self.size, self.values)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_4 = (__pyx_v__dict != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict);
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.shape is not None or self.values is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.nd, self.shape, self.size, self.values)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.shape is not None or self.values is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, None), state
 */
  /*else*/ {
    __pyx_t_4 = (__pyx_v_self->shape != ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->values != ((PyObject*)Py_None));
    __pyx_t_4 = (__pyx_t_6 != 0);
    __pyx_t_5 = __pyx_t_4;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_5;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.shape is not None or self.values is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, None), state
 *     else:
 */
  __pyx_t_5 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":11
 *         use_setstate = self.shape is not None or self.values is not None
 *     if use_setstate:
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_broadcast); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_5472103);
    __Pyx_GIVEREF(__pyx_int_5472103);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_5472103);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.shape is not None or self.values is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, None), state
 *     else:
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_broadcast__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_broadcast); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_5472103);
    __Pyx_GIVEREF(__pyx_int_5472103);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_5472103);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.nd, self.shape, self.size, self.values)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core.broadcast.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_broadcast__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4cupy_4core_4core_9broadcast_4__setstate_cython__[] = "broadcast.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_9broadcast_4__setstate_cython__(((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_4__setstate_cython__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":15
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_broadcast__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(4, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core___pyx_unpickle_broadcast__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_broadcast__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.broadcast.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2394
 * 
 * 
 * cpdef ndarray broadcast_to(ndarray array, shape):             # <<<<<<<<<<<<<<
 *     """Broadcast an array to a given shape.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_67broadcast_to(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_broadcast_to(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_array, PyObject *__pyx_v_shape, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_strides = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_j = NULL;
  PyObject *__pyx_v_sh = NULL;
  PyObject *__pyx_v_a_sh = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_view = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  std::vector<Py_ssize_t> ::size_type __pyx_t_7;
  std::vector<Py_ssize_t>  __pyx_t_8;
  std::vector<Py_ssize_t>  __pyx_t_9;
  __Pyx_RefNannySetupContext("broadcast_to", 0);

  /* "cupy/core/core.pyx":2402
 * 
 *     """
 *     if array.ndim > len(shape):             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'input operand has more dimensions than allowed by the axis '
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_array), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_v_shape); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 2402, __pyx_L1_error)
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2402, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2402, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":2403
 *     """
 *     if array.ndim > len(shape):
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             'input operand has more dimensions than allowed by the axis '
 *             'remapping')
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__115, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2403, __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, 2403, __pyx_L1_error)

    /* "cupy/core/core.pyx":2402
 * 
 *     """
 *     if array.ndim > len(shape):             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'input operand has more dimensions than allowed by the axis '
 */
  }

  /* "cupy/core/core.pyx":2407
 *             'remapping')
 * 
 *     strides = [0] * len(shape)             # <<<<<<<<<<<<<<
 *     for i in range(array.ndim):
 *         j = -i - 1
 */
  __pyx_t_2 = PyObject_Length(__pyx_v_shape); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 2407, __pyx_L1_error)
  __pyx_t_4 = PyList_New(1 * ((__pyx_t_2<0) ? 0:__pyx_t_2)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  { Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < __pyx_t_2; __pyx_temp++) {
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyList_SET_ITEM(__pyx_t_4, __pyx_temp, __pyx_int_0);
    }
  }
  __pyx_v_strides = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2408
 * 
 *     strides = [0] * len(shape)
 *     for i in range(array.ndim):             # <<<<<<<<<<<<<<
 *         j = -i - 1
 *         sh = shape[j]
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_array), __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2408, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_2 >= 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_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2408, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2408, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2408, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2408, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_6(__pyx_t_3);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2408, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2409
 *     strides = [0] * len(shape)
 *     for i in range(array.ndim):
 *         j = -i - 1             # <<<<<<<<<<<<<<
 *         sh = shape[j]
 *         a_sh = array.shape[j]
 */
    __pyx_t_4 = PyNumber_Negative(__pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyInt_SubtractObjC(__pyx_t_4, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2410
 *     for i in range(array.ndim):
 *         j = -i - 1
 *         sh = shape[j]             # <<<<<<<<<<<<<<
 *         a_sh = array.shape[j]
 *         if sh == a_sh:
 */
    __pyx_t_1 = PyObject_GetItem(__pyx_v_shape, __pyx_v_j); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2410, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_sh, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2411
 *         j = -i - 1
 *         sh = shape[j]
 *         a_sh = array.shape[j]             # <<<<<<<<<<<<<<
 *         if sh == a_sh:
 *             strides[j] = array._strides[j % array.ndim]
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_array), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyObject_GetItem(__pyx_t_1, __pyx_v_j); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_a_sh, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2412
 *         sh = shape[j]
 *         a_sh = array.shape[j]
 *         if sh == a_sh:             # <<<<<<<<<<<<<<
 *             strides[j] = array._strides[j % array.ndim]
 *         elif a_sh != 1:
 */
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_sh, __pyx_v_a_sh, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2412, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2412, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_5) {

      /* "cupy/core/core.pyx":2413
 *         a_sh = array.shape[j]
 *         if sh == a_sh:
 *             strides[j] = array._strides[j % array.ndim]             # <<<<<<<<<<<<<<
 *         elif a_sh != 1:
 *             raise ValueError('Broadcasting failed')
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_array), __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2413, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = PyNumber_Remainder(__pyx_v_j, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2413, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_7 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2413, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_array->_strides[__pyx_t_7])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2413, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(PyObject_SetItem(__pyx_v_strides, __pyx_v_j, __pyx_t_1) < 0)) __PYX_ERR(0, 2413, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":2412
 *         sh = shape[j]
 *         a_sh = array.shape[j]
 *         if sh == a_sh:             # <<<<<<<<<<<<<<
 *             strides[j] = array._strides[j % array.ndim]
 *         elif a_sh != 1:
 */
      goto __pyx_L6;
    }

    /* "cupy/core/core.pyx":2414
 *         if sh == a_sh:
 *             strides[j] = array._strides[j % array.ndim]
 *         elif a_sh != 1:             # <<<<<<<<<<<<<<
 *             raise ValueError('Broadcasting failed')
 * 
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_a_sh, __pyx_int_1, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2414, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2414, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_5) {

      /* "cupy/core/core.pyx":2415
 *             strides[j] = array._strides[j % array.ndim]
 *         elif a_sh != 1:
 *             raise ValueError('Broadcasting failed')             # <<<<<<<<<<<<<<
 * 
 *     view = array.view()
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__116, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2415, __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, 2415, __pyx_L1_error)

      /* "cupy/core/core.pyx":2414
 *         if sh == a_sh:
 *             strides[j] = array._strides[j % array.ndim]
 *         elif a_sh != 1:             # <<<<<<<<<<<<<<
 *             raise ValueError('Broadcasting failed')
 * 
 */
    }
    __pyx_L6:;

    /* "cupy/core/core.pyx":2408
 * 
 *     strides = [0] * len(shape)
 *     for i in range(array.ndim):             # <<<<<<<<<<<<<<
 *         j = -i - 1
 *         sh = shape[j]
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2417
 *             raise ValueError('Broadcasting failed')
 * 
 *     view = array.view()             # <<<<<<<<<<<<<<
 *     view._set_shape_and_strides(shape, strides)
 *     return view
 */
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_array->__pyx_vtab)->view(__pyx_v_array, 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_view = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2418
 * 
 *     view = array.view()
 *     view._set_shape_and_strides(shape, strides)             # <<<<<<<<<<<<<<
 *     return view
 * 
 */
  __pyx_t_8 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2418, __pyx_L1_error)
  __pyx_t_9 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_strides); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2418, __pyx_L1_error)
  __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_t_8, __pyx_t_9, 0, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2419
 *     view = array.view()
 *     view._set_shape_and_strides(shape, strides)
 *     return view             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_view));
  __pyx_r = __pyx_v_view;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2394
 * 
 * 
 * cpdef ndarray broadcast_to(ndarray array, shape):             # <<<<<<<<<<<<<<
 *     """Broadcast an array to a given shape.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.broadcast_to", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_strides);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XDECREF(__pyx_v_sh);
  __Pyx_XDECREF(__pyx_v_a_sh);
  __Pyx_XDECREF((PyObject *)__pyx_v_view);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_67broadcast_to(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_66broadcast_to[] = "broadcast_to(ndarray array, shape) -> ndarray\nBroadcast an array to a given shape.\n\n    .. seealso::\n        :func:`cupy.broadcast_to` for full documentation,\n        :meth:`numpy.broadcast_to`\n\n    ";
static PyObject *__pyx_pw_4cupy_4core_4core_67broadcast_to(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_array = 0;
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("broadcast_to (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_array,&__pyx_n_s_shape,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_array)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("broadcast_to", 1, 2, 2, 1); __PYX_ERR(0, 2394, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "broadcast_to") < 0)) __PYX_ERR(0, 2394, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_array = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_shape = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("broadcast_to", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2394, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.broadcast_to", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_array), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "array", 0))) __PYX_ERR(0, 2394, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_66broadcast_to(__pyx_self, __pyx_v_array, __pyx_v_shape);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_66broadcast_to(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_array, PyObject *__pyx_v_shape) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("broadcast_to", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_broadcast_to(__pyx_v_array, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.broadcast_to", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2422
 * 
 * 
 * cpdef ndarray _repeat(ndarray a, repeats, axis=None):             # <<<<<<<<<<<<<<
 *     """Repeat arrays along an axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_69_repeat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__repeat(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_repeats, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__repeat *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = 0;
  int __pyx_v_broadcast;
  PyObject *__pyx_v_rep = NULL;
  PyObject *__pyx_v_ret_shape = NULL;
  PyObject *__pyx_v_a_index = NULL;
  PyObject *__pyx_v_ret_index = NULL;
  PyObject *__pyx_v_offset = NULL;
  PyObject *__pyx_v_i = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  std::vector<Py_ssize_t> ::size_type __pyx_t_13;
  __Pyx_RefNannySetupContext("_repeat", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF(__pyx_v_repeats);
  __Pyx_INCREF(__pyx_v_axis);

  /* "cupy/core/core.pyx":2440
 *     # Scalar and size 1 'repeat' arrays broadcast to any shape, for all
 *     # other inputs the dimension must match exactly.
 *     cdef bint broadcast = False             # <<<<<<<<<<<<<<
 *     if isinstance(repeats, int):
 *         if repeats < 0:
 */
  __pyx_v_broadcast = 0;

  /* "cupy/core/core.pyx":2441
 *     # other inputs the dimension must match exactly.
 *     cdef bint broadcast = False
 *     if isinstance(repeats, int):             # <<<<<<<<<<<<<<
 *         if repeats < 0:
 *             raise ValueError(
 */
  __pyx_t_1 = PyInt_Check(__pyx_v_repeats); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2442
 *     cdef bint broadcast = False
 *     if isinstance(repeats, int):
 *         if repeats < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 "'repeats' should not be negative: {}".format(repeats))
 */
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_repeats, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2442, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2442, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2444
 *         if repeats < 0:
 *             raise ValueError(
 *                 "'repeats' should not be negative: {}".format(repeats))             # <<<<<<<<<<<<<<
 *         broadcast = True
 *         repeats = [repeats]
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_repeats_should_not_be_negative, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2444, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_repeats); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2444, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_repeats};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2444, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_3);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_repeats};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2444, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_3);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2444, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
          __Pyx_INCREF(__pyx_v_repeats);
          __Pyx_GIVEREF(__pyx_v_repeats);
          PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_repeats);
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2444, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":2443
 *     if isinstance(repeats, int):
 *         if repeats < 0:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 "'repeats' should not be negative: {}".format(repeats))
 *         broadcast = True
 */
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2443, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2443, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 2443, __pyx_L1_error)

      /* "cupy/core/core.pyx":2442
 *     cdef bint broadcast = False
 *     if isinstance(repeats, int):
 *         if repeats < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 "'repeats' should not be negative: {}".format(repeats))
 */
    }

    /* "cupy/core/core.pyx":2445
 *             raise ValueError(
 *                 "'repeats' should not be negative: {}".format(repeats))
 *         broadcast = True             # <<<<<<<<<<<<<<
 *         repeats = [repeats]
 *     elif cpython.PySequence_Check(repeats):
 */
    __pyx_v_broadcast = 1;

    /* "cupy/core/core.pyx":2446
 *                 "'repeats' should not be negative: {}".format(repeats))
 *         broadcast = True
 *         repeats = [repeats]             # <<<<<<<<<<<<<<
 *     elif cpython.PySequence_Check(repeats):
 *         for rep in repeats:
 */
    __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2446, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_repeats);
    __Pyx_GIVEREF(__pyx_v_repeats);
    PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_repeats);
    __Pyx_DECREF_SET(__pyx_v_repeats, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2441
 *     # other inputs the dimension must match exactly.
 *     cdef bint broadcast = False
 *     if isinstance(repeats, int):             # <<<<<<<<<<<<<<
 *         if repeats < 0:
 *             raise ValueError(
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":2447
 *         broadcast = True
 *         repeats = [repeats]
 *     elif cpython.PySequence_Check(repeats):             # <<<<<<<<<<<<<<
 *         for rep in repeats:
 *             if rep < 0:
 */
  __pyx_t_2 = (PySequence_Check(__pyx_v_repeats) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2448
 *         repeats = [repeats]
 *     elif cpython.PySequence_Check(repeats):
 *         for rep in repeats:             # <<<<<<<<<<<<<<
 *             if rep < 0:
 *                 raise ValueError(
 */
    if (likely(PyList_CheckExact(__pyx_v_repeats)) || PyTuple_CheckExact(__pyx_v_repeats)) {
      __pyx_t_3 = __pyx_v_repeats; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_repeats); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2448, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2448, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 2448, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2448, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 2448, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2448, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        }
      } else {
        __pyx_t_4 = __pyx_t_8(__pyx_t_3);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 2448, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_XDECREF_SET(__pyx_v_rep, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":2449
 *     elif cpython.PySequence_Check(repeats):
 *         for rep in repeats:
 *             if rep < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     "all elements of 'repeats' should not be negative: {}"
 */
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_rep, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2449, __pyx_L1_error)
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2449, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":2452
 *                 raise ValueError(
 *                     "all elements of 'repeats' should not be negative: {}"
 *                     .format(repeats))             # <<<<<<<<<<<<<<
 *         if len(repeats) == 1:
 *             broadcast = True
 */
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_all_elements_of_repeats_should_n, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2452, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_5 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_5)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
          }
        }
        if (!__pyx_t_5) {
          __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_repeats); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2452, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_repeats};
            __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2452, __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[2] = {__pyx_t_5, __pyx_v_repeats};
            __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2452, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_GOTREF(__pyx_t_4);
          } else
          #endif
          {
            __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2452, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); __pyx_t_5 = NULL;
            __Pyx_INCREF(__pyx_v_repeats);
            __Pyx_GIVEREF(__pyx_v_repeats);
            PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_repeats);
            __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2452, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "cupy/core/core.pyx":2450
 *         for rep in repeats:
 *             if rep < 0:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     "all elements of 'repeats' should not be negative: {}"
 *                     .format(repeats))
 */
        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2450, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2450, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(0, 2450, __pyx_L1_error)

        /* "cupy/core/core.pyx":2449
 *     elif cpython.PySequence_Check(repeats):
 *         for rep in repeats:
 *             if rep < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     "all elements of 'repeats' should not be negative: {}"
 */
      }

      /* "cupy/core/core.pyx":2448
 *         repeats = [repeats]
 *     elif cpython.PySequence_Check(repeats):
 *         for rep in repeats:             # <<<<<<<<<<<<<<
 *             if rep < 0:
 *                 raise ValueError(
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2453
 *                     "all elements of 'repeats' should not be negative: {}"
 *                     .format(repeats))
 *         if len(repeats) == 1:             # <<<<<<<<<<<<<<
 *             broadcast = True
 *     else:
 */
    __pyx_t_7 = PyObject_Length(__pyx_v_repeats); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 2453, __pyx_L1_error)
    __pyx_t_2 = ((__pyx_t_7 == 1) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2454
 *                     .format(repeats))
 *         if len(repeats) == 1:
 *             broadcast = True             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError(
 */
      __pyx_v_broadcast = 1;

      /* "cupy/core/core.pyx":2453
 *                     "all elements of 'repeats' should not be negative: {}"
 *                     .format(repeats))
 *         if len(repeats) == 1:             # <<<<<<<<<<<<<<
 *             broadcast = True
 *     else:
 */
    }

    /* "cupy/core/core.pyx":2447
 *         broadcast = True
 *         repeats = [repeats]
 *     elif cpython.PySequence_Check(repeats):             # <<<<<<<<<<<<<<
 *         for rep in repeats:
 *             if rep < 0:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":2456
 *             broadcast = True
 *     else:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             "'repeats' should be int or sequence: {}".format(repeats))
 * 
 */
  /*else*/ {

    /* "cupy/core/core.pyx":2457
 *     else:
 *         raise ValueError(
 *             "'repeats' should be int or sequence: {}".format(repeats))             # <<<<<<<<<<<<<<
 * 
 *     if axis is None:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_repeats_should_be_int_or_sequen, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2457, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_repeats); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2457, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_repeats};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2457, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_repeats};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2457, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2457, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
        __Pyx_INCREF(__pyx_v_repeats);
        __Pyx_GIVEREF(__pyx_v_repeats);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_repeats);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2457, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2456
 *             broadcast = True
 *     else:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             "'repeats' should be int or sequence: {}".format(repeats))
 * 
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2456, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":2459
 *             "'repeats' should be int or sequence: {}".format(repeats))
 * 
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         if broadcast:
 *             a = a.reshape((-1, 1))
 */
  __pyx_t_2 = (__pyx_v_axis == Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2460
 * 
 *     if axis is None:
 *         if broadcast:             # <<<<<<<<<<<<<<
 *             a = a.reshape((-1, 1))
 *             ret = ndarray((a.size, repeats[0]), dtype=a.dtype)
 */
    __pyx_t_1 = (__pyx_v_broadcast != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":2461
 *     if axis is None:
 *         if broadcast:
 *             a = a.reshape((-1, 1))             # <<<<<<<<<<<<<<
 *             ret = ndarray((a.size, repeats[0]), dtype=a.dtype)
 *             if ret.size:
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2461, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__118, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2461, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2461, __pyx_L1_error)
      __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":2462
 *         if broadcast:
 *             a = a.reshape((-1, 1))
 *             ret = ndarray((a.size, repeats[0]), dtype=a.dtype)             # <<<<<<<<<<<<<<
 *             if ret.size:
 *                 ret[...] = a
 */
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_a->size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2462, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_repeats, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2462, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2462, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3);
      __pyx_t_4 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2462, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2462, __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, 2462, __pyx_L1_error)
      __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2462, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":2463
 *             a = a.reshape((-1, 1))
 *             ret = ndarray((a.size, repeats[0]), dtype=a.dtype)
 *             if ret.size:             # <<<<<<<<<<<<<<
 *                 ret[...] = a
 *             return ret.ravel()
 */
      __pyx_t_1 = (__pyx_v_ret->size != 0);
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":2464
 *             ret = ndarray((a.size, repeats[0]), dtype=a.dtype)
 *             if ret.size:
 *                 ret[...] = a             # <<<<<<<<<<<<<<
 *             return ret.ravel()
 *         else:
 */
        if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_ret), Py_Ellipsis, ((PyObject *)__pyx_v_a)) < 0)) __PYX_ERR(0, 2464, __pyx_L1_error)

        /* "cupy/core/core.pyx":2463
 *             a = a.reshape((-1, 1))
 *             ret = ndarray((a.size, repeats[0]), dtype=a.dtype)
 *             if ret.size:             # <<<<<<<<<<<<<<
 *                 ret[...] = a
 *             return ret.ravel()
 */
      }

      /* "cupy/core/core.pyx":2465
 *             if ret.size:
 *                 ret[...] = a
 *             return ret.ravel()             # <<<<<<<<<<<<<<
 *         else:
 *             a = a.ravel()
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ret->__pyx_vtab)->ravel(__pyx_v_ret, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2465, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
      __pyx_t_4 = 0;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2460
 * 
 *     if axis is None:
 *         if broadcast:             # <<<<<<<<<<<<<<
 *             a = a.reshape((-1, 1))
 *             ret = ndarray((a.size, repeats[0]), dtype=a.dtype)
 */
    }

    /* "cupy/core/core.pyx":2467
 *             return ret.ravel()
 *         else:
 *             a = a.ravel()             # <<<<<<<<<<<<<<
 *             axis = 0
 *     elif not (-a.ndim <= axis < a.ndim):
 */
    /*else*/ {
      __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->ravel(__pyx_v_a, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2467, __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":2468
 *         else:
 *             a = a.ravel()
 *             axis = 0             # <<<<<<<<<<<<<<
 *     elif not (-a.ndim <= axis < a.ndim):
 *         raise _AxisError(
 */
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_DECREF_SET(__pyx_v_axis, __pyx_int_0);
    }

    /* "cupy/core/core.pyx":2459
 *             "'repeats' should be int or sequence: {}".format(repeats))
 * 
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         if broadcast:
 *             a = a.reshape((-1, 1))
 */
    goto __pyx_L9;
  }

  /* "cupy/core/core.pyx":2469
 *             a = a.ravel()
 *             axis = 0
 *     elif not (-a.ndim <= axis < a.ndim):             # <<<<<<<<<<<<<<
 *         raise _AxisError(
 *             'axis {} is out of bounds for array of dimension {}'.format(
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2469, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = PyNumber_Negative(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2469, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_9, __pyx_v_axis, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2469, __pyx_L1_error)
  if (__Pyx_PyObject_IsTrue(__pyx_t_4)) {
    __Pyx_DECREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2469, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2469, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2469, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2470
 *             axis = 0
 *     elif not (-a.ndim <= axis < a.ndim):
 *         raise _AxisError(             # <<<<<<<<<<<<<<
 *             'axis {} is out of bounds for array of dimension {}'.format(
 *                 axis, a.ndim))
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2470, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);

    /* "cupy/core/core.pyx":2471
 *     elif not (-a.ndim <= axis < a.ndim):
 *         raise _AxisError(
 *             'axis {} is out of bounds for array of dimension {}'.format(             # <<<<<<<<<<<<<<
 *                 axis, a.ndim))
 * 
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_axis_is_out_of_bounds_for_array, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2471, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);

    /* "cupy/core/core.pyx":2472
 *         raise _AxisError(
 *             'axis {} is out of bounds for array of dimension {}'.format(
 *                 axis, a.ndim))             # <<<<<<<<<<<<<<
 * 
 *     if broadcast:
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2472, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_10 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_axis, __pyx_t_5};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2471, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 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_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_axis, __pyx_t_5};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2471, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2471, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_v_axis);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2471, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2470, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2470, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2470, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2470, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_6); __pyx_t_6 = NULL;
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2470, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2470, __pyx_L1_error)

    /* "cupy/core/core.pyx":2469
 *             a = a.ravel()
 *             axis = 0
 *     elif not (-a.ndim <= axis < a.ndim):             # <<<<<<<<<<<<<<
 *         raise _AxisError(
 *             'axis {} is out of bounds for array of dimension {}'.format(
 */
  }
  __pyx_L9:;

  /* "cupy/core/core.pyx":2474
 *                 axis, a.ndim))
 * 
 *     if broadcast:             # <<<<<<<<<<<<<<
 *         repeats = repeats * a._shape[axis % a._shape.size()]
 *     elif a.shape[axis] != len(repeats):
 */
  __pyx_t_2 = (__pyx_v_broadcast != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2475
 * 
 *     if broadcast:
 *         repeats = repeats * a._shape[axis % a._shape.size()]             # <<<<<<<<<<<<<<
 *     elif a.shape[axis] != len(repeats):
 *         raise ValueError(
 */
    __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_a->_shape.size()); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2475, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = PyNumber_Remainder(__pyx_v_axis, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2475, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_13 = __Pyx_PyInt_As_size_t(__pyx_t_9); if (unlikely((__pyx_t_13 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2475, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyInt_FromSsize_t((__pyx_v_a->_shape[__pyx_t_13])); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2475, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_4 = PyNumber_Multiply(__pyx_v_repeats, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2475, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF_SET(__pyx_v_repeats, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2474
 *                 axis, a.ndim))
 * 
 *     if broadcast:             # <<<<<<<<<<<<<<
 *         repeats = repeats * a._shape[axis % a._shape.size()]
 *     elif a.shape[axis] != len(repeats):
 */
    goto __pyx_L12;
  }

  /* "cupy/core/core.pyx":2476
 *     if broadcast:
 *         repeats = repeats * a._shape[axis % a._shape.size()]
 *     elif a.shape[axis] != len(repeats):             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             "'repeats' and 'axis' of 'a' should be same length: {} != {}"
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2476, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = PyObject_GetItem(__pyx_t_4, __pyx_v_axis); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2476, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = PyObject_Length(__pyx_v_repeats); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 2476, __pyx_L1_error)
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2476, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_12 = PyObject_RichCompare(__pyx_t_9, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2476, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2476, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2479
 *         raise ValueError(
 *             "'repeats' and 'axis' of 'a' should be same length: {} != {}"
 *             .format(a.shape[axis], len(repeats)))             # <<<<<<<<<<<<<<
 * 
 *     if axis < 0:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_repeats_and_axis_of_a_should_be, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_3 = PyObject_GetItem(__pyx_t_9, __pyx_v_axis); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_7 = PyObject_Length(__pyx_v_repeats); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 2479, __pyx_L1_error)
    __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_6 = NULL;
    __pyx_t_11 = 0;
    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);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_9};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2479, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_9};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2479, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2479, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_11, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_11, __pyx_t_9);
      __pyx_t_3 = 0;
      __pyx_t_9 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2479, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2477
 *         repeats = repeats * a._shape[axis % a._shape.size()]
 *     elif a.shape[axis] != len(repeats):
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             "'repeats' and 'axis' of 'a' should be same length: {} != {}"
 *             .format(a.shape[axis], len(repeats)))
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2477, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2477, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_12, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __PYX_ERR(0, 2477, __pyx_L1_error)

    /* "cupy/core/core.pyx":2476
 *     if broadcast:
 *         repeats = repeats * a._shape[axis % a._shape.size()]
 *     elif a.shape[axis] != len(repeats):             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             "'repeats' and 'axis' of 'a' should be same length: {} != {}"
 */
  }
  __pyx_L12:;

  /* "cupy/core/core.pyx":2481
 *             .format(a.shape[axis], len(repeats)))
 * 
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += a.ndim
 * 
 */
  __pyx_t_12 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2481, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2481, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2482
 * 
 *     if axis < 0:
 *         axis += a.ndim             # <<<<<<<<<<<<<<
 * 
 *     ret_shape = list(a.shape)
 */
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2482, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_axis, __pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2482, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2481
 *             .format(a.shape[axis], len(repeats)))
 * 
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += a.ndim
 * 
 */
  }

  /* "cupy/core/core.pyx":2484
 *         axis += a.ndim
 * 
 *     ret_shape = list(a.shape)             # <<<<<<<<<<<<<<
 *     ret_shape[axis] = sum(repeats)
 *     ret = ndarray(ret_shape, dtype=a.dtype)
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_12 = PySequence_List(__pyx_t_4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_ret_shape = ((PyObject*)__pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2485
 * 
 *     ret_shape = list(a.shape)
 *     ret_shape[axis] = sum(repeats)             # <<<<<<<<<<<<<<
 *     ret = ndarray(ret_shape, dtype=a.dtype)
 *     a_index = [slice(None)] * len(ret_shape)
 */
  __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_INCREF(__pyx_v_repeats);
  __Pyx_GIVEREF(__pyx_v_repeats);
  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_repeats);
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (unlikely(PyObject_SetItem(__pyx_v_ret_shape, __pyx_v_axis, __pyx_t_4) < 0)) __PYX_ERR(0, 2485, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2486
 *     ret_shape = list(a.shape)
 *     ret_shape[axis] = sum(repeats)
 *     ret = ndarray(ret_shape, dtype=a.dtype)             # <<<<<<<<<<<<<<
 *     a_index = [slice(None)] * len(ret_shape)
 *     ret_index = list(a_index)
 */
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2486, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_ret_shape);
  __Pyx_GIVEREF(__pyx_v_ret_shape);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_ret_shape);
  __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2486, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) __PYX_ERR(0, 2486, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_4, __pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2486, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2487
 *     ret_shape[axis] = sum(repeats)
 *     ret = ndarray(ret_shape, dtype=a.dtype)
 *     a_index = [slice(None)] * len(ret_shape)             # <<<<<<<<<<<<<<
 *     ret_index = list(a_index)
 *     offset = 0
 */
  __pyx_t_7 = PyList_GET_SIZE(__pyx_v_ret_shape); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 2487, __pyx_L1_error)
  __pyx_t_5 = PyList_New(1 * ((__pyx_t_7<0) ? 0:__pyx_t_7)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2487, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  { Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < __pyx_t_7; __pyx_temp++) {
      __Pyx_INCREF(__pyx_slice__119);
      __Pyx_GIVEREF(__pyx_slice__119);
      PyList_SET_ITEM(__pyx_t_5, __pyx_temp, __pyx_slice__119);
    }
  }
  __pyx_v_a_index = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2488
 *     ret = ndarray(ret_shape, dtype=a.dtype)
 *     a_index = [slice(None)] * len(ret_shape)
 *     ret_index = list(a_index)             # <<<<<<<<<<<<<<
 *     offset = 0
 *     for i in range(a._shape[axis]):
 */
  __pyx_t_5 = PySequence_List(__pyx_v_a_index); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_ret_index = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2489
 *     a_index = [slice(None)] * len(ret_shape)
 *     ret_index = list(a_index)
 *     offset = 0             # <<<<<<<<<<<<<<
 *     for i in range(a._shape[axis]):
 *         if repeats[i] == 0:
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_offset = __pyx_int_0;

  /* "cupy/core/core.pyx":2490
 *     ret_index = list(a_index)
 *     offset = 0
 *     for i in range(a._shape[axis]):             # <<<<<<<<<<<<<<
 *         if repeats[i] == 0:
 *             continue
 */
  __pyx_t_13 = __Pyx_PyInt_As_size_t(__pyx_v_axis); if (unlikely((__pyx_t_13 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2490, __pyx_L1_error)
  __pyx_t_5 = PyInt_FromSsize_t((__pyx_v_a->_shape[__pyx_t_13])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2490, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2490, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2490, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
    __pyx_t_12 = __pyx_t_5; __Pyx_INCREF(__pyx_t_12); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_12 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2490, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_8 = Py_TYPE(__pyx_t_12)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2490, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_12))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_12)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 2490, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_12, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2490, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_12)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_12, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 2490, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_12, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2490, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_8(__pyx_t_12);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2490, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2491
 *     offset = 0
 *     for i in range(a._shape[axis]):
 *         if repeats[i] == 0:             # <<<<<<<<<<<<<<
 *             continue
 *         a_index[axis] = slice(i, i + 1)
 */
    __pyx_t_5 = PyObject_GetItem(__pyx_v_repeats, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2491, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_t_5, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2491, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2491, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2492
 *     for i in range(a._shape[axis]):
 *         if repeats[i] == 0:
 *             continue             # <<<<<<<<<<<<<<
 *         a_index[axis] = slice(i, i + 1)
 *         ret_index[axis] = slice(offset, offset + repeats[i])
 */
      goto __pyx_L14_continue;

      /* "cupy/core/core.pyx":2491
 *     offset = 0
 *     for i in range(a._shape[axis]):
 *         if repeats[i] == 0:             # <<<<<<<<<<<<<<
 *             continue
 *         a_index[axis] = slice(i, i + 1)
 */
    }

    /* "cupy/core/core.pyx":2493
 *         if repeats[i] == 0:
 *             continue
 *         a_index[axis] = slice(i, i + 1)             # <<<<<<<<<<<<<<
 *         ret_index[axis] = slice(offset, offset + repeats[i])
 *         # convert to tuple because cupy has a indexing bug
 */
    __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2493, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PySlice_New(__pyx_v_i, __pyx_t_4, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2493, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(PyObject_SetItem(__pyx_v_a_index, __pyx_v_axis, __pyx_t_5) < 0)) __PYX_ERR(0, 2493, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2494
 *             continue
 *         a_index[axis] = slice(i, i + 1)
 *         ret_index[axis] = slice(offset, offset + repeats[i])             # <<<<<<<<<<<<<<
 *         # convert to tuple because cupy has a indexing bug
 *         ret[tuple(ret_index)] = a[tuple(a_index)]
 */
    __pyx_t_5 = PyObject_GetItem(__pyx_v_repeats, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2494, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyNumber_Add(__pyx_v_offset, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2494, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PySlice_New(__pyx_v_offset, __pyx_t_4, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2494, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(PyObject_SetItem(__pyx_v_ret_index, __pyx_v_axis, __pyx_t_5) < 0)) __PYX_ERR(0, 2494, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2496
 *         ret_index[axis] = slice(offset, offset + repeats[i])
 *         # convert to tuple because cupy has a indexing bug
 *         ret[tuple(ret_index)] = a[tuple(a_index)]             # <<<<<<<<<<<<<<
 *         offset += repeats[i]
 *     return ret
 */
    __pyx_t_5 = PyList_AsTuple(__pyx_v_a_index); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2496, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2496, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyList_AsTuple(__pyx_v_ret_index); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2496, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_ret), __pyx_t_5, __pyx_t_4) < 0)) __PYX_ERR(0, 2496, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2497
 *         # convert to tuple because cupy has a indexing bug
 *         ret[tuple(ret_index)] = a[tuple(a_index)]
 *         offset += repeats[i]             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
    __pyx_t_4 = PyObject_GetItem(__pyx_v_repeats, __pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2497, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_offset, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2497, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_offset, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2490
 *     ret_index = list(a_index)
 *     offset = 0
 *     for i in range(a._shape[axis]):             # <<<<<<<<<<<<<<
 *         if repeats[i] == 0:
 *             continue
 */
    __pyx_L14_continue:;
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2498
 *         ret[tuple(ret_index)] = a[tuple(a_index)]
 *         offset += repeats[i]
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2422
 * 
 * 
 * cpdef ndarray _repeat(ndarray a, repeats, axis=None):             # <<<<<<<<<<<<<<
 *     """Repeat arrays along an axis.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core._repeat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_rep);
  __Pyx_XDECREF(__pyx_v_ret_shape);
  __Pyx_XDECREF(__pyx_v_a_index);
  __Pyx_XDECREF(__pyx_v_ret_index);
  __Pyx_XDECREF(__pyx_v_offset);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_repeats);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_69_repeat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_68_repeat[] = "_repeat(ndarray a, repeats, axis=None) -> ndarray\nRepeat arrays along an axis.\n\n    Args:\n        a (cupy.ndarray): Array to transform.\n        repeats (int, list or tuple): The number of repeats.\n        axis (int): The axis to repeat.\n\n    Returns:\n        cupy.ndarray: Transformed array with repeats.\n\n    .. seealso:: :func:`numpy.repeat`\n\n    ";
static PyObject *__pyx_pw_4cupy_4core_4core_69_repeat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_repeats = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_repeat (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_repeats,&__pyx_n_s_axis,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_repeats)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_repeat", 0, 2, 3, 1); __PYX_ERR(0, 2422, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_repeat") < 0)) __PYX_ERR(0, 2422, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_repeats = values[1];
    __pyx_v_axis = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_repeat", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2422, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._repeat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 2422, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_68_repeat(__pyx_self, __pyx_v_a, __pyx_v_repeats, __pyx_v_axis);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_68_repeat(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_repeats, PyObject *__pyx_v_axis) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__repeat __pyx_t_2;
  __Pyx_RefNannySetupContext("_repeat", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__repeat(__pyx_v_a, __pyx_v_repeats, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._repeat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2501
 * 
 * 
 * cpdef ndarray concatenate_method(tup, int axis):             # <<<<<<<<<<<<<<
 *     cdef int ndim
 *     cdef int i
 */

static PyObject *__pyx_pw_4cupy_4core_4core_71concatenate_method(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_concatenate_method(PyObject *__pyx_v_tup, int __pyx_v_axis, CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_v_ndim;
  int __pyx_v_i;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  int __pyx_v_have_same_types;
  std::vector<Py_ssize_t>  __pyx_v_shape;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_o = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  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;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  __Pyx_RefNannySetupContext("concatenate_method", 0);

  /* "cupy/core/core.pyx":2508
 *     cdef vector.vector[Py_ssize_t] shape
 * 
 *     ndim = -1             # <<<<<<<<<<<<<<
 *     dtype = None
 *     have_same_types = True
 */
  __pyx_v_ndim = -1;

  /* "cupy/core/core.pyx":2509
 * 
 *     ndim = -1
 *     dtype = None             # <<<<<<<<<<<<<<
 *     have_same_types = True
 *     for o in tup:
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_dtype = Py_None;

  /* "cupy/core/core.pyx":2510
 *     ndim = -1
 *     dtype = None
 *     have_same_types = True             # <<<<<<<<<<<<<<
 *     for o in tup:
 *         if not isinstance(o, ndarray):
 */
  __pyx_v_have_same_types = 1;

  /* "cupy/core/core.pyx":2511
 *     dtype = None
 *     have_same_types = True
 *     for o in tup:             # <<<<<<<<<<<<<<
 *         if not isinstance(o, ndarray):
 *             raise TypeError('Only cupy arrays can be concatenated')
 */
  if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
    __pyx_t_1 = __pyx_v_tup; __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_tup); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2511, __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(0, 2511, __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(0, 2511, __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(0, 2511, __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(0, 2511, __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(0, 2511, __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(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2511, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_o, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2512
 *     have_same_types = True
 *     for o in tup:
 *         if not isinstance(o, ndarray):             # <<<<<<<<<<<<<<
 *             raise TypeError('Only cupy arrays can be concatenated')
 *         a = o
 */
    __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_o, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_6 = ((!(__pyx_t_5 != 0)) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":2513
 *     for o in tup:
 *         if not isinstance(o, ndarray):
 *             raise TypeError('Only cupy arrays can be concatenated')             # <<<<<<<<<<<<<<
 *         a = o
 *         if a.ndim == 0:
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__120, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2513, __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, 2513, __pyx_L1_error)

      /* "cupy/core/core.pyx":2512
 *     have_same_types = True
 *     for o in tup:
 *         if not isinstance(o, ndarray):             # <<<<<<<<<<<<<<
 *             raise TypeError('Only cupy arrays can be concatenated')
 *         a = o
 */
    }

    /* "cupy/core/core.pyx":2514
 *         if not isinstance(o, ndarray):
 *             raise TypeError('Only cupy arrays can be concatenated')
 *         a = o             # <<<<<<<<<<<<<<
 *         if a.ndim == 0:
 *             raise TypeError('zero-dimensional arrays cannot be concatenated')
 */
    if (!(likely(((__pyx_v_o) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_o, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2514, __pyx_L1_error)
    __pyx_t_4 = __pyx_v_o;
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_XDECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2515
 *             raise TypeError('Only cupy arrays can be concatenated')
 *         a = o
 *         if a.ndim == 0:             # <<<<<<<<<<<<<<
 *             raise TypeError('zero-dimensional arrays cannot be concatenated')
 *         if ndim == -1:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyInt_EqObjC(__pyx_t_4, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 2515, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":2516
 *         a = o
 *         if a.ndim == 0:
 *             raise TypeError('zero-dimensional arrays cannot be concatenated')             # <<<<<<<<<<<<<<
 *         if ndim == -1:
 *             ndim = a.ndim
 */
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__121, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2516, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __PYX_ERR(0, 2516, __pyx_L1_error)

      /* "cupy/core/core.pyx":2515
 *             raise TypeError('Only cupy arrays can be concatenated')
 *         a = o
 *         if a.ndim == 0:             # <<<<<<<<<<<<<<
 *             raise TypeError('zero-dimensional arrays cannot be concatenated')
 *         if ndim == -1:
 */
    }

    /* "cupy/core/core.pyx":2517
 *         if a.ndim == 0:
 *             raise TypeError('zero-dimensional arrays cannot be concatenated')
 *         if ndim == -1:             # <<<<<<<<<<<<<<
 *             ndim = a.ndim
 *             shape = a._shape
 */
    __pyx_t_6 = ((__pyx_v_ndim == -1L) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":2518
 *             raise TypeError('zero-dimensional arrays cannot be concatenated')
 *         if ndim == -1:
 *             ndim = a.ndim             # <<<<<<<<<<<<<<
 *             shape = a._shape
 *             if axis < 0:
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2518, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_ndim = __pyx_t_8;

      /* "cupy/core/core.pyx":2519
 *         if ndim == -1:
 *             ndim = a.ndim
 *             shape = a._shape             # <<<<<<<<<<<<<<
 *             if axis < 0:
 *                 axis += ndim
 */
      __pyx_t_9 = __pyx_v_a->_shape;
      __pyx_v_shape = __pyx_t_9;

      /* "cupy/core/core.pyx":2520
 *             ndim = a.ndim
 *             shape = a._shape
 *             if axis < 0:             # <<<<<<<<<<<<<<
 *                 axis += ndim
 *             if axis < 0 or axis >= ndim:
 */
      __pyx_t_6 = ((__pyx_v_axis < 0) != 0);
      if (__pyx_t_6) {

        /* "cupy/core/core.pyx":2521
 *             shape = a._shape
 *             if axis < 0:
 *                 axis += ndim             # <<<<<<<<<<<<<<
 *             if axis < 0 or axis >= ndim:
 *                 raise _AxisError(
 */
        __pyx_v_axis = (__pyx_v_axis + __pyx_v_ndim);

        /* "cupy/core/core.pyx":2520
 *             ndim = a.ndim
 *             shape = a._shape
 *             if axis < 0:             # <<<<<<<<<<<<<<
 *                 axis += ndim
 *             if axis < 0 or axis >= ndim:
 */
      }

      /* "cupy/core/core.pyx":2522
 *             if axis < 0:
 *                 axis += ndim
 *             if axis < 0 or axis >= ndim:             # <<<<<<<<<<<<<<
 *                 raise _AxisError(
 *                     'axis {} out of bounds [0, {})'.format(axis, ndim))
 */
      __pyx_t_5 = ((__pyx_v_axis < 0) != 0);
      if (!__pyx_t_5) {
      } else {
        __pyx_t_6 = __pyx_t_5;
        goto __pyx_L10_bool_binop_done;
      }
      __pyx_t_5 = ((__pyx_v_axis >= __pyx_v_ndim) != 0);
      __pyx_t_6 = __pyx_t_5;
      __pyx_L10_bool_binop_done:;
      if (__pyx_t_6) {

        /* "cupy/core/core.pyx":2523
 *                 axis += ndim
 *             if axis < 0 or axis >= ndim:
 *                 raise _AxisError(             # <<<<<<<<<<<<<<
 *                     'axis {} out of bounds [0, {})'.format(axis, ndim))
 *             dtype = a.dtype
 */
        __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2523, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);

        /* "cupy/core/core.pyx":2524
 *             if axis < 0 or axis >= ndim:
 *                 raise _AxisError(
 *                     'axis {} out of bounds [0, {})'.format(axis, ndim))             # <<<<<<<<<<<<<<
 *             dtype = a.dtype
 *             continue
 */
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_axis_out_of_bounds_0, __pyx_n_s_format); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2524, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_axis); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2524, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_ndim); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2524, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_14 = NULL;
        __pyx_t_8 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_11);
          if (likely(__pyx_t_14)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
            __Pyx_INCREF(__pyx_t_14);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_11, function);
            __pyx_t_8 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_11)) {
          PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_t_12, __pyx_t_13};
          __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2524, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
          PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_t_12, __pyx_t_13};
          __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2524, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __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, 2524, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_15);
          if (__pyx_t_14) {
            __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_12);
          PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_8, __pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_13);
          PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_8, __pyx_t_13);
          __pyx_t_12 = 0;
          __pyx_t_13 = 0;
          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_15, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2524, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_11 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_11)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_11);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        if (!__pyx_t_11) {
          __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2523, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_4)) {
            PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_10};
            __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2523, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
            PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_10};
            __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2523, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          } else
          #endif
          {
            __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2523, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_15);
            __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_11); __pyx_t_11 = NULL;
            __Pyx_GIVEREF(__pyx_t_10);
            PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_10);
            __pyx_t_10 = 0;
            __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_15, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2523, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_Raise(__pyx_t_7, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __PYX_ERR(0, 2523, __pyx_L1_error)

        /* "cupy/core/core.pyx":2522
 *             if axis < 0:
 *                 axis += ndim
 *             if axis < 0 or axis >= ndim:             # <<<<<<<<<<<<<<
 *                 raise _AxisError(
 *                     'axis {} out of bounds [0, {})'.format(axis, ndim))
 */
      }

      /* "cupy/core/core.pyx":2525
 *                 raise _AxisError(
 *                     'axis {} out of bounds [0, {})'.format(axis, ndim))
 *             dtype = a.dtype             # <<<<<<<<<<<<<<
 *             continue
 * 
 */
      __pyx_t_7 = __pyx_v_a->dtype;
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "cupy/core/core.pyx":2526
 *                     'axis {} out of bounds [0, {})'.format(axis, ndim))
 *             dtype = a.dtype
 *             continue             # <<<<<<<<<<<<<<
 * 
 *         have_same_types = have_same_types and (a.dtype == dtype)
 */
      goto __pyx_L3_continue;

      /* "cupy/core/core.pyx":2517
 *         if a.ndim == 0:
 *             raise TypeError('zero-dimensional arrays cannot be concatenated')
 *         if ndim == -1:             # <<<<<<<<<<<<<<
 *             ndim = a.ndim
 *             shape = a._shape
 */
    }

    /* "cupy/core/core.pyx":2528
 *             continue
 * 
 *         have_same_types = have_same_types and (a.dtype == dtype)             # <<<<<<<<<<<<<<
 *         if a.ndim != ndim:
 *             raise ValueError(
 */
    __pyx_t_5 = (__pyx_v_have_same_types != 0);
    if (__pyx_t_5) {
    } else {
      __pyx_t_6 = __pyx_t_5;
      goto __pyx_L12_bool_binop_done;
    }
    __pyx_t_7 = PyObject_RichCompare(__pyx_v_a->dtype, __pyx_v_dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2528, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2528, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_6 = __pyx_t_5;
    __pyx_L12_bool_binop_done:;
    __pyx_v_have_same_types = __pyx_t_6;

    /* "cupy/core/core.pyx":2529
 * 
 *         have_same_types = have_same_types and (a.dtype == dtype)
 *         if a.ndim != ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'All arrays to concatenate must have the same ndim')
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2529, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2529, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_15 = PyObject_RichCompare(__pyx_t_7, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2529, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 2529, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":2530
 *         have_same_types = have_same_types and (a.dtype == dtype)
 *         if a.ndim != ndim:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'All arrays to concatenate must have the same ndim')
 *         for i in range(ndim):
 */
      __pyx_t_15 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__122, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2530, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_Raise(__pyx_t_15, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __PYX_ERR(0, 2530, __pyx_L1_error)

      /* "cupy/core/core.pyx":2529
 * 
 *         have_same_types = have_same_types and (a.dtype == dtype)
 *         if a.ndim != ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'All arrays to concatenate must have the same ndim')
 */
    }

    /* "cupy/core/core.pyx":2532
 *             raise ValueError(
 *                 'All arrays to concatenate must have the same ndim')
 *         for i in range(ndim):             # <<<<<<<<<<<<<<
 *             if i != axis and shape[i] != a._shape[i]:
 *                 raise ValueError(
 */
    __pyx_t_8 = __pyx_v_ndim;
    for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_8; __pyx_t_16+=1) {
      __pyx_v_i = __pyx_t_16;

      /* "cupy/core/core.pyx":2533
 *                 'All arrays to concatenate must have the same ndim')
 *         for i in range(ndim):
 *             if i != axis and shape[i] != a._shape[i]:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'All arrays must have same shape except the axis to '
 */
      __pyx_t_5 = ((__pyx_v_i != __pyx_v_axis) != 0);
      if (__pyx_t_5) {
      } else {
        __pyx_t_6 = __pyx_t_5;
        goto __pyx_L18_bool_binop_done;
      }
      __pyx_t_5 = (((__pyx_v_shape[__pyx_v_i]) != (__pyx_v_a->_shape[__pyx_v_i])) != 0);
      __pyx_t_6 = __pyx_t_5;
      __pyx_L18_bool_binop_done:;
      if (__pyx_t_6) {

        /* "cupy/core/core.pyx":2534
 *         for i in range(ndim):
 *             if i != axis and shape[i] != a._shape[i]:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'All arrays must have same shape except the axis to '
 *                     'concatenate')
 */
        __pyx_t_15 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__123, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2534, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_Raise(__pyx_t_15, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __PYX_ERR(0, 2534, __pyx_L1_error)

        /* "cupy/core/core.pyx":2533
 *                 'All arrays to concatenate must have the same ndim')
 *         for i in range(ndim):
 *             if i != axis and shape[i] != a._shape[i]:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'All arrays must have same shape except the axis to '
 */
      }
    }

    /* "cupy/core/core.pyx":2537
 *                     'All arrays must have same shape except the axis to '
 *                     'concatenate')
 *         shape[axis] += a._shape[axis]             # <<<<<<<<<<<<<<
 * 
 *     if ndim == -1:
 */
    __pyx_t_8 = __pyx_v_axis;
    (__pyx_v_shape[__pyx_t_8]) = ((__pyx_v_shape[__pyx_t_8]) + (__pyx_v_a->_shape[__pyx_v_axis]));

    /* "cupy/core/core.pyx":2511
 *     dtype = None
 *     have_same_types = True
 *     for o in tup:             # <<<<<<<<<<<<<<
 *         if not isinstance(o, ndarray):
 *             raise TypeError('Only cupy arrays can be concatenated')
 */
    __pyx_L3_continue:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2539
 *         shape[axis] += a._shape[axis]
 * 
 *     if ndim == -1:             # <<<<<<<<<<<<<<
 *         raise ValueError('Cannot concatenate from empty tuple')
 * 
 */
  __pyx_t_6 = ((__pyx_v_ndim == -1L) != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":2540
 * 
 *     if ndim == -1:
 *         raise ValueError('Cannot concatenate from empty tuple')             # <<<<<<<<<<<<<<
 * 
 *     if not have_same_types:
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__124, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2540, __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, 2540, __pyx_L1_error)

    /* "cupy/core/core.pyx":2539
 *         shape[axis] += a._shape[axis]
 * 
 *     if ndim == -1:             # <<<<<<<<<<<<<<
 *         raise ValueError('Cannot concatenate from empty tuple')
 * 
 */
  }

  /* "cupy/core/core.pyx":2542
 *         raise ValueError('Cannot concatenate from empty tuple')
 * 
 *     if not have_same_types:             # <<<<<<<<<<<<<<
 *         dtype = numpy.find_common_type([a.dtype for a in tup], [])
 *     return concatenate(tup, axis, shape, dtype)
 */
  __pyx_t_6 = ((!(__pyx_v_have_same_types != 0)) != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":2543
 * 
 *     if not have_same_types:
 *         dtype = numpy.find_common_type([a.dtype for a in tup], [])             # <<<<<<<<<<<<<<
 *     return concatenate(tup, axis, shape, dtype)
 * 
 */
    __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_find_common_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = PyList_New(0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
      __pyx_t_7 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_7); __pyx_t_2 = 0;
      __pyx_t_3 = NULL;
    } else {
      __pyx_t_2 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2543, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2543, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_3)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_10 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_2); __Pyx_INCREF(__pyx_t_10); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2543, __pyx_L1_error)
          #else
          __pyx_t_10 = PySequence_ITEM(__pyx_t_7, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2543, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          #endif
        } else {
          if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_2); __Pyx_INCREF(__pyx_t_10); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2543, __pyx_L1_error)
          #else
          __pyx_t_10 = PySequence_ITEM(__pyx_t_7, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2543, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          #endif
        }
      } else {
        __pyx_t_10 = __pyx_t_3(__pyx_t_7);
        if (unlikely(!__pyx_t_10)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 2543, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_10);
      }
      if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2543, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10));
      __pyx_t_10 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_15, (PyObject*)__pyx_v_a->dtype))) __PYX_ERR(0, 2543, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_10 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_15, __pyx_t_7};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2543, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_15, __pyx_t_7};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2543, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2543, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_8, __pyx_t_15);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_8, __pyx_t_7);
      __pyx_t_15 = 0;
      __pyx_t_7 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2543, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2542
 *         raise ValueError('Cannot concatenate from empty tuple')
 * 
 *     if not have_same_types:             # <<<<<<<<<<<<<<
 *         dtype = numpy.find_common_type([a.dtype for a in tup], [])
 *     return concatenate(tup, axis, shape, dtype)
 */
  }

  /* "cupy/core/core.pyx":2544
 *     if not have_same_types:
 *         dtype = numpy.find_common_type([a.dtype for a in tup], [])
 *     return concatenate(tup, axis, shape, dtype)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_axis); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_11 = ((PyObject *)__pyx_f_4cupy_4core_4core_concatenate(__pyx_v_tup, __pyx_t_1, __pyx_t_4, __pyx_v_dtype, 0)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_11);
  __pyx_t_11 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2501
 * 
 * 
 * cpdef ndarray concatenate_method(tup, int axis):             # <<<<<<<<<<<<<<
 *     cdef int ndim
 *     cdef int i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __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_AddTraceback("cupy.core.core.concatenate_method", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_o);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_71concatenate_method(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_70concatenate_method[] = "concatenate_method(tup, int axis) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_71concatenate_method(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tup = 0;
  int __pyx_v_axis;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("concatenate_method (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_tup,&__pyx_n_s_axis,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tup)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("concatenate_method", 1, 2, 2, 1); __PYX_ERR(0, 2501, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "concatenate_method") < 0)) __PYX_ERR(0, 2501, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_tup = values[0];
    __pyx_v_axis = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_axis == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2501, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("concatenate_method", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2501, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.concatenate_method", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_70concatenate_method(__pyx_self, __pyx_v_tup, __pyx_v_axis);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_70concatenate_method(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tup, int __pyx_v_axis) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("concatenate_method", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_concatenate_method(__pyx_v_tup, __pyx_v_axis, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.concatenate_method", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2547
 * 
 * 
 * cpdef ndarray concatenate(tup, axis, shape, dtype):             # <<<<<<<<<<<<<<
 *     cdef ndarray a, x, ret
 *     cdef int i, j, base, cum, ndim
 */

static PyObject *__pyx_pw_4cupy_4core_4core_73concatenate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_concatenate(PyObject *__pyx_v_tup, PyObject *__pyx_v_axis, PyObject *__pyx_v_shape, PyObject *__pyx_v_dtype, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = 0;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_base;
  int __pyx_v_cum;
  int __pyx_v_ndim;
  int __pyx_v_all_same_type;
  int __pyx_v_all_one_and_contiguous;
  __Pyx_memviewslice __pyx_v_ptrs = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_cum_sizes = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_x_strides = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_v_any_contiguous_on_axis = NULL;
  PyObject *__pyx_v_total_bytes = NULL;
  PyObject *__pyx_v_skip = NULL;
  PyObject *__pyx_v_aw = 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;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  int __pyx_t_6;
  int __pyx_t_7;
  std::vector<Py_ssize_t> ::size_type __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  __Pyx_memviewslice __pyx_t_14 = { 0, 0, { 0 }, { 0 }, { 0 } };
  size_t __pyx_t_15;
  Py_ssize_t __pyx_t_16;
  int __pyx_t_17;
  std::vector<Py_ssize_t>  __pyx_t_18;
  __Pyx_memviewslice __pyx_t_19 = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_t_20 = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_t_21;
  Py_ssize_t __pyx_t_22;
  Py_ssize_t __pyx_t_23;
  int __pyx_t_24;
  Py_ssize_t __pyx_t_25;
  __Pyx_RefNannySetupContext("concatenate", 0);
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/core.pyx":2555
 *     cdef int[:, :] x_strides
 * 
 *     ret = ndarray(shape, dtype=dtype)             # <<<<<<<<<<<<<<
 * 
 *     all_same_type = True
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2555, __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_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2555, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 2555, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2555, __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_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2557
 *     ret = ndarray(shape, dtype=dtype)
 * 
 *     all_same_type = True             # <<<<<<<<<<<<<<
 *     all_one_and_contiguous = True
 *     any_contiguous_on_axis = False
 */
  __pyx_v_all_same_type = 1;

  /* "cupy/core/core.pyx":2558
 * 
 *     all_same_type = True
 *     all_one_and_contiguous = True             # <<<<<<<<<<<<<<
 *     any_contiguous_on_axis = False
 *     total_bytes = 0
 */
  __pyx_v_all_one_and_contiguous = 1;

  /* "cupy/core/core.pyx":2559
 *     all_same_type = True
 *     all_one_and_contiguous = True
 *     any_contiguous_on_axis = False             # <<<<<<<<<<<<<<
 *     total_bytes = 0
 *     dtype = tup[0].dtype
 */
  __Pyx_INCREF(Py_False);
  __pyx_v_any_contiguous_on_axis = Py_False;

  /* "cupy/core/core.pyx":2560
 *     all_one_and_contiguous = True
 *     any_contiguous_on_axis = False
 *     total_bytes = 0             # <<<<<<<<<<<<<<
 *     dtype = tup[0].dtype
 *     for a in tup:
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_total_bytes = __pyx_int_0;

  /* "cupy/core/core.pyx":2561
 *     any_contiguous_on_axis = False
 *     total_bytes = 0
 *     dtype = tup[0].dtype             # <<<<<<<<<<<<<<
 *     for a in tup:
 *         all_same_type = all_same_type and (a.dtype == dtype)
 */
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_tup, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2561, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2561, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2562
 *     total_bytes = 0
 *     dtype = tup[0].dtype
 *     for a in tup:             # <<<<<<<<<<<<<<
 *         all_same_type = all_same_type and (a.dtype == dtype)
 *         all_one_and_contiguous = (
 */
  if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
    __pyx_t_2 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2562, __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, 2562, __pyx_L1_error)
  }
  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, 2562, __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, 2562, __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, 2562, __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, 2562, __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(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2562, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2562, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2563
 *     dtype = tup[0].dtype
 *     for a in tup:
 *         all_same_type = all_same_type and (a.dtype == dtype)             # <<<<<<<<<<<<<<
 *         all_one_and_contiguous = (
 *             all_one_and_contiguous and a._c_contiguous and
 */
    __pyx_t_7 = (__pyx_v_all_same_type != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_a->dtype, __pyx_v_dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2563, __pyx_L1_error)
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2563, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = __pyx_t_7;
    __pyx_L5_bool_binop_done:;
    __pyx_v_all_same_type = __pyx_t_6;

    /* "cupy/core/core.pyx":2565
 *         all_same_type = all_same_type and (a.dtype == dtype)
 *         all_one_and_contiguous = (
 *             all_one_and_contiguous and a._c_contiguous and             # <<<<<<<<<<<<<<
 *             a._shape[axis] == 1)
 *         any_contiguous_on_axis = (
 */
    __pyx_t_7 = (__pyx_v_all_one_and_contiguous != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_7 = (__pyx_v_a->_c_contiguous != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L7_bool_binop_done;
    }

    /* "cupy/core/core.pyx":2566
 *         all_one_and_contiguous = (
 *             all_one_and_contiguous and a._c_contiguous and
 *             a._shape[axis] == 1)             # <<<<<<<<<<<<<<
 *         any_contiguous_on_axis = (
 *             any_contiguous_on_axis or
 */
    __pyx_t_8 = __Pyx_PyInt_As_size_t(__pyx_v_axis); if (unlikely((__pyx_t_8 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2566, __pyx_L1_error)
    __pyx_t_7 = (((__pyx_v_a->_shape[__pyx_t_8]) == 1) != 0);
    __pyx_t_6 = __pyx_t_7;
    __pyx_L7_bool_binop_done:;
    __pyx_v_all_one_and_contiguous = __pyx_t_6;

    /* "cupy/core/core.pyx":2568
 *             a._shape[axis] == 1)
 *         any_contiguous_on_axis = (
 *             any_contiguous_on_axis or             # <<<<<<<<<<<<<<
 *             a._strides[axis] == a.itemsize)
 *         total_bytes += a.size * a.itemsize
 */
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_any_contiguous_on_axis); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 2568, __pyx_L1_error)
    if (!__pyx_t_6) {
    } else {
      __Pyx_INCREF(__pyx_v_any_contiguous_on_axis);
      __pyx_t_3 = __pyx_v_any_contiguous_on_axis;
      goto __pyx_L10_bool_binop_done;
    }

    /* "cupy/core/core.pyx":2569
 *         any_contiguous_on_axis = (
 *             any_contiguous_on_axis or
 *             a._strides[axis] == a.itemsize)             # <<<<<<<<<<<<<<
 *         total_bytes += a.size * a.itemsize
 * 
 */
    __pyx_t_8 = __Pyx_PyInt_As_size_t(__pyx_v_axis); if (unlikely((__pyx_t_8 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2569, __pyx_L1_error)
    __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_a->_strides[__pyx_t_8])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2569, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2569, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = PyObject_RichCompare(__pyx_t_1, __pyx_t_9, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2569, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_INCREF(__pyx_t_10);
    __pyx_t_3 = __pyx_t_10;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_L10_bool_binop_done:;
    __Pyx_DECREF_SET(__pyx_v_any_contiguous_on_axis, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2570
 *             any_contiguous_on_axis or
 *             a._strides[axis] == a.itemsize)
 *         total_bytes += a.size * a.itemsize             # <<<<<<<<<<<<<<
 * 
 *     if ((not all_same_type or not any_contiguous_on_axis) and
 */
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_a->size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2570, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2570, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_9 = PyNumber_Multiply(__pyx_t_3, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2570, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = PyNumber_InPlaceAdd(__pyx_v_total_bytes, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2570, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF_SET(__pyx_v_total_bytes, __pyx_t_10);
    __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":2562
 *     total_bytes = 0
 *     dtype = tup[0].dtype
 *     for a in tup:             # <<<<<<<<<<<<<<
 *         all_same_type = all_same_type and (a.dtype == dtype)
 *         all_one_and_contiguous = (
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2572
 *         total_bytes += a.size * a.itemsize
 * 
 *     if ((not all_same_type or not any_contiguous_on_axis) and             # <<<<<<<<<<<<<<
 *             (len(tup) < 256 or total_bytes / len(tup) > 524288)):
 *         skip = (slice(None),) * axis
 */
  __pyx_t_7 = ((!(__pyx_v_all_same_type != 0)) != 0);
  if (!__pyx_t_7) {
  } else {
    goto __pyx_L14_next_and;
  }
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_any_contiguous_on_axis); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2572, __pyx_L1_error)
  __pyx_t_11 = ((!__pyx_t_7) != 0);
  if (__pyx_t_11) {
  } else {
    __pyx_t_6 = __pyx_t_11;
    goto __pyx_L13_bool_binop_done;
  }
  __pyx_L14_next_and:;

  /* "cupy/core/core.pyx":2573
 * 
 *     if ((not all_same_type or not any_contiguous_on_axis) and
 *             (len(tup) < 256 or total_bytes / len(tup) > 524288)):             # <<<<<<<<<<<<<<
 *         skip = (slice(None),) * axis
 *         i = 0
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 2573, __pyx_L1_error)
  __pyx_t_11 = ((__pyx_t_4 < 0x100) != 0);
  if (!__pyx_t_11) {
  } else {
    __pyx_t_6 = __pyx_t_11;
    goto __pyx_L13_bool_binop_done;
  }
  __pyx_t_4 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 2573, __pyx_L1_error)
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2573, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = __Pyx_PyNumber_Divide(__pyx_v_total_bytes, __pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2573, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_10, __pyx_int_524288, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2573, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2573, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __pyx_t_11;
  __pyx_L13_bool_binop_done:;

  /* "cupy/core/core.pyx":2572
 *         total_bytes += a.size * a.itemsize
 * 
 *     if ((not all_same_type or not any_contiguous_on_axis) and             # <<<<<<<<<<<<<<
 *             (len(tup) < 256 or total_bytes / len(tup) > 524288)):
 *         skip = (slice(None),) * axis
 */
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":2574
 *     if ((not all_same_type or not any_contiguous_on_axis) and
 *             (len(tup) < 256 or total_bytes / len(tup) > 524288)):
 *         skip = (slice(None),) * axis             # <<<<<<<<<<<<<<
 *         i = 0
 *         for a in tup:
 */
    __pyx_t_2 = PyNumber_Multiply(__pyx_tuple__126, __pyx_v_axis); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2574, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_skip = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2575
 *             (len(tup) < 256 or total_bytes / len(tup) > 524288)):
 *         skip = (slice(None),) * axis
 *         i = 0             # <<<<<<<<<<<<<<
 *         for a in tup:
 *             aw = a._shape[axis]
 */
    __pyx_v_i = 0;

    /* "cupy/core/core.pyx":2576
 *         skip = (slice(None),) * axis
 *         i = 0
 *         for a in tup:             # <<<<<<<<<<<<<<
 *             aw = a._shape[axis]
 *             ret[skip + (slice(i, i + aw),)] = a
 */
    if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
      __pyx_t_2 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2576, __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, 2576, __pyx_L1_error)
    }
    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_10 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_10); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2576, __pyx_L1_error)
          #else
          __pyx_t_10 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2576, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_10); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2576, __pyx_L1_error)
          #else
          __pyx_t_10 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2576, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          #endif
        }
      } else {
        __pyx_t_10 = __pyx_t_5(__pyx_t_2);
        if (unlikely(!__pyx_t_10)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 2576, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_10);
      }
      if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2576, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10));
      __pyx_t_10 = 0;

      /* "cupy/core/core.pyx":2577
 *         i = 0
 *         for a in tup:
 *             aw = a._shape[axis]             # <<<<<<<<<<<<<<
 *             ret[skip + (slice(i, i + aw),)] = a
 *             i += aw
 */
      __pyx_t_8 = __Pyx_PyInt_As_size_t(__pyx_v_axis); if (unlikely((__pyx_t_8 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2577, __pyx_L1_error)
      __pyx_t_10 = PyInt_FromSsize_t((__pyx_v_a->_shape[__pyx_t_8])); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2577, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_XDECREF_SET(__pyx_v_aw, __pyx_t_10);
      __pyx_t_10 = 0;

      /* "cupy/core/core.pyx":2578
 *         for a in tup:
 *             aw = a._shape[axis]
 *             ret[skip + (slice(i, i + aw),)] = a             # <<<<<<<<<<<<<<
 *             i += aw
 *     else:
 */
      __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2578, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2578, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_3 = PyNumber_Add(__pyx_t_9, __pyx_v_aw); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2578, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PySlice_New(__pyx_t_10, __pyx_t_3, Py_None); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2578, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2578, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = PyNumber_Add(__pyx_v_skip, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2578, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_ret), __pyx_t_9, ((PyObject *)__pyx_v_a)) < 0)) __PYX_ERR(0, 2578, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "cupy/core/core.pyx":2579
 *             aw = a._shape[axis]
 *             ret[skip + (slice(i, i + aw),)] = a
 *             i += aw             # <<<<<<<<<<<<<<
 *     else:
 *         ptrs = numpy.ndarray(len(tup), numpy.int64)
 */
      __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2579, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_9, __pyx_v_aw); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2579, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2579, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_i = __pyx_t_12;

      /* "cupy/core/core.pyx":2576
 *         skip = (slice(None),) * axis
 *         i = 0
 *         for a in tup:             # <<<<<<<<<<<<<<
 *             aw = a._shape[axis]
 *             ret[skip + (slice(i, i + aw),)] = a
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2572
 *         total_bytes += a.size * a.itemsize
 * 
 *     if ((not all_same_type or not any_contiguous_on_axis) and             # <<<<<<<<<<<<<<
 *             (len(tup) < 256 or total_bytes / len(tup) > 524288)):
 *         skip = (slice(None),) * axis
 */
    goto __pyx_L12;
  }

  /* "cupy/core/core.pyx":2581
 *             i += aw
 *     else:
 *         ptrs = numpy.ndarray(len(tup), numpy.int64)             # <<<<<<<<<<<<<<
 *         for i, a in enumerate(tup):
 *             ptrs[i] = a.data.ptr
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 2581, __pyx_L1_error)
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_int64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = NULL;
    __pyx_t_12 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
        __pyx_t_12 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_3, __pyx_t_1};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2581, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_3, __pyx_t_1};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2581, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2581, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_1);
      __pyx_t_3 = 0;
      __pyx_t_1 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2581, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_14 = __Pyx_PyObject_to_MemoryviewSlice_ds_Py_ssize_t(__pyx_t_2);
    if (unlikely(!__pyx_t_14.memview)) __PYX_ERR(0, 2581, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_ptrs = __pyx_t_14;
    __pyx_t_14.memview = NULL;
    __pyx_t_14.data = NULL;

    /* "cupy/core/core.pyx":2582
 *     else:
 *         ptrs = numpy.ndarray(len(tup), numpy.int64)
 *         for i, a in enumerate(tup):             # <<<<<<<<<<<<<<
 *             ptrs[i] = a.data.ptr
 *         x = array(ptrs)
 */
    __pyx_t_12 = 0;
    if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
      __pyx_t_2 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2582, __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, 2582, __pyx_L1_error)
    }
    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_9 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_9); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2582, __pyx_L1_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2582, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_9); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2582, __pyx_L1_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2582, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_5(__pyx_t_2);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 2582, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2582, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_9));
      __pyx_t_9 = 0;
      __pyx_v_i = __pyx_t_12;
      __pyx_t_12 = (__pyx_t_12 + 1);

      /* "cupy/core/core.pyx":2583
 *         ptrs = numpy.ndarray(len(tup), numpy.int64)
 *         for i, a in enumerate(tup):
 *             ptrs[i] = a.data.ptr             # <<<<<<<<<<<<<<
 *         x = array(ptrs)
 * 
 */
      __pyx_t_15 = __pyx_v_a->data->ptr;
      __pyx_t_16 = __pyx_v_i;
      __pyx_t_17 = -1;
      if (__pyx_t_16 < 0) {
        __pyx_t_16 += __pyx_v_ptrs.shape[0];
        if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
      } else if (unlikely(__pyx_t_16 >= __pyx_v_ptrs.shape[0])) __pyx_t_17 = 0;
      if (unlikely(__pyx_t_17 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_17);
        __PYX_ERR(0, 2583, __pyx_L1_error)
      }
      *((Py_ssize_t *) ( /* dim=0 */ (__pyx_v_ptrs.data + __pyx_t_16 * __pyx_v_ptrs.strides[0]) )) = __pyx_t_15;

      /* "cupy/core/core.pyx":2582
 *     else:
 *         ptrs = numpy.ndarray(len(tup), numpy.int64)
 *         for i, a in enumerate(tup):             # <<<<<<<<<<<<<<
 *             ptrs[i] = a.data.ptr
 *         x = array(ptrs)
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2584
 *         for i, a in enumerate(tup):
 *             ptrs[i] = a.data.ptr
 *         x = array(ptrs)             # <<<<<<<<<<<<<<
 * 
 *         if all_one_and_contiguous:
 */
    __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_ptrs, 1, (PyObject *(*)(char *)) __pyx_memview_get_Py_ssize_t, (int (*)(char *, PyObject *)) __pyx_memview_set_Py_ssize_t, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2584, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_t_2, 0, NULL)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2584, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_9);
    __pyx_t_9 = 0;

    /* "cupy/core/core.pyx":2586
 *         x = array(ptrs)
 * 
 *         if all_one_and_contiguous:             # <<<<<<<<<<<<<<
 *             base = <int>internal.prod_ssize_t(shape[axis + 1:])
 *             _concatenate_kernel_one(x, base, ret)
 */
    __pyx_t_6 = (__pyx_v_all_one_and_contiguous != 0);
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":2587
 * 
 *         if all_one_and_contiguous:
 *             base = <int>internal.prod_ssize_t(shape[axis + 1:])             # <<<<<<<<<<<<<<
 *             _concatenate_kernel_one(x, base, ret)
 *         else:
 */
      __pyx_t_9 = __Pyx_PyInt_AddObjC(__pyx_v_axis, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2587, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_shape, 0, 0, &__pyx_t_9, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2587, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_18 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2587, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_base = ((int)__pyx_f_4cupy_4core_8internal_prod_ssize_t(__pyx_t_18, 0, NULL));

      /* "cupy/core/core.pyx":2588
 *         if all_one_and_contiguous:
 *             base = <int>internal.prod_ssize_t(shape[axis + 1:])
 *             _concatenate_kernel_one(x, base, ret)             # <<<<<<<<<<<<<<
 *         else:
 *             ndim = tup[0].ndim
 */
      __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_base); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2588, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_v_4cupy_4core_4core__concatenate_kernel_one);
      __pyx_t_13 = __pyx_v_4cupy_4core_4core__concatenate_kernel_one; __pyx_t_1 = NULL;
      __pyx_t_12 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_13);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_13, function);
          __pyx_t_12 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[4] = {__pyx_t_1, ((PyObject *)__pyx_v_x), __pyx_t_9, ((PyObject *)__pyx_v_ret)};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2588, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[4] = {__pyx_t_1, ((PyObject *)__pyx_v_x), __pyx_t_9, ((PyObject *)__pyx_v_ret)};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2588, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(3+__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2588, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (__pyx_t_1) {
          __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_x));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_x));
        PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_12, ((PyObject *)__pyx_v_x));
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_12, __pyx_t_9);
        __Pyx_INCREF(((PyObject *)__pyx_v_ret));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_ret));
        PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_12, ((PyObject *)__pyx_v_ret));
        __pyx_t_9 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2588, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":2586
 *         x = array(ptrs)
 * 
 *         if all_one_and_contiguous:             # <<<<<<<<<<<<<<
 *             base = <int>internal.prod_ssize_t(shape[axis + 1:])
 *             _concatenate_kernel_one(x, base, ret)
 */
      goto __pyx_L21;
    }

    /* "cupy/core/core.pyx":2590
 *             _concatenate_kernel_one(x, base, ret)
 *         else:
 *             ndim = tup[0].ndim             # <<<<<<<<<<<<<<
 *             x_strides = numpy.ndarray((len(tup), ndim), numpy.int32)
 *             cum_sizes = numpy.ndarray(len(tup), numpy.int32)
 */
    /*else*/ {
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_tup, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2590, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ndim); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2590, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_13); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2590, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_v_ndim = __pyx_t_12;

      /* "cupy/core/core.pyx":2591
 *         else:
 *             ndim = tup[0].ndim
 *             x_strides = numpy.ndarray((len(tup), ndim), numpy.int32)             # <<<<<<<<<<<<<<
 *             cum_sizes = numpy.ndarray(len(tup), numpy.int32)
 *             cum = 0
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2591, __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, 2591, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_4 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 2591, __pyx_L1_error)
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2591, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_ndim); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2591, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2591, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_9);
      __pyx_t_2 = 0;
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2591, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2591, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = NULL;
      __pyx_t_12 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_12 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_1, __pyx_t_2};
        __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2591, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_1, __pyx_t_2};
        __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2591, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2591, __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_1);
        PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_12, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_12, __pyx_t_2);
        __pyx_t_1 = 0;
        __pyx_t_2 = 0;
        __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2591, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_19 = __Pyx_PyObject_to_MemoryviewSlice_dsds_int(__pyx_t_13);
      if (unlikely(!__pyx_t_19.memview)) __PYX_ERR(0, 2591, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_v_x_strides = __pyx_t_19;
      __pyx_t_19.memview = NULL;
      __pyx_t_19.data = NULL;

      /* "cupy/core/core.pyx":2592
 *             ndim = tup[0].ndim
 *             x_strides = numpy.ndarray((len(tup), ndim), numpy.int32)
 *             cum_sizes = numpy.ndarray(len(tup), numpy.int32)             # <<<<<<<<<<<<<<
 *             cum = 0
 *             for i, a in enumerate(tup):
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2592, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2592, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_4 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 2592, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2592, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2592, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2592, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      __pyx_t_12 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
          __pyx_t_12 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_3, __pyx_t_1};
        __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2592, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_3, __pyx_t_1};
        __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2592, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2592, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (__pyx_t_2) {
          __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2); __pyx_t_2 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_12, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_12, __pyx_t_1);
        __pyx_t_3 = 0;
        __pyx_t_1 = 0;
        __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_9, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2592, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_20 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_t_13);
      if (unlikely(!__pyx_t_20.memview)) __PYX_ERR(0, 2592, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_v_cum_sizes = __pyx_t_20;
      __pyx_t_20.memview = NULL;
      __pyx_t_20.data = NULL;

      /* "cupy/core/core.pyx":2593
 *             x_strides = numpy.ndarray((len(tup), ndim), numpy.int32)
 *             cum_sizes = numpy.ndarray(len(tup), numpy.int32)
 *             cum = 0             # <<<<<<<<<<<<<<
 *             for i, a in enumerate(tup):
 *                 for j in range(ndim):
 */
      __pyx_v_cum = 0;

      /* "cupy/core/core.pyx":2594
 *             cum_sizes = numpy.ndarray(len(tup), numpy.int32)
 *             cum = 0
 *             for i, a in enumerate(tup):             # <<<<<<<<<<<<<<
 *                 for j in range(ndim):
 *                     x_strides[i, j] = <int>a._strides[j]
 */
      __pyx_t_12 = 0;
      if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
        __pyx_t_13 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_13); __pyx_t_4 = 0;
        __pyx_t_5 = NULL;
      } else {
        __pyx_t_4 = -1; __pyx_t_13 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2594, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_5 = Py_TYPE(__pyx_t_13)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2594, __pyx_L1_error)
      }
      for (;;) {
        if (likely(!__pyx_t_5)) {
          if (likely(PyList_CheckExact(__pyx_t_13))) {
            if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_13)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_10 = PyList_GET_ITEM(__pyx_t_13, __pyx_t_4); __Pyx_INCREF(__pyx_t_10); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2594, __pyx_L1_error)
            #else
            __pyx_t_10 = PySequence_ITEM(__pyx_t_13, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2594, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            #endif
          } else {
            if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_13)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_13, __pyx_t_4); __Pyx_INCREF(__pyx_t_10); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2594, __pyx_L1_error)
            #else
            __pyx_t_10 = PySequence_ITEM(__pyx_t_13, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2594, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            #endif
          }
        } else {
          __pyx_t_10 = __pyx_t_5(__pyx_t_13);
          if (unlikely(!__pyx_t_10)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 2594, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_10);
        }
        if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2594, __pyx_L1_error)
        __Pyx_XDECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10));
        __pyx_t_10 = 0;
        __pyx_v_i = __pyx_t_12;
        __pyx_t_12 = (__pyx_t_12 + 1);

        /* "cupy/core/core.pyx":2595
 *             cum = 0
 *             for i, a in enumerate(tup):
 *                 for j in range(ndim):             # <<<<<<<<<<<<<<
 *                     x_strides[i, j] = <int>a._strides[j]
 *                 cum_sizes[i] = cum
 */
        __pyx_t_17 = __pyx_v_ndim;
        for (__pyx_t_21 = 0; __pyx_t_21 < __pyx_t_17; __pyx_t_21+=1) {
          __pyx_v_j = __pyx_t_21;

          /* "cupy/core/core.pyx":2596
 *             for i, a in enumerate(tup):
 *                 for j in range(ndim):
 *                     x_strides[i, j] = <int>a._strides[j]             # <<<<<<<<<<<<<<
 *                 cum_sizes[i] = cum
 *                 cum += <int>a._shape[axis]
 */
          __pyx_t_22 = __pyx_v_i;
          __pyx_t_23 = __pyx_v_j;
          __pyx_t_24 = -1;
          if (__pyx_t_22 < 0) {
            __pyx_t_22 += __pyx_v_x_strides.shape[0];
            if (unlikely(__pyx_t_22 < 0)) __pyx_t_24 = 0;
          } else if (unlikely(__pyx_t_22 >= __pyx_v_x_strides.shape[0])) __pyx_t_24 = 0;
          if (__pyx_t_23 < 0) {
            __pyx_t_23 += __pyx_v_x_strides.shape[1];
            if (unlikely(__pyx_t_23 < 0)) __pyx_t_24 = 1;
          } else if (unlikely(__pyx_t_23 >= __pyx_v_x_strides.shape[1])) __pyx_t_24 = 1;
          if (unlikely(__pyx_t_24 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_24);
            __PYX_ERR(0, 2596, __pyx_L1_error)
          }
          *((int *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x_strides.data + __pyx_t_22 * __pyx_v_x_strides.strides[0]) ) + __pyx_t_23 * __pyx_v_x_strides.strides[1]) )) = ((int)(__pyx_v_a->_strides[__pyx_v_j]));
        }

        /* "cupy/core/core.pyx":2597
 *                 for j in range(ndim):
 *                     x_strides[i, j] = <int>a._strides[j]
 *                 cum_sizes[i] = cum             # <<<<<<<<<<<<<<
 *                 cum += <int>a._shape[axis]
 * 
 */
        __pyx_t_25 = __pyx_v_i;
        __pyx_t_17 = -1;
        if (__pyx_t_25 < 0) {
          __pyx_t_25 += __pyx_v_cum_sizes.shape[0];
          if (unlikely(__pyx_t_25 < 0)) __pyx_t_17 = 0;
        } else if (unlikely(__pyx_t_25 >= __pyx_v_cum_sizes.shape[0])) __pyx_t_17 = 0;
        if (unlikely(__pyx_t_17 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_17);
          __PYX_ERR(0, 2597, __pyx_L1_error)
        }
        *((int *) ( /* dim=0 */ (__pyx_v_cum_sizes.data + __pyx_t_25 * __pyx_v_cum_sizes.strides[0]) )) = __pyx_v_cum;

        /* "cupy/core/core.pyx":2598
 *                     x_strides[i, j] = <int>a._strides[j]
 *                 cum_sizes[i] = cum
 *                 cum += <int>a._shape[axis]             # <<<<<<<<<<<<<<
 * 
 *             _concatenate_kernel(
 */
        __pyx_t_8 = __Pyx_PyInt_As_size_t(__pyx_v_axis); if (unlikely((__pyx_t_8 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2598, __pyx_L1_error)
        __pyx_v_cum = (__pyx_v_cum + ((int)(__pyx_v_a->_shape[__pyx_t_8])));

        /* "cupy/core/core.pyx":2594
 *             cum_sizes = numpy.ndarray(len(tup), numpy.int32)
 *             cum = 0
 *             for i, a in enumerate(tup):             # <<<<<<<<<<<<<<
 *                 for j in range(ndim):
 *                     x_strides[i, j] = <int>a._strides[j]
 */
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "cupy/core/core.pyx":2601
 * 
 *             _concatenate_kernel(
 *                 x, axis, array(cum_sizes), array(x_strides), ret)             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
      __pyx_t_10 = __pyx_memoryview_fromslice(__pyx_v_cum_sizes, 1, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2601, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_9 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_t_10, 0, NULL)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2601, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = __pyx_memoryview_fromslice(__pyx_v_x_strides, 2, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2601, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_t_10, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2601, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_INCREF(__pyx_v_4cupy_4core_4core__concatenate_kernel);
      __pyx_t_10 = __pyx_v_4cupy_4core_4core__concatenate_kernel; __pyx_t_3 = NULL;
      __pyx_t_12 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
          __pyx_t_12 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[6] = {__pyx_t_3, ((PyObject *)__pyx_v_x), __pyx_v_axis, __pyx_t_9, __pyx_t_1, ((PyObject *)__pyx_v_ret)};
        __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_12, 5+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2600, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[6] = {__pyx_t_3, ((PyObject *)__pyx_v_x), __pyx_v_axis, __pyx_t_9, __pyx_t_1, ((PyObject *)__pyx_v_ret)};
        __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_12, 5+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2600, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      {
        __pyx_t_2 = PyTuple_New(5+__pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2600, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        if (__pyx_t_3) {
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_x));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_x));
        PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_12, ((PyObject *)__pyx_v_x));
        __Pyx_INCREF(__pyx_v_axis);
        __Pyx_GIVEREF(__pyx_v_axis);
        PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_12, __pyx_v_axis);
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_12, __pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_2, 3+__pyx_t_12, __pyx_t_1);
        __Pyx_INCREF(((PyObject *)__pyx_v_ret));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_ret));
        PyTuple_SET_ITEM(__pyx_t_2, 4+__pyx_t_12, ((PyObject *)__pyx_v_ret));
        __pyx_t_9 = 0;
        __pyx_t_1 = 0;
        __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_2, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2600, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
    __pyx_L21:;
  }
  __pyx_L12:;

  /* "cupy/core/core.pyx":2602
 *             _concatenate_kernel(
 *                 x, axis, array(cum_sizes), array(x_strides), ret)
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * cdef _concatenate_kernel_one = ElementwiseKernel(
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2547
 * 
 * 
 * cpdef ndarray concatenate(tup, axis, shape, dtype):             # <<<<<<<<<<<<<<
 *     cdef ndarray a, x, ret
 *     cdef int i, j, base, cum, ndim
 */

  /* 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_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_13);
  __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_19, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_20, 1);
  __Pyx_AddTraceback("cupy.core.core.concatenate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __PYX_XDEC_MEMVIEW(&__pyx_v_ptrs, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_cum_sizes, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_x_strides, 1);
  __Pyx_XDECREF(__pyx_v_any_contiguous_on_axis);
  __Pyx_XDECREF(__pyx_v_total_bytes);
  __Pyx_XDECREF(__pyx_v_skip);
  __Pyx_XDECREF(__pyx_v_aw);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_73concatenate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_72concatenate[] = "concatenate(tup, axis, shape, dtype) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_73concatenate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tup = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("concatenate (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_tup,&__pyx_n_s_axis,&__pyx_n_s_shape,&__pyx_n_s_dtype,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tup)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("concatenate", 1, 4, 4, 1); __PYX_ERR(0, 2547, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("concatenate", 1, 4, 4, 2); __PYX_ERR(0, 2547, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("concatenate", 1, 4, 4, 3); __PYX_ERR(0, 2547, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "concatenate") < 0)) __PYX_ERR(0, 2547, __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_tup = values[0];
    __pyx_v_axis = values[1];
    __pyx_v_shape = values[2];
    __pyx_v_dtype = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("concatenate", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2547, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.concatenate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_72concatenate(__pyx_self, __pyx_v_tup, __pyx_v_axis, __pyx_v_shape, __pyx_v_dtype);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_72concatenate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tup, PyObject *__pyx_v_axis, PyObject *__pyx_v_shape, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("concatenate", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_concatenate(__pyx_v_tup, __pyx_v_axis, __pyx_v_shape, __pyx_v_dtype, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2547, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.concatenate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2657
 * 
 * 
 * cpdef Py_ssize_t size(ndarray a, axis=None) except *:             # <<<<<<<<<<<<<<
 *     """Returns the number of elements along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_75size(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static Py_ssize_t __pyx_f_4cupy_4core_4core_size(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_size *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  int __pyx_v_index;
  int __pyx_v_ndim;
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("size", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
    }
  }

  /* "cupy/core/core.pyx":2670
 *     """
 *     cdef int index, ndim
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         return a.size
 *     else:
 */
  __pyx_t_1 = (__pyx_v_axis == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2671
 *     cdef int index, ndim
 *     if axis is None:
 *         return a.size             # <<<<<<<<<<<<<<
 *     else:
 *         index = axis
 */
    __pyx_r = __pyx_v_a->size;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2670
 *     """
 *     cdef int index, ndim
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         return a.size
 *     else:
 */
  }

  /* "cupy/core/core.pyx":2673
 *         return a.size
 *     else:
 *         index = axis             # <<<<<<<<<<<<<<
 *         ndim = a._shape.size()
 *         if index < 0:
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_axis); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2673, __pyx_L1_error)
    __pyx_v_index = __pyx_t_3;

    /* "cupy/core/core.pyx":2674
 *     else:
 *         index = axis
 *         ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *         if index < 0:
 *             index += ndim
 */
    __pyx_v_ndim = __pyx_v_a->_shape.size();

    /* "cupy/core/core.pyx":2675
 *         index = axis
 *         ndim = a._shape.size()
 *         if index < 0:             # <<<<<<<<<<<<<<
 *             index += ndim
 *         if not 0 <= index < ndim:
 */
    __pyx_t_2 = ((__pyx_v_index < 0) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2676
 *         ndim = a._shape.size()
 *         if index < 0:
 *             index += ndim             # <<<<<<<<<<<<<<
 *         if not 0 <= index < ndim:
 *             raise IndexError('index out of range')
 */
      __pyx_v_index = (__pyx_v_index + __pyx_v_ndim);

      /* "cupy/core/core.pyx":2675
 *         index = axis
 *         ndim = a._shape.size()
 *         if index < 0:             # <<<<<<<<<<<<<<
 *             index += ndim
 *         if not 0 <= index < ndim:
 */
    }

    /* "cupy/core/core.pyx":2677
 *         if index < 0:
 *             index += ndim
 *         if not 0 <= index < ndim:             # <<<<<<<<<<<<<<
 *             raise IndexError('index out of range')
 *         return a._shape[index]
 */
    __pyx_t_2 = (0 <= __pyx_v_index);
    if (__pyx_t_2) {
      __pyx_t_2 = (__pyx_v_index < __pyx_v_ndim);
    }
    __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":2678
 *             index += ndim
 *         if not 0 <= index < ndim:
 *             raise IndexError('index out of range')             # <<<<<<<<<<<<<<
 *         return a._shape[index]
 * 
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__127, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2678, __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, 2678, __pyx_L1_error)

      /* "cupy/core/core.pyx":2677
 *         if index < 0:
 *             index += ndim
 *         if not 0 <= index < ndim:             # <<<<<<<<<<<<<<
 *             raise IndexError('index out of range')
 *         return a._shape[index]
 */
    }

    /* "cupy/core/core.pyx":2679
 *         if not 0 <= index < ndim:
 *             raise IndexError('index out of range')
 *         return a._shape[index]             # <<<<<<<<<<<<<<
 * 
 * # -----------------------------------------------------------------------------
 */
    __pyx_r = (__pyx_v_a->_shape[__pyx_v_index]);
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":2657
 * 
 * 
 * cpdef Py_ssize_t size(ndarray a, axis=None) except *:             # <<<<<<<<<<<<<<
 *     """Returns the number of elements along a given axis.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_75size(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_74size[] = "size(ndarray a, axis=None) -> Py_ssize_t\nReturns the number of elements along a given axis.\n\n    Args:\n        a (ndarray): Input data.\n        axis (int or None): Axis along which the elements are counted.\n            When it is ``None``, it returns the total number of elements.\n\n    Returns:\n        int: Number of elements along the given axis.\n\n    ";
static PyObject *__pyx_pw_4cupy_4core_4core_75size(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_axis,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__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 = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "size") < 0)) __PYX_ERR(0, 2657, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_axis = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("size", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2657, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 2657, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_74size(__pyx_self, __pyx_v_a, __pyx_v_axis);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_74size(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_axis) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  struct __pyx_opt_args_4cupy_4core_4core_size __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("size", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_size(__pyx_v_a, 0, &__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2657, __pyx_L1_error)
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2657, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core.size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2685
 * # -----------------------------------------------------------------------------
 * 
 * cpdef _create_bit_op(name, op, no_bool, doc=''):             # <<<<<<<<<<<<<<
 *     types = () if no_bool else ('??->?',)
 *     return create_ufunc(
 */

static PyObject *__pyx_pw_4cupy_4core_4core_77_create_bit_op(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__create_bit_op(PyObject *__pyx_v_name, PyObject *__pyx_v_op, PyObject *__pyx_v_no_bool, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__create_bit_op *__pyx_optional_args) {
  PyObject *__pyx_v_doc = ((PyObject *)__pyx_kp_s__5);
  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":2686
 * 
 * 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, 2686, __pyx_L1_error)
  if (__pyx_t_2) {
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_t_1 = __pyx_empty_tuple;
  } else {
    __Pyx_INCREF(__pyx_tuple__129);
    __pyx_t_1 = __pyx_tuple__129;
  }
  __pyx_v_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2687
 * 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, 2687, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":2688
 *     types = () if no_bool else ('??->?',)
 *     return create_ufunc(
 *         'cupy_' + name,             # <<<<<<<<<<<<<<
 *         types + ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
 *                  'LL->L', 'qq->q', 'QQ->Q'),
 */
  __pyx_t_3 = PyNumber_Add(__pyx_n_s_cupy_2, __pyx_v_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2688, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/core.pyx":2689
 *     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__130); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2689, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":2691
 *         types + ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
 *                  'LL->L', 'qq->q', 'QQ->Q'),
 *         'out0 = in0 %s in1' % op,             # <<<<<<<<<<<<<<
 *         doc=doc)
 * 
 */
  __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_out0_in0_s_in1, __pyx_v_op); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2691, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/core.pyx":2687
 * 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, 2687, __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":2692
 *                  'LL->L', 'qq->q', 'QQ->Q'),
 *         'out0 = in0 %s in1' % op,
 *         doc=doc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2692, __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, 2692, __pyx_L1_error)

  /* "cupy/core/core.pyx":2687
 * 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, 2687, __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":2685
 * # -----------------------------------------------------------------------------
 * 
 * cpdef _create_bit_op(name, op, no_bool, doc=''):             # <<<<<<<<<<<<<<
 *     types = () if no_bool else ('??->?',)
 *     return create_ufunc(
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core._create_bit_op", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_types);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_77_create_bit_op(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_76_create_bit_op[] = "_create_bit_op(name, op, no_bool, doc='')";
static PyObject *__pyx_pw_4cupy_4core_4core_77_create_bit_op(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_v_no_bool = 0;
  PyObject *__pyx_v_doc = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_bit_op (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,&__pyx_n_s_op,&__pyx_n_s_no_bool,&__pyx_n_s_doc,0};
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((PyObject *)__pyx_kp_s__5);
    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] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_op)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_bit_op", 0, 3, 4, 1); __PYX_ERR(0, 2685, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_no_bool)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_bit_op", 0, 3, 4, 2); __PYX_ERR(0, 2685, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 2685, __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, 2685, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._create_bit_op", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_76_create_bit_op(__pyx_self, __pyx_v_name, __pyx_v_op, __pyx_v_no_bool, __pyx_v_doc);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_76_create_bit_op(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_op, PyObject *__pyx_v_no_bool, PyObject *__pyx_v_doc) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__create_bit_op __pyx_t_2;
  __Pyx_RefNannySetupContext("_create_bit_op", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.doc = __pyx_v_doc;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_v_name, __pyx_v_op, __pyx_v_no_bool, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2685, __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":2862
 * 
 * 
 * cpdef _prepare_mask_indexing_single(ndarray a, ndarray mask, Py_ssize_t axis):             # <<<<<<<<<<<<<<
 *     cdef ndarray mask_scanned, mask_br, mask_br_scanned
 *     cdef int n_true
 */

static PyObject *__pyx_pw_4cupy_4core_4core_79_prepare_mask_indexing_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__prepare_mask_indexing_single(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask, Py_ssize_t __pyx_v_axis, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask_scanned = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask_br = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask_br_scanned = 0;
  int __pyx_v_n_true;
  PyObject *__pyx_v_lshape = 0;
  PyObject *__pyx_v_rshape = 0;
  PyObject *__pyx_v_masked_shape = NULL;
  PyObject *__pyx_v_mask_type = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  std::vector<Py_ssize_t>  __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("_prepare_mask_indexing_single", 0);

  /* "cupy/core/core.pyx":2867
 *     cdef tuple lshape, rshape, out_shape
 * 
 *     lshape = a.shape[:axis]             # <<<<<<<<<<<<<<
 *     rshape = a.shape[axis + mask.ndim:]
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2867, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_t_1, 0, __pyx_v_axis, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2867, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 2867, __pyx_L1_error)
  __pyx_v_lshape = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2868
 * 
 *     lshape = a.shape[:axis]
 *     rshape = a.shape[axis + mask.ndim:]             # <<<<<<<<<<<<<<
 * 
 *     if mask.size == 0:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_axis); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mask), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_t_2, 0, 0, &__pyx_t_4, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 2868, __pyx_L1_error)
  __pyx_v_rshape = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2870
 *     rshape = a.shape[axis + mask.ndim:]
 * 
 *     if mask.size == 0:             # <<<<<<<<<<<<<<
 *         masked_shape = lshape + (0,) + rshape
 *         mask_br = mask._reshape(masked_shape)
 */
  __pyx_t_5 = ((__pyx_v_mask->size == 0) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":2871
 * 
 *     if mask.size == 0:
 *         masked_shape = lshape + (0,) + rshape             # <<<<<<<<<<<<<<
 *         mask_br = mask._reshape(masked_shape)
 *         return mask_br, mask_br, masked_shape
 */
    __pyx_t_3 = PyNumber_Add(__pyx_v_lshape, __pyx_tuple__131); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2871, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_v_rshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2871, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_masked_shape = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2872
 *     if mask.size == 0:
 *         masked_shape = lshape + (0,) + rshape
 *         mask_br = mask._reshape(masked_shape)             # <<<<<<<<<<<<<<
 *         return mask_br, mask_br, masked_shape
 * 
 */
    __pyx_t_6 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_masked_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2872, __pyx_L1_error)
    __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_mask->__pyx_vtab)->_reshape(__pyx_v_mask, __pyx_t_6, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2872, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_mask_br = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2873
 *         masked_shape = lshape + (0,) + rshape
 *         mask_br = mask._reshape(masked_shape)
 *         return mask_br, mask_br, masked_shape             # <<<<<<<<<<<<<<
 * 
 *     # Get number of True in the mask to determine the shape of the array
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2873, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_mask_br));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_mask_br));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_mask_br));
    __Pyx_INCREF(((PyObject *)__pyx_v_mask_br));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_mask_br));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_mask_br));
    __Pyx_INCREF(__pyx_v_masked_shape);
    __Pyx_GIVEREF(__pyx_v_masked_shape);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_masked_shape);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2870
 *     rshape = a.shape[axis + mask.ndim:]
 * 
 *     if mask.size == 0:             # <<<<<<<<<<<<<<
 *         masked_shape = lshape + (0,) + rshape
 *         mask_br = mask._reshape(masked_shape)
 */
  }

  /* "cupy/core/core.pyx":2877
 *     # Get number of True in the mask to determine the shape of the array
 *     # after masking.
 *     if mask.size <= 2 ** 31 - 1:             # <<<<<<<<<<<<<<
 *         mask_type = numpy.int32
 *     else:
 */
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_mask->size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2877, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_4, __pyx_int_2147483647, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2877, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2877, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":2878
 *     # after masking.
 *     if mask.size <= 2 ** 31 - 1:
 *         mask_type = numpy.int32             # <<<<<<<<<<<<<<
 *     else:
 *         mask_type = numpy.int64
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2878, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_int32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2878, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_mask_type = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2877
 *     # Get number of True in the mask to determine the shape of the array
 *     # after masking.
 *     if mask.size <= 2 ** 31 - 1:             # <<<<<<<<<<<<<<
 *         mask_type = numpy.int32
 *     else:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":2880
 *         mask_type = numpy.int32
 *     else:
 *         mask_type = numpy.int64             # <<<<<<<<<<<<<<
 *     mask_scanned = scan(mask.astype(mask_type).ravel())  # starts with 1
 *     n_true = int(mask_scanned[-1])
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2880, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2880, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_mask_type = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":2881
 *     else:
 *         mask_type = numpy.int64
 *     mask_scanned = scan(mask.astype(mask_type).ravel())  # starts with 1             # <<<<<<<<<<<<<<
 *     n_true = int(mask_scanned[-1])
 *     masked_shape = lshape + (n_true,) + rshape
 */
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_mask->__pyx_vtab)->astype(__pyx_v_mask, __pyx_v_mask_type, 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2881, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3)->__pyx_vtab)->ravel(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3), 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2881, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_scan(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4), 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2881, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_mask_scanned = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2882
 *         mask_type = numpy.int64
 *     mask_scanned = scan(mask.astype(mask_type).ravel())  # starts with 1
 *     n_true = int(mask_scanned[-1])             # <<<<<<<<<<<<<<
 *     masked_shape = lshape + (n_true,) + rshape
 * 
 */
  __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_mask_scanned), -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2882, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2882, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2882, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_n_true = __pyx_t_7;

  /* "cupy/core/core.pyx":2883
 *     mask_scanned = scan(mask.astype(mask_type).ravel())  # starts with 1
 *     n_true = int(mask_scanned[-1])
 *     masked_shape = lshape + (n_true,) + rshape             # <<<<<<<<<<<<<<
 * 
 *     # When mask covers the entire array, broadcasting is not necessary.
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_true); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Add(__pyx_v_lshape, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_v_rshape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_masked_shape = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2886
 * 
 *     # When mask covers the entire array, broadcasting is not necessary.
 *     if mask.ndim == a.ndim and axis == 0:             # <<<<<<<<<<<<<<
 *         return mask, mask_scanned._reshape(mask._shape), masked_shape
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mask), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2886, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2886, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2886, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 2886, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_8) {
  } else {
    __pyx_t_5 = __pyx_t_8;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_8 = ((__pyx_v_axis == 0) != 0);
  __pyx_t_5 = __pyx_t_8;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":2887
 *     # When mask covers the entire array, broadcasting is not necessary.
 *     if mask.ndim == a.ndim and axis == 0:
 *         return mask, mask_scanned._reshape(mask._shape), masked_shape             # <<<<<<<<<<<<<<
 * 
 *     # The scan of the broadcasted array is used to index on kernel.
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_mask_scanned->__pyx_vtab)->_reshape(__pyx_v_mask_scanned, __pyx_v_mask->_shape, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2887, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2887, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_mask));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_mask));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_mask));
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_masked_shape);
    __Pyx_GIVEREF(__pyx_v_masked_shape);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_masked_shape);
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2886
 * 
 *     # When mask covers the entire array, broadcasting is not necessary.
 *     if mask.ndim == a.ndim and axis == 0:             # <<<<<<<<<<<<<<
 *         return mask, mask_scanned._reshape(mask._shape), masked_shape
 * 
 */
  }

  /* "cupy/core/core.pyx":2891
 *     # The scan of the broadcasted array is used to index on kernel.
 *     mask_br = mask._reshape(
 *         axis * (1,) + mask.shape + (a.ndim - axis - mask.ndim) * (1,))             # <<<<<<<<<<<<<<
 *     mask_br = broadcast_to(mask_br, a.shape)
 *     if mask.size <= 2 ** 31 - 1:
 */
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_axis); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyNumber_Multiply(__pyx_t_4, __pyx_tuple__132); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mask), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_axis); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mask), __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyNumber_Subtract(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Multiply(__pyx_t_4, __pyx_tuple__133); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2891, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2890
 * 
 *     # The scan of the broadcasted array is used to index on kernel.
 *     mask_br = mask._reshape(             # <<<<<<<<<<<<<<
 *         axis * (1,) + mask.shape + (a.ndim - axis - mask.ndim) * (1,))
 *     mask_br = broadcast_to(mask_br, a.shape)
 */
  __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_mask->__pyx_vtab)->_reshape(__pyx_v_mask, __pyx_t_6, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_mask_br = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2892
 *     mask_br = mask._reshape(
 *         axis * (1,) + mask.shape + (a.ndim - axis - mask.ndim) * (1,))
 *     mask_br = broadcast_to(mask_br, a.shape)             # <<<<<<<<<<<<<<
 *     if mask.size <= 2 ** 31 - 1:
 *         mask_type = numpy.int32
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2892, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core_broadcast_to(__pyx_v_mask_br, __pyx_t_4, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2892, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF_SET(__pyx_v_mask_br, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2893
 *         axis * (1,) + mask.shape + (a.ndim - axis - mask.ndim) * (1,))
 *     mask_br = broadcast_to(mask_br, a.shape)
 *     if mask.size <= 2 ** 31 - 1:             # <<<<<<<<<<<<<<
 *         mask_type = numpy.int32
 *     else:
 */
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_mask->size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2893, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_int_2147483647, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2893, __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, 2893, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":2894
 *     mask_br = broadcast_to(mask_br, a.shape)
 *     if mask.size <= 2 ** 31 - 1:
 *         mask_type = numpy.int32             # <<<<<<<<<<<<<<
 *     else:
 *         mask_type = numpy.int64
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2894, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2894, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_mask_type, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2893
 *         axis * (1,) + mask.shape + (a.ndim - axis - mask.ndim) * (1,))
 *     mask_br = broadcast_to(mask_br, a.shape)
 *     if mask.size <= 2 ** 31 - 1:             # <<<<<<<<<<<<<<
 *         mask_type = numpy.int32
 *     else:
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":2896
 *         mask_type = numpy.int32
 *     else:
 *         mask_type = numpy.int64             # <<<<<<<<<<<<<<
 *     mask_br_scanned = scan(mask_br.astype(mask_type).ravel())
 *     mask_br_scanned = mask_br_scanned._reshape(mask_br._shape)
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2896, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2896, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_mask_type, __pyx_t_4);
    __pyx_t_4 = 0;
  }
  __pyx_L8:;

  /* "cupy/core/core.pyx":2897
 *     else:
 *         mask_type = numpy.int64
 *     mask_br_scanned = scan(mask_br.astype(mask_type).ravel())             # <<<<<<<<<<<<<<
 *     mask_br_scanned = mask_br_scanned._reshape(mask_br._shape)
 *     return mask_br, mask_br_scanned, masked_shape
 */
  __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_mask_br->__pyx_vtab)->astype(__pyx_v_mask_br, __pyx_v_mask_type, 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2897, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4)->__pyx_vtab)->ravel(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4), 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2897, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core_scan(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2), 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2897, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_mask_br_scanned = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2898
 *         mask_type = numpy.int64
 *     mask_br_scanned = scan(mask_br.astype(mask_type).ravel())
 *     mask_br_scanned = mask_br_scanned._reshape(mask_br._shape)             # <<<<<<<<<<<<<<
 *     return mask_br, mask_br_scanned, masked_shape
 * 
 */
  __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_mask_br_scanned->__pyx_vtab)->_reshape(__pyx_v_mask_br_scanned, __pyx_v_mask_br->_shape, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2898, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF_SET(__pyx_v_mask_br_scanned, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2899
 *     mask_br_scanned = scan(mask_br.astype(mask_type).ravel())
 *     mask_br_scanned = mask_br_scanned._reshape(mask_br._shape)
 *     return mask_br, mask_br_scanned, masked_shape             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_mask_br));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_mask_br));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_mask_br));
  __Pyx_INCREF(((PyObject *)__pyx_v_mask_br_scanned));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_mask_br_scanned));
  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_mask_br_scanned));
  __Pyx_INCREF(__pyx_v_masked_shape);
  __Pyx_GIVEREF(__pyx_v_masked_shape);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_masked_shape);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2862
 * 
 * 
 * cpdef _prepare_mask_indexing_single(ndarray a, ndarray mask, Py_ssize_t axis):             # <<<<<<<<<<<<<<
 *     cdef ndarray mask_scanned, mask_br, mask_br_scanned
 *     cdef int n_true
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core._prepare_mask_indexing_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mask_scanned);
  __Pyx_XDECREF((PyObject *)__pyx_v_mask_br);
  __Pyx_XDECREF((PyObject *)__pyx_v_mask_br_scanned);
  __Pyx_XDECREF(__pyx_v_lshape);
  __Pyx_XDECREF(__pyx_v_rshape);
  __Pyx_XDECREF(__pyx_v_masked_shape);
  __Pyx_XDECREF(__pyx_v_mask_type);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_79_prepare_mask_indexing_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_78_prepare_mask_indexing_single[] = "_prepare_mask_indexing_single(ndarray a, ndarray mask, Py_ssize_t axis)";
static PyObject *__pyx_pw_4cupy_4core_4core_79_prepare_mask_indexing_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask = 0;
  Py_ssize_t __pyx_v_axis;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_prepare_mask_indexing_single (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_mask,&__pyx_n_s_axis,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mask)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_prepare_mask_indexing_single", 1, 3, 3, 1); __PYX_ERR(0, 2862, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_prepare_mask_indexing_single", 1, 3, 3, 2); __PYX_ERR(0, 2862, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_prepare_mask_indexing_single") < 0)) __PYX_ERR(0, 2862, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_mask = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_axis = __Pyx_PyIndex_AsSsize_t(values[2]); if (unlikely((__pyx_v_axis == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2862, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_prepare_mask_indexing_single", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2862, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._prepare_mask_indexing_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 2862, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mask), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "mask", 0))) __PYX_ERR(0, 2862, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_78_prepare_mask_indexing_single(__pyx_self, __pyx_v_a, __pyx_v_mask, __pyx_v_axis);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_78_prepare_mask_indexing_single(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask, Py_ssize_t __pyx_v_axis) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_prepare_mask_indexing_single", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__prepare_mask_indexing_single(__pyx_v_a, __pyx_v_mask, __pyx_v_axis, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2862, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._prepare_mask_indexing_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2902
 * 
 * 
 * cpdef ndarray _getitem_mask_single(ndarray a, ndarray mask, int axis):             # <<<<<<<<<<<<<<
 *     cdef ndarray mask_scanned
 *     cdef tuple masked_shape
 */

static PyObject *__pyx_pw_4cupy_4core_4core_81_getitem_mask_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__getitem_mask_single(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask, int __pyx_v_axis, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask_scanned = 0;
  PyObject *__pyx_v_masked_shape = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("_getitem_mask_single", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_mask);

  /* "cupy/core/core.pyx":2906
 *     cdef tuple masked_shape
 * 
 *     mask, mask_scanned, masked_shape = _prepare_mask_indexing_single(             # <<<<<<<<<<<<<<
 *         a, mask, axis)
 *     out = ndarray(masked_shape, dtype=a.dtype)
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__prepare_mask_indexing_single(__pyx_v_a, __pyx_v_mask, __pyx_v_axis, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2906, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2906, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2906, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2906, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2906, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2906, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 2; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 3) < 0) __PYX_ERR(0, 2906, __pyx_L1_error)
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2906, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2906, __pyx_L1_error)
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2906, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 2906, __pyx_L1_error)
  __Pyx_DECREF_SET(__pyx_v_mask, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;
  __pyx_v_mask_scanned = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_masked_shape = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2908
 *     mask, mask_scanned, masked_shape = _prepare_mask_indexing_single(
 *         a, mask, axis)
 *     out = ndarray(masked_shape, dtype=a.dtype)             # <<<<<<<<<<<<<<
 *     if out.size == 0:
 *         return out
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2908, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_masked_shape);
  __Pyx_GIVEREF(__pyx_v_masked_shape);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_masked_shape);
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2908, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) __PYX_ERR(0, 2908, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2908, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2909
 *         a, mask, axis)
 *     out = ndarray(masked_shape, dtype=a.dtype)
 *     if out.size == 0:             # <<<<<<<<<<<<<<
 *         return out
 *     return _getitem_mask_kernel(a, mask, mask_scanned, out)
 */
  __pyx_t_7 = ((__pyx_v_out->size == 0) != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":2910
 *     out = ndarray(masked_shape, dtype=a.dtype)
 *     if out.size == 0:
 *         return out             # <<<<<<<<<<<<<<
 *     return _getitem_mask_kernel(a, mask, mask_scanned, out)
 * 
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __pyx_r = __pyx_v_out;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2909
 *         a, mask, axis)
 *     out = ndarray(masked_shape, dtype=a.dtype)
 *     if out.size == 0:             # <<<<<<<<<<<<<<
 *         return out
 *     return _getitem_mask_kernel(a, mask, mask_scanned, out)
 */
  }

  /* "cupy/core/core.pyx":2911
 *     if out.size == 0:
 *         return out
 *     return _getitem_mask_kernel(a, mask, mask_scanned, out)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__getitem_mask_kernel);
  __pyx_t_4 = __pyx_v_4cupy_4core_4core__getitem_mask_kernel; __pyx_t_1 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[5] = {__pyx_t_1, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_mask), ((PyObject *)__pyx_v_mask_scanned), ((PyObject *)__pyx_v_out)};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2911, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[5] = {__pyx_t_1, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_mask), ((PyObject *)__pyx_v_mask_scanned), ((PyObject *)__pyx_v_out)};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2911, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  {
    __pyx_t_2 = PyTuple_New(4+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2911, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_8, ((PyObject *)__pyx_v_a));
    __Pyx_INCREF(((PyObject *)__pyx_v_mask));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_mask));
    PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_8, ((PyObject *)__pyx_v_mask));
    __Pyx_INCREF(((PyObject *)__pyx_v_mask_scanned));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_mask_scanned));
    PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_8, ((PyObject *)__pyx_v_mask_scanned));
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
    PyTuple_SET_ITEM(__pyx_t_2, 3+__pyx_t_8, ((PyObject *)__pyx_v_out));
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2911, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2911, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2902
 * 
 * 
 * cpdef ndarray _getitem_mask_single(ndarray a, ndarray mask, int axis):             # <<<<<<<<<<<<<<
 *     cdef ndarray mask_scanned
 *     cdef tuple masked_shape
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core._getitem_mask_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mask_scanned);
  __Pyx_XDECREF(__pyx_v_masked_shape);
  __Pyx_XDECREF((PyObject *)__pyx_v_out);
  __Pyx_XDECREF((PyObject *)__pyx_v_mask);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_81_getitem_mask_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_80_getitem_mask_single[] = "_getitem_mask_single(ndarray a, ndarray mask, int axis) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_81_getitem_mask_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask = 0;
  int __pyx_v_axis;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_getitem_mask_single (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_mask,&__pyx_n_s_axis,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mask)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_getitem_mask_single", 1, 3, 3, 1); __PYX_ERR(0, 2902, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_getitem_mask_single", 1, 3, 3, 2); __PYX_ERR(0, 2902, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_getitem_mask_single") < 0)) __PYX_ERR(0, 2902, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_mask = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_axis = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_axis == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2902, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_getitem_mask_single", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2902, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._getitem_mask_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 2902, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mask), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "mask", 0))) __PYX_ERR(0, 2902, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_80_getitem_mask_single(__pyx_self, __pyx_v_a, __pyx_v_mask, __pyx_v_axis);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_80_getitem_mask_single(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask, int __pyx_v_axis) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_getitem_mask_single", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__getitem_mask_single(__pyx_v_a, __pyx_v_mask, __pyx_v_axis, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2902, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._getitem_mask_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2914
 * 
 * 
 * cpdef ndarray _take(ndarray a, indices, li=None, ri=None, ndarray out=None):             # <<<<<<<<<<<<<<
 *     # When li == ri, this function behaves similarly to np.take
 *     if a.ndim == 0:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_83_take(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__take(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_indices, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__take *__pyx_optional_args) {
  PyObject *__pyx_v_li = ((PyObject *)Py_None);
  PyObject *__pyx_v_ri = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);
  PyObject *__pyx_v_lshape = NULL;
  PyObject *__pyx_v_rshape = NULL;
  Py_ssize_t __pyx_v_adim;
  PyObject *__pyx_v_index_range = NULL;
  PyObject *__pyx_v_out_shape = NULL;
  PyObject *__pyx_v_cdim = NULL;
  Py_ssize_t __pyx_v_rdim;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_array __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  __Pyx_RefNannySetupContext("_take", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_li = __pyx_optional_args->li;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_ri = __pyx_optional_args->ri;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
        }
      }
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF(__pyx_v_indices);
  __Pyx_INCREF(__pyx_v_li);
  __Pyx_INCREF(__pyx_v_ri);
  __Pyx_INCREF((PyObject *)__pyx_v_out);

  /* "cupy/core/core.pyx":2916
 * cpdef ndarray _take(ndarray a, indices, li=None, ri=None, ndarray out=None):
 *     # When li == ri, this function behaves similarly to np.take
 *     if a.ndim == 0:             # <<<<<<<<<<<<<<
 *         a = a[None]
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2916, __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, 2916, __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, 2916, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2917
 *     # When li == ri, this function behaves similarly to np.take
 *     if a.ndim == 0:
 *         a = a[None]             # <<<<<<<<<<<<<<
 * 
 *     if li is None and ri is None:
 */
    __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_a), Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2917, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2917, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2916
 * cpdef ndarray _take(ndarray a, indices, li=None, ri=None, ndarray out=None):
 *     # When li == ri, this function behaves similarly to np.take
 *     if a.ndim == 0:             # <<<<<<<<<<<<<<
 *         a = a[None]
 * 
 */
  }

  /* "cupy/core/core.pyx":2919
 *         a = a[None]
 * 
 *     if li is None and ri is None:             # <<<<<<<<<<<<<<
 *         a = a.ravel()
 *         lshape = ()
 */
  __pyx_t_4 = (__pyx_v_li == Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_5 = (__pyx_v_ri == Py_None);
  __pyx_t_4 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2920
 * 
 *     if li is None and ri is None:
 *         a = a.ravel()             # <<<<<<<<<<<<<<
 *         lshape = ()
 *         rshape = ()
 */
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->ravel(__pyx_v_a, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2920, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2921
 *     if li is None and ri is None:
 *         a = a.ravel()
 *         lshape = ()             # <<<<<<<<<<<<<<
 *         rshape = ()
 *         adim = 1
 */
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_v_lshape = __pyx_empty_tuple;

    /* "cupy/core/core.pyx":2922
 *         a = a.ravel()
 *         lshape = ()
 *         rshape = ()             # <<<<<<<<<<<<<<
 *         adim = 1
 *         index_range = a.size
 */
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_v_rshape = __pyx_empty_tuple;

    /* "cupy/core/core.pyx":2923
 *         lshape = ()
 *         rshape = ()
 *         adim = 1             # <<<<<<<<<<<<<<
 *         index_range = a.size
 *     else:
 */
    __pyx_v_adim = 1;

    /* "cupy/core/core.pyx":2924
 *         rshape = ()
 *         adim = 1
 *         index_range = a.size             # <<<<<<<<<<<<<<
 *     else:
 *         if not (-a.ndim <= li < a.ndim and -a.ndim <= ri < a.ndim):
 */
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_a->size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2924, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_index_range = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2919
 *         a = a[None]
 * 
 *     if li is None and ri is None:             # <<<<<<<<<<<<<<
 *         a = a.ravel()
 *         lshape = ()
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":2926
 *         index_range = a.size
 *     else:
 *         if not (-a.ndim <= li < a.ndim and -a.ndim <= ri < a.ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis overrun')
 *         if a.ndim != 0:
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2926, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_Negative(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2926, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_v_li, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2926, __pyx_L1_error)
    if (__Pyx_PyObject_IsTrue(__pyx_t_2)) {
      __Pyx_DECREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2926, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_li, __pyx_t_6, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2926, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2926, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_4) {
    } else {
      __pyx_t_3 = __pyx_t_4;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2926, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_Negative(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2926, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_v_ri, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2926, __pyx_L1_error)
    if (__Pyx_PyObject_IsTrue(__pyx_t_2)) {
      __Pyx_DECREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2926, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_ri, __pyx_t_6, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2926, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2926, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = __pyx_t_4;
    __pyx_L8_bool_binop_done:;
    __pyx_t_4 = ((!__pyx_t_3) != 0);
    if (__pyx_t_4) {

      /* "cupy/core/core.pyx":2927
 *     else:
 *         if not (-a.ndim <= li < a.ndim and -a.ndim <= ri < a.ndim):
 *             raise _AxisError('Axis overrun')             # <<<<<<<<<<<<<<
 *         if a.ndim != 0:
 *             li %= a.ndim
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2927, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__134, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2927, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(0, 2927, __pyx_L1_error)

      /* "cupy/core/core.pyx":2926
 *         index_range = a.size
 *     else:
 *         if not (-a.ndim <= li < a.ndim and -a.ndim <= ri < a.ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis overrun')
 *         if a.ndim != 0:
 */
    }

    /* "cupy/core/core.pyx":2928
 *         if not (-a.ndim <= li < a.ndim and -a.ndim <= ri < a.ndim):
 *             raise _AxisError('Axis overrun')
 *         if a.ndim != 0:             # <<<<<<<<<<<<<<
 *             li %= a.ndim
 *             ri %= a.ndim
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2928, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2928, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2928, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_4) {

      /* "cupy/core/core.pyx":2929
 *             raise _AxisError('Axis overrun')
 *         if a.ndim != 0:
 *             li %= a.ndim             # <<<<<<<<<<<<<<
 *             ri %= a.ndim
 * 
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2929, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyNumber_InPlaceRemainder(__pyx_v_li, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2929, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_li, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":2930
 *         if a.ndim != 0:
 *             li %= a.ndim
 *             ri %= a.ndim             # <<<<<<<<<<<<<<
 * 
 *         lshape = a.shape[:li]
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2930, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_InPlaceRemainder(__pyx_v_ri, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2930, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v_ri, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":2928
 *         if not (-a.ndim <= li < a.ndim and -a.ndim <= ri < a.ndim):
 *             raise _AxisError('Axis overrun')
 *         if a.ndim != 0:             # <<<<<<<<<<<<<<
 *             li %= a.ndim
 *             ri %= a.ndim
 */
    }

    /* "cupy/core/core.pyx":2932
 *             ri %= a.ndim
 * 
 *         lshape = a.shape[:li]             # <<<<<<<<<<<<<<
 *         rshape = a.shape[ri + 1:]
 *         adim = internal.prod(a.shape[li:ri + 1])
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2932, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_2, 0, 0, NULL, &__pyx_v_li, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2932, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_lshape = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2933
 * 
 *         lshape = a.shape[:li]
 *         rshape = a.shape[ri + 1:]             # <<<<<<<<<<<<<<
 *         adim = internal.prod(a.shape[li:ri + 1])
 *         index_range = adim
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2933, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_ri, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2933, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_t_1, 0, 0, &__pyx_t_2, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2933, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_rshape = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2934
 *         lshape = a.shape[:li]
 *         rshape = a.shape[ri + 1:]
 *         adim = internal.prod(a.shape[li:ri + 1])             # <<<<<<<<<<<<<<
 *         index_range = adim
 * 
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2934, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_ri, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2934, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_6, 0, 0, &__pyx_v_li, &__pyx_t_2, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2934, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = __pyx_f_4cupy_4core_8internal_prod(__pyx_t_1, 0, NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2934, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_adim = __pyx_t_7;

    /* "cupy/core/core.pyx":2935
 *         rshape = a.shape[ri + 1:]
 *         adim = internal.prod(a.shape[li:ri + 1])
 *         index_range = adim             # <<<<<<<<<<<<<<
 * 
 *     if numpy.isscalar(indices):
 */
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_adim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2935, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_index_range = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":2937
 *         index_range = adim
 * 
 *     if numpy.isscalar(indices):             # <<<<<<<<<<<<<<
 *         indices %= index_range
 *         if li is not None and ri is not None and li == ri:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2937, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_isscalar); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2937, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2937, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_indices};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2937, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_indices};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2937, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2937, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_INCREF(__pyx_v_indices);
      __Pyx_GIVEREF(__pyx_v_indices);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_indices);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2937, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2937, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":2938
 * 
 *     if numpy.isscalar(indices):
 *         indices %= index_range             # <<<<<<<<<<<<<<
 *         if li is not None and ri is not None and li == ri:
 *             a = rollaxis(a, li)
 */
    __pyx_t_1 = PyNumber_InPlaceRemainder(__pyx_v_indices, __pyx_v_index_range); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2938, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_indices, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2939
 *     if numpy.isscalar(indices):
 *         indices %= index_range
 *         if li is not None and ri is not None and li == ri:             # <<<<<<<<<<<<<<
 *             a = rollaxis(a, li)
 *         if out is None:
 */
    __pyx_t_3 = (__pyx_v_li != Py_None);
    __pyx_t_5 = (__pyx_t_3 != 0);
    if (__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_ri != Py_None);
    __pyx_t_3 = (__pyx_t_5 != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_4 = __pyx_t_3;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_li, __pyx_v_ri, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2939, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2939, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = __pyx_t_3;
    __pyx_L13_bool_binop_done:;
    if (__pyx_t_4) {

      /* "cupy/core/core.pyx":2940
 *         indices %= index_range
 *         if li is not None and ri is not None and li == ri:
 *             a = rollaxis(a, li)             # <<<<<<<<<<<<<<
 *         if out is None:
 *             return a[indices].copy()
 */
      __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_v_li); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2940, __pyx_L1_error)
      __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_rollaxis(__pyx_v_a, __pyx_t_7, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2940, __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":2939
 *     if numpy.isscalar(indices):
 *         indices %= index_range
 *         if li is not None and ri is not None and li == ri:             # <<<<<<<<<<<<<<
 *             a = rollaxis(a, li)
 *         if out is None:
 */
    }

    /* "cupy/core/core.pyx":2941
 *         if li is not None and ri is not None and li == ri:
 *             a = rollaxis(a, li)
 *         if out is None:             # <<<<<<<<<<<<<<
 *             return a[indices].copy()
 *         else:
 */
    __pyx_t_4 = (((PyObject *)__pyx_v_out) == Py_None);
    __pyx_t_3 = (__pyx_t_4 != 0);
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":2942
 *             a = rollaxis(a, li)
 *         if out is None:
 *             return a[indices].copy()             # <<<<<<<<<<<<<<
 *         else:
 *             if out.dtype != a.dtype:
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_6 = PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_v_indices); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2942, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_copy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2942, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_6) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2942, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else {
        __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2942, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2942, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
      __pyx_t_1 = 0;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2941
 *         if li is not None and ri is not None and li == ri:
 *             a = rollaxis(a, li)
 *         if out is None:             # <<<<<<<<<<<<<<
 *             return a[indices].copy()
 *         else:
 */
    }

    /* "cupy/core/core.pyx":2944
 *             return a[indices].copy()
 *         else:
 *             if out.dtype != a.dtype:             # <<<<<<<<<<<<<<
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:
 */
    /*else*/ {
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_out->dtype, __pyx_v_a->dtype, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2944, __pyx_L1_error)
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2944, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_3) {

        /* "cupy/core/core.pyx":2945
 *         else:
 *             if out.dtype != a.dtype:
 *                 raise TypeError('Output dtype mismatch')             # <<<<<<<<<<<<<<
 *             if out.shape != a.shape[1:]:
 *                 raise ValueError('Output shape mismatch')
 */
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__135, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2945, __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, 2945, __pyx_L1_error)

        /* "cupy/core/core.pyx":2944
 *             return a[indices].copy()
 *         else:
 *             if out.dtype != a.dtype:             # <<<<<<<<<<<<<<
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:
 */
      }

      /* "cupy/core/core.pyx":2946
 *             if out.dtype != a.dtype:
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Output shape mismatch')
 *             out[()] = a[indices]
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2946, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2946, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_t_8, 1, 0, NULL, NULL, &__pyx_slice__136, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2946, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_1, __pyx_t_6, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2946, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2946, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (__pyx_t_3) {

        /* "cupy/core/core.pyx":2947
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:
 *                 raise ValueError('Output shape mismatch')             # <<<<<<<<<<<<<<
 *             out[()] = a[indices]
 *             return out
 */
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__137, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2947, __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, 2947, __pyx_L1_error)

        /* "cupy/core/core.pyx":2946
 *             if out.dtype != a.dtype:
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Output shape mismatch')
 *             out[()] = a[indices]
 */
      }

      /* "cupy/core/core.pyx":2948
 *             if out.shape != a.shape[1:]:
 *                 raise ValueError('Output shape mismatch')
 *             out[()] = a[indices]             # <<<<<<<<<<<<<<
 *             return out
 *     elif not isinstance(indices, ndarray):
 */
      __pyx_t_8 = PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_v_indices); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2948, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_out), __pyx_empty_tuple, __pyx_t_8) < 0)) __PYX_ERR(0, 2948, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":2949
 *                 raise ValueError('Output shape mismatch')
 *             out[()] = a[indices]
 *             return out             # <<<<<<<<<<<<<<
 *     elif not isinstance(indices, ndarray):
 *         indices = array(indices, dtype=int)
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(((PyObject *)__pyx_v_out));
      __pyx_r = __pyx_v_out;
      goto __pyx_L0;
    }

    /* "cupy/core/core.pyx":2937
 *         index_range = adim
 * 
 *     if numpy.isscalar(indices):             # <<<<<<<<<<<<<<
 *         indices %= index_range
 *         if li is not None and ri is not None and li == ri:
 */
  }

  /* "cupy/core/core.pyx":2950
 *             out[()] = a[indices]
 *             return out
 *     elif not isinstance(indices, ndarray):             # <<<<<<<<<<<<<<
 *         indices = array(indices, dtype=int)
 * 
 */
  __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_indices, __pyx_ptype_4cupy_4core_4core_ndarray); 
  __pyx_t_4 = ((!(__pyx_t_3 != 0)) != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":2951
 *             return out
 *     elif not isinstance(indices, ndarray):
 *         indices = array(indices, dtype=int)             # <<<<<<<<<<<<<<
 * 
 *     out_shape = lshape + indices.shape + rshape
 */
    __pyx_t_9.__pyx_n = 1;
    __pyx_t_9.dtype = ((PyObject *)(&PyInt_Type));
    __pyx_t_8 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_v_indices, 0, &__pyx_t_9)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2951, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF_SET(__pyx_v_indices, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":2950
 *             out[()] = a[indices]
 *             return out
 *     elif not isinstance(indices, ndarray):             # <<<<<<<<<<<<<<
 *         indices = array(indices, dtype=int)
 * 
 */
  }

  /* "cupy/core/core.pyx":2953
 *         indices = array(indices, dtype=int)
 * 
 *     out_shape = lshape + indices.shape + rshape             # <<<<<<<<<<<<<<
 *     if out is None:
 *         out = ndarray(out_shape, dtype=a.dtype)
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2953, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = PyNumber_Add(__pyx_v_lshape, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2953, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyNumber_Add(__pyx_t_6, __pyx_v_rshape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2953, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_out_shape = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2954
 * 
 *     out_shape = lshape + indices.shape + rshape
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(out_shape, dtype=a.dtype)
 *     else:
 */
  __pyx_t_4 = (((PyObject *)__pyx_v_out) == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2955
 *     out_shape = lshape + indices.shape + rshape
 *     if out is None:
 *         out = ndarray(out_shape, dtype=a.dtype)             # <<<<<<<<<<<<<<
 *     else:
 *         if out.dtype != a.dtype:
 */
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2955, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v_out_shape);
    __Pyx_GIVEREF(__pyx_v_out_shape);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_out_shape);
    __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2955, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) __PYX_ERR(0, 2955, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2955, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2954
 * 
 *     out_shape = lshape + indices.shape + rshape
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(out_shape, dtype=a.dtype)
 *     else:
 */
    goto __pyx_L19;
  }

  /* "cupy/core/core.pyx":2957
 *         out = ndarray(out_shape, dtype=a.dtype)
 *     else:
 *         if out.dtype != a.dtype:             # <<<<<<<<<<<<<<
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:
 */
  /*else*/ {
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_out->dtype, __pyx_v_a->dtype, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2957, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2957, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":2958
 *     else:
 *         if out.dtype != a.dtype:
 *             raise TypeError('Output dtype mismatch')             # <<<<<<<<<<<<<<
 *         if out.shape != out_shape:
 *             raise ValueError('Output shape mismatch')
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__138, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2958, __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, 2958, __pyx_L1_error)

      /* "cupy/core/core.pyx":2957
 *         out = ndarray(out_shape, dtype=a.dtype)
 *     else:
 *         if out.dtype != a.dtype:             # <<<<<<<<<<<<<<
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:
 */
    }

    /* "cupy/core/core.pyx":2959
 *         if out.dtype != a.dtype:
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Output shape mismatch')
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2959, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_v_out_shape, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2959, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2959, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":2960
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:
 *             raise ValueError('Output shape mismatch')             # <<<<<<<<<<<<<<
 * 
 *     cdim = indices.size
 */
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__139, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2960, __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, 2960, __pyx_L1_error)

      /* "cupy/core/core.pyx":2959
 *         if out.dtype != a.dtype:
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Output shape mismatch')
 * 
 */
    }
  }
  __pyx_L19:;

  /* "cupy/core/core.pyx":2962
 *             raise ValueError('Output shape mismatch')
 * 
 *     cdim = indices.size             # <<<<<<<<<<<<<<
 *     rdim = internal.prod(rshape)
 *     indices = indices.reshape(
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2962, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_cdim = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":2963
 * 
 *     cdim = indices.size
 *     rdim = internal.prod(rshape)             # <<<<<<<<<<<<<<
 *     indices = indices.reshape(
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 */
  __pyx_t_7 = __pyx_f_4cupy_4core_8internal_prod(__pyx_v_rshape, 0, NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2963, __pyx_L1_error)
  __pyx_v_rdim = __pyx_t_7;

  /* "cupy/core/core.pyx":2964
 *     cdim = indices.size
 *     rdim = internal.prod(rshape)
 *     indices = indices.reshape(             # <<<<<<<<<<<<<<
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 *     if (li == 0 and ri == 0) or (li is None and ri is None):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2964, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":2965
 *     rdim = internal.prod(rshape)
 *     indices = indices.reshape(
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))             # <<<<<<<<<<<<<<
 *     if (li == 0 and ri == 0) or (li is None and ri is None):
 *         return _take_kernel_0axis(
 */
  __pyx_t_7 = PyObject_Length(__pyx_v_lshape); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 2965, __pyx_L1_error)
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2965, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = PyNumber_Multiply(__pyx_tuple__140, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2965, __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_indices, __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2965, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_10 = PyNumber_Add(__pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2965, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_7 = PyObject_Length(__pyx_v_rshape); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 2965, __pyx_L1_error)
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2965, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = PyNumber_Multiply(__pyx_tuple__141, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2965, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyNumber_Add(__pyx_t_10, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2965, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(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);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2964, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_8};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2964, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_8};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2964, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2964, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2964, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_indices, __pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":2966
 *     indices = indices.reshape(
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 *     if (li == 0 and ri == 0) or (li is None and ri is None):             # <<<<<<<<<<<<<<
 *         return _take_kernel_0axis(
 *             a.reduced_view(), indices, rdim, index_range, out)
 */
  __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_v_li, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2966, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2966, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!__pyx_t_4) {
    goto __pyx_L24_next_or;
  } else {
  }
  __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_v_ri, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2966, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2966, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L23_bool_binop_done;
  }
  __pyx_L24_next_or:;
  __pyx_t_4 = (__pyx_v_li == Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L23_bool_binop_done;
  }
  __pyx_t_5 = (__pyx_v_ri == Py_None);
  __pyx_t_4 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L23_bool_binop_done:;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2967
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 *     if (li == 0 and ri == 0) or (li is None and ri is None):
 *         return _take_kernel_0axis(             # <<<<<<<<<<<<<<
 *             a.reduced_view(), indices, rdim, index_range, out)
 *     else:
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));

    /* "cupy/core/core.pyx":2968
 *     if (li == 0 and ri == 0) or (li is None and ri is None):
 *         return _take_kernel_0axis(
 *             a.reduced_view(), indices, rdim, index_range, out)             # <<<<<<<<<<<<<<
 *     else:
 *         return _take_kernel(
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->reduced_view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2968, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = PyInt_FromSsize_t(__pyx_v_rdim); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2968, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__take_kernel_0axis);
    __pyx_t_8 = __pyx_v_4cupy_4core_4core__take_kernel_0axis; __pyx_t_2 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[6] = {__pyx_t_2, __pyx_t_1, __pyx_v_indices, __pyx_t_10, __pyx_v_index_range, ((PyObject *)__pyx_v_out)};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2967, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[6] = {__pyx_t_2, __pyx_t_1, __pyx_v_indices, __pyx_t_10, __pyx_v_index_range, ((PyObject *)__pyx_v_out)};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2967, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(5+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2967, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_1);
      __Pyx_INCREF(__pyx_v_indices);
      __Pyx_GIVEREF(__pyx_v_indices);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_v_indices);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_t_10);
      __Pyx_INCREF(__pyx_v_index_range);
      __Pyx_GIVEREF(__pyx_v_index_range);
      PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_11, __pyx_v_index_range);
      __Pyx_INCREF(((PyObject *)__pyx_v_out));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
      PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_11, ((PyObject *)__pyx_v_out));
      __pyx_t_1 = 0;
      __pyx_t_10 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2967, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":2967
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 *     if (li == 0 and ri == 0) or (li is None and ri is None):
 *         return _take_kernel_0axis(             # <<<<<<<<<<<<<<
 *             a.reduced_view(), indices, rdim, index_range, out)
 *     else:
 */
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2967, __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":2966
 *     indices = indices.reshape(
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 *     if (li == 0 and ri == 0) or (li is None and ri is None):             # <<<<<<<<<<<<<<
 *         return _take_kernel_0axis(
 *             a.reduced_view(), indices, rdim, index_range, out)
 */
  }

  /* "cupy/core/core.pyx":2970
 *             a.reduced_view(), indices, rdim, index_range, out)
 *     else:
 *         return _take_kernel(             # <<<<<<<<<<<<<<
 *             a.reduced_view(), indices, cdim, rdim, adim, index_range, out)
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));

    /* "cupy/core/core.pyx":2971
 *     else:
 *         return _take_kernel(
 *             a.reduced_view(), indices, cdim, rdim, adim, index_range, out)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_8 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->reduced_view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_rdim); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_10 = PyInt_FromSsize_t(__pyx_v_adim); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__take_kernel);
    __pyx_t_1 = __pyx_v_4cupy_4core_4core__take_kernel; __pyx_t_2 = NULL;
    __pyx_t_11 = 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_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[8] = {__pyx_t_2, __pyx_t_8, __pyx_v_indices, __pyx_v_cdim, __pyx_t_12, __pyx_t_10, __pyx_v_index_range, ((PyObject *)__pyx_v_out)};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 7+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2970, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[8] = {__pyx_t_2, __pyx_t_8, __pyx_v_indices, __pyx_v_cdim, __pyx_t_12, __pyx_t_10, __pyx_v_index_range, ((PyObject *)__pyx_v_out)};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 7+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2970, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    {
      __pyx_t_13 = PyTuple_New(7+__pyx_t_11); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2970, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_11, __pyx_t_8);
      __Pyx_INCREF(__pyx_v_indices);
      __Pyx_GIVEREF(__pyx_v_indices);
      PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_11, __pyx_v_indices);
      __Pyx_INCREF(__pyx_v_cdim);
      __Pyx_GIVEREF(__pyx_v_cdim);
      PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_11, __pyx_v_cdim);
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_13, 3+__pyx_t_11, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_13, 4+__pyx_t_11, __pyx_t_10);
      __Pyx_INCREF(__pyx_v_index_range);
      __Pyx_GIVEREF(__pyx_v_index_range);
      PyTuple_SET_ITEM(__pyx_t_13, 5+__pyx_t_11, __pyx_v_index_range);
      __Pyx_INCREF(((PyObject *)__pyx_v_out));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
      PyTuple_SET_ITEM(__pyx_t_13, 6+__pyx_t_11, ((PyObject *)__pyx_v_out));
      __pyx_t_8 = 0;
      __pyx_t_12 = 0;
      __pyx_t_10 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_13, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2970, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2970
 *             a.reduced_view(), indices, rdim, index_range, out)
 *     else:
 *         return _take_kernel(             # <<<<<<<<<<<<<<
 *             a.reduced_view(), indices, cdim, rdim, adim, index_range, out)
 * 
 */
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2970, __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":2914
 * 
 * 
 * cpdef ndarray _take(ndarray a, indices, li=None, ri=None, ndarray out=None):             # <<<<<<<<<<<<<<
 *     # When li == ri, this function behaves similarly to np.take
 *     if a.ndim == 0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("cupy.core.core._take", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_lshape);
  __Pyx_XDECREF(__pyx_v_rshape);
  __Pyx_XDECREF(__pyx_v_index_range);
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XDECREF(__pyx_v_cdim);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_indices);
  __Pyx_XDECREF(__pyx_v_li);
  __Pyx_XDECREF(__pyx_v_ri);
  __Pyx_XDECREF((PyObject *)__pyx_v_out);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_83_take(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_82_take[] = "_take(ndarray a, indices, li=None, ri=None, ndarray out=None) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_83_take(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_indices = 0;
  PyObject *__pyx_v_li = 0;
  PyObject *__pyx_v_ri = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_take (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_indices,&__pyx_n_s_li,&__pyx_n_s_ri,&__pyx_n_s_out,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[4] = (PyObject *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_indices)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_take", 0, 2, 5, 1); __PYX_ERR(0, 2914, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_li);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ri);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_take") < 0)) __PYX_ERR(0, 2914, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_indices = values[1];
    __pyx_v_li = values[2];
    __pyx_v_ri = values[3];
    __pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[4]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_take", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2914, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._take", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 2914, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(0, 2914, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_82_take(__pyx_self, __pyx_v_a, __pyx_v_indices, __pyx_v_li, __pyx_v_ri, __pyx_v_out);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_82_take(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_indices, PyObject *__pyx_v_li, PyObject *__pyx_v_ri, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__take __pyx_t_2;
  __Pyx_RefNannySetupContext("_take", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.li = __pyx_v_li;
  __pyx_t_2.ri = __pyx_v_ri;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__take(__pyx_v_a, __pyx_v_indices, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2914, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._take", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2974
 * 
 * 
 * cpdef _scatter_op_single(ndarray a, ndarray indices, v,             # <<<<<<<<<<<<<<
 *                          Py_ssize_t li=0, Py_ssize_t ri=0, op=''):
 *     # When op == 'update', this function behaves similarly to
 */

static PyObject *__pyx_pw_4cupy_4core_4core_85_scatter_op_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__scatter_op_single(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_indices, PyObject *__pyx_v_v, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__scatter_op_single *__pyx_optional_args) {
  Py_ssize_t __pyx_v_li = ((Py_ssize_t)0);
  Py_ssize_t __pyx_v_ri = ((Py_ssize_t)0);
  PyObject *__pyx_v_op = ((PyObject *)__pyx_kp_s__5);
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_adim;
  Py_ssize_t __pyx_v_cdim;
  Py_ssize_t __pyx_v_rdim;
  PyObject *__pyx_v_a_shape = 0;
  PyObject *__pyx_v_indices_shape = 0;
  PyObject *__pyx_v_lshape = 0;
  PyObject *__pyx_v_rshape = 0;
  PyObject *__pyx_v_v_shape = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_array __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  std::vector<Py_ssize_t>  __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  __Pyx_RefNannySetupContext("_scatter_op_single", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_li = __pyx_optional_args->li;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_ri = __pyx_optional_args->ri;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_op = __pyx_optional_args->op;
        }
      }
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_indices);
  __Pyx_INCREF(__pyx_v_v);

  /* "cupy/core/core.pyx":2989
 *     cdef tuple a_shape, indices_shape, lshape, rshape, v_shape
 * 
 *     ndim = a._shape.size()             # <<<<<<<<<<<<<<
 * 
 *     if ndim == 0:
 */
  __pyx_v_ndim = __pyx_v_a->_shape.size();

  /* "cupy/core/core.pyx":2991
 *     ndim = a._shape.size()
 * 
 *     if ndim == 0:             # <<<<<<<<<<<<<<
 *         raise ValueError("requires a.ndim >= 1")
 *     if not (-ndim <= li < ndim and -ndim <= ri < ndim):
 */
  __pyx_t_1 = ((__pyx_v_ndim == 0) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2992
 * 
 *     if ndim == 0:
 *         raise ValueError("requires a.ndim >= 1")             # <<<<<<<<<<<<<<
 *     if not (-ndim <= li < ndim and -ndim <= ri < ndim):
 *         raise ValueError('Axis overrun')
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__142, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2992, __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, 2992, __pyx_L1_error)

    /* "cupy/core/core.pyx":2991
 *     ndim = a._shape.size()
 * 
 *     if ndim == 0:             # <<<<<<<<<<<<<<
 *         raise ValueError("requires a.ndim >= 1")
 *     if not (-ndim <= li < ndim and -ndim <= ri < ndim):
 */
  }

  /* "cupy/core/core.pyx":2993
 *     if ndim == 0:
 *         raise ValueError("requires a.ndim >= 1")
 *     if not (-ndim <= li < ndim and -ndim <= ri < ndim):             # <<<<<<<<<<<<<<
 *         raise ValueError('Axis overrun')
 * 
 */
  __pyx_t_3 = ((-__pyx_v_ndim) <= __pyx_v_li);
  if (__pyx_t_3) {
    __pyx_t_3 = (__pyx_v_li < __pyx_v_ndim);
  }
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_4 = ((-__pyx_v_ndim) <= __pyx_v_ri);
  if (__pyx_t_4) {
    __pyx_t_4 = (__pyx_v_ri < __pyx_v_ndim);
  }
  __pyx_t_3 = (__pyx_t_4 != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L5_bool_binop_done:;
  __pyx_t_3 = ((!__pyx_t_1) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2994
 *         raise ValueError("requires a.ndim >= 1")
 *     if not (-ndim <= li < ndim and -ndim <= ri < ndim):
 *         raise ValueError('Axis overrun')             # <<<<<<<<<<<<<<
 * 
 *     if not isinstance(v, ndarray):
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__143, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2994, __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, 2994, __pyx_L1_error)

    /* "cupy/core/core.pyx":2993
 *     if ndim == 0:
 *         raise ValueError("requires a.ndim >= 1")
 *     if not (-ndim <= li < ndim and -ndim <= ri < ndim):             # <<<<<<<<<<<<<<
 *         raise ValueError('Axis overrun')
 * 
 */
  }

  /* "cupy/core/core.pyx":2996
 *         raise ValueError('Axis overrun')
 * 
 *     if not isinstance(v, ndarray):             # <<<<<<<<<<<<<<
 *         v = array(v, dtype=a.dtype)
 *     v = v.astype(a.dtype)
 */
  __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_v, __pyx_ptype_4cupy_4core_4core_ndarray); 
  __pyx_t_1 = ((!(__pyx_t_3 != 0)) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2997
 * 
 *     if not isinstance(v, ndarray):
 *         v = array(v, dtype=a.dtype)             # <<<<<<<<<<<<<<
 *     v = v.astype(a.dtype)
 * 
 */
    __pyx_t_2 = __pyx_v_a->dtype;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6.__pyx_n = 1;
    __pyx_t_6.dtype = __pyx_t_2;
    __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_v_v, 0, &__pyx_t_6)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2997, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2996
 *         raise ValueError('Axis overrun')
 * 
 *     if not isinstance(v, ndarray):             # <<<<<<<<<<<<<<
 *         v = array(v, dtype=a.dtype)
 *     v = v.astype(a.dtype)
 */
  }

  /* "cupy/core/core.pyx":2998
 *     if not isinstance(v, ndarray):
 *         v = array(v, dtype=a.dtype)
 *     v = v.astype(a.dtype)             # <<<<<<<<<<<<<<
 * 
 *     a_shape = a.shape
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_v, __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2998, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_a->dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2998, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_a->dtype};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2998, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_a->dtype};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2998, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2998, __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_INCREF(__pyx_v_a->dtype);
      __Pyx_GIVEREF(__pyx_v_a->dtype);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_a->dtype);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2998, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3000
 *     v = v.astype(a.dtype)
 * 
 *     a_shape = a.shape             # <<<<<<<<<<<<<<
 *     li %= ndim
 *     ri %= ndim
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3000, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (!(likely(PyTuple_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(0, 3000, __pyx_L1_error)
  __pyx_v_a_shape = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3001
 * 
 *     a_shape = a.shape
 *     li %= ndim             # <<<<<<<<<<<<<<
 *     ri %= ndim
 * 
 */
  if (unlikely(__pyx_v_ndim == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 3001, __pyx_L1_error)
  }
  __pyx_v_li = __Pyx_mod_Py_ssize_t(__pyx_v_li, __pyx_v_ndim);

  /* "cupy/core/core.pyx":3002
 *     a_shape = a.shape
 *     li %= ndim
 *     ri %= ndim             # <<<<<<<<<<<<<<
 * 
 *     lshape = a_shape[:li]
 */
  if (unlikely(__pyx_v_ndim == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 3002, __pyx_L1_error)
  }
  __pyx_v_ri = __Pyx_mod_Py_ssize_t(__pyx_v_ri, __pyx_v_ndim);

  /* "cupy/core/core.pyx":3004
 *     ri %= ndim
 * 
 *     lshape = a_shape[:li]             # <<<<<<<<<<<<<<
 *     rshape = a_shape[ri + 1:]
 *     adim = internal.prod(a_shape[li:ri + 1])
 */
  if (unlikely(__pyx_v_a_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 3004, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyTuple_GetSlice(__pyx_v_a_shape, 0, __pyx_v_li); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3004, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_lshape = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3005
 * 
 *     lshape = a_shape[:li]
 *     rshape = a_shape[ri + 1:]             # <<<<<<<<<<<<<<
 *     adim = internal.prod(a_shape[li:ri + 1])
 * 
 */
  if (unlikely(__pyx_v_a_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 3005, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyTuple_GetSlice(__pyx_v_a_shape, (__pyx_v_ri + 1), PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_rshape = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3006
 *     lshape = a_shape[:li]
 *     rshape = a_shape[ri + 1:]
 *     adim = internal.prod(a_shape[li:ri + 1])             # <<<<<<<<<<<<<<
 * 
 *     indices_shape = indices.shape
 */
  if (unlikely(__pyx_v_a_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 3006, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyTuple_GetSlice(__pyx_v_a_shape, __pyx_v_li, (__pyx_v_ri + 1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3006, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_9 = __pyx_f_4cupy_4core_8internal_prod(__pyx_t_5, 0, NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3006, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_adim = __pyx_t_9;

  /* "cupy/core/core.pyx":3008
 *     adim = internal.prod(a_shape[li:ri + 1])
 * 
 *     indices_shape = indices.shape             # <<<<<<<<<<<<<<
 *     v_shape = lshape + indices_shape + rshape
 *     v = broadcast_to(v, v_shape)
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_indices), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3008, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (!(likely(PyTuple_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(0, 3008, __pyx_L1_error)
  __pyx_v_indices_shape = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3009
 * 
 *     indices_shape = indices.shape
 *     v_shape = lshape + indices_shape + rshape             # <<<<<<<<<<<<<<
 *     v = broadcast_to(v, v_shape)
 * 
 */
  __pyx_t_5 = PyNumber_Add(__pyx_v_lshape, __pyx_v_indices_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3009, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = PyNumber_Add(__pyx_t_5, __pyx_v_rshape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3009, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_v_shape = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":3010
 *     indices_shape = indices.shape
 *     v_shape = lshape + indices_shape + rshape
 *     v = broadcast_to(v, v_shape)             # <<<<<<<<<<<<<<
 * 
 *     cdim = indices.size
 */
  if (!(likely(((__pyx_v_v) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_v, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3010, __pyx_L1_error)
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core_broadcast_to(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_v), __pyx_v_v_shape, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3010, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":3012
 *     v = broadcast_to(v, v_shape)
 * 
 *     cdim = indices.size             # <<<<<<<<<<<<<<
 *     rdim = internal.prod(rshape)
 *     indices = indices._reshape(
 */
  __pyx_t_9 = __pyx_v_indices->size;
  __pyx_v_cdim = __pyx_t_9;

  /* "cupy/core/core.pyx":3013
 * 
 *     cdim = indices.size
 *     rdim = internal.prod(rshape)             # <<<<<<<<<<<<<<
 *     indices = indices._reshape(
 *         (1,) * len(lshape) + indices_shape + (1,) * len(rshape))
 */
  __pyx_t_9 = __pyx_f_4cupy_4core_8internal_prod(__pyx_v_rshape, 0, NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3013, __pyx_L1_error)
  __pyx_v_rdim = __pyx_t_9;

  /* "cupy/core/core.pyx":3015
 *     rdim = internal.prod(rshape)
 *     indices = indices._reshape(
 *         (1,) * len(lshape) + indices_shape + (1,) * len(rshape))             # <<<<<<<<<<<<<<
 *     indices = broadcast_to(indices, v_shape)
 * 
 */
  __pyx_t_9 = PyTuple_GET_SIZE(__pyx_v_lshape); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 3015, __pyx_L1_error)
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = PyNumber_Multiply(__pyx_tuple__144, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(__pyx_t_5, __pyx_v_indices_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_9 = PyTuple_GET_SIZE(__pyx_v_rshape); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 3015, __pyx_L1_error)
  __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = PyNumber_Multiply(__pyx_tuple__145, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Add(__pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_10 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3015, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3014
 *     cdim = indices.size
 *     rdim = internal.prod(rshape)
 *     indices = indices._reshape(             # <<<<<<<<<<<<<<
 *         (1,) * len(lshape) + indices_shape + (1,) * len(rshape))
 *     indices = broadcast_to(indices, v_shape)
 */
  __pyx_t_5 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_indices->__pyx_vtab)->_reshape(__pyx_v_indices, __pyx_t_10, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3014, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF_SET(__pyx_v_indices, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3016
 *     indices = indices._reshape(
 *         (1,) * len(lshape) + indices_shape + (1,) * len(rshape))
 *     indices = broadcast_to(indices, v_shape)             # <<<<<<<<<<<<<<
 * 
 *     if op == 'update':
 */
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_broadcast_to(__pyx_v_indices, __pyx_v_v_shape, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3016, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF_SET(__pyx_v_indices, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3018
 *     indices = broadcast_to(indices, v_shape)
 * 
 *     if op == 'update':             # <<<<<<<<<<<<<<
 *         _scatter_update_kernel(
 *             v, indices, cdim, rdim, adim, a.reduced_view())
 */
  __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_n_s_update, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3018, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3020
 *     if op == 'update':
 *         _scatter_update_kernel(
 *             v, indices, cdim, rdim, adim, a.reduced_view())             # <<<<<<<<<<<<<<
 *     elif op == 'add':
 *         # There is constraints on types because atomicAdd() in CUDA 7.5
 */
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_cdim); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3020, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_rdim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3020, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_adim); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3020, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_11 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->reduced_view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3020, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__scatter_update_kernel);
    __pyx_t_12 = __pyx_v_4cupy_4core_4core__scatter_update_kernel; __pyx_t_13 = NULL;
    __pyx_t_14 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_13)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
        __pyx_t_14 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[7] = {__pyx_t_13, __pyx_v_v, ((PyObject *)__pyx_v_indices), __pyx_t_8, __pyx_t_2, __pyx_t_7, __pyx_t_11};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_14, 6+__pyx_t_14); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3019, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[7] = {__pyx_t_13, __pyx_v_v, ((PyObject *)__pyx_v_indices), __pyx_t_8, __pyx_t_2, __pyx_t_7, __pyx_t_11};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_14, 6+__pyx_t_14); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3019, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    {
      __pyx_t_15 = PyTuple_New(6+__pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3019, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      if (__pyx_t_13) {
        __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_13); __pyx_t_13 = NULL;
      }
      __Pyx_INCREF(__pyx_v_v);
      __Pyx_GIVEREF(__pyx_v_v);
      PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_14, __pyx_v_v);
      __Pyx_INCREF(((PyObject *)__pyx_v_indices));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_indices));
      PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_14, ((PyObject *)__pyx_v_indices));
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_14, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_15, 3+__pyx_t_14, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_15, 4+__pyx_t_14, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_15, 5+__pyx_t_14, __pyx_t_11);
      __pyx_t_8 = 0;
      __pyx_t_2 = 0;
      __pyx_t_7 = 0;
      __pyx_t_11 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_15, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3019, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3018
 *     indices = broadcast_to(indices, v_shape)
 * 
 *     if op == 'update':             # <<<<<<<<<<<<<<
 *         _scatter_update_kernel(
 *             v, indices, cdim, rdim, adim, a.reduced_view())
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":3021
 *         _scatter_update_kernel(
 *             v, indices, cdim, rdim, adim, a.reduced_view())
 *     elif op == 'add':             # <<<<<<<<<<<<<<
 *         # There is constraints on types because atomicAdd() in CUDA 7.5
 *         # only supports int32, uint32, uint64, and float32.
 */
  __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_n_s_add, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3021, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3024
 *         # There is constraints on types because atomicAdd() in CUDA 7.5
 *         # only supports int32, uint32, uint64, and float32.
 *         if not issubclass(v.dtype.type,             # <<<<<<<<<<<<<<
 *                           (numpy.int32, numpy.float32,
 *                            numpy.uint32, numpy.uint64, numpy.ulonglong)):
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_v, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3024, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_type); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3024, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3025
 *         # only supports int32, uint32, uint64, and float32.
 *         if not issubclass(v.dtype.type,
 *                           (numpy.int32, numpy.float32,             # <<<<<<<<<<<<<<
 *                            numpy.uint32, numpy.uint64, numpy.ulonglong)):
 *             raise TypeError(
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3025, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int32); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3025, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3025, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_float32); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3025, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3026
 *         if not issubclass(v.dtype.type,
 *                           (numpy.int32, numpy.float32,
 *                            numpy.uint32, numpy.uint64, numpy.ulonglong)):             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 'scatter_add only supports int32, float32, uint32, uint64 as '
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3026, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_uint32); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3026, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3026, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_uint64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3026, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3026, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ulonglong); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3026, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3025
 *         # only supports int32, uint32, uint64, and float32.
 *         if not issubclass(v.dtype.type,
 *                           (numpy.int32, numpy.float32,             # <<<<<<<<<<<<<<
 *                            numpy.uint32, numpy.uint64, numpy.ulonglong)):
 *             raise TypeError(
 */
    __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3025, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_15);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_15);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_t_8);
    __pyx_t_15 = 0;
    __pyx_t_11 = 0;
    __pyx_t_7 = 0;
    __pyx_t_2 = 0;
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":3024
 *         # There is constraints on types because atomicAdd() in CUDA 7.5
 *         # only supports int32, uint32, uint64, and float32.
 *         if not issubclass(v.dtype.type,             # <<<<<<<<<<<<<<
 *                           (numpy.int32, numpy.float32,
 *                            numpy.uint32, numpy.uint64, numpy.ulonglong)):
 */
    __pyx_t_1 = PyObject_IsSubclass(__pyx_t_12, __pyx_t_5); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 3024, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_3 = ((!(__pyx_t_1 != 0)) != 0);
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":3027
 *                           (numpy.int32, numpy.float32,
 *                            numpy.uint32, numpy.uint64, numpy.ulonglong)):
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 'scatter_add only supports int32, float32, uint32, uint64 as '
 *                 'data type')
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__146, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3027, __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, 3027, __pyx_L1_error)

      /* "cupy/core/core.pyx":3024
 *         # There is constraints on types because atomicAdd() in CUDA 7.5
 *         # only supports int32, uint32, uint64, and float32.
 *         if not issubclass(v.dtype.type,             # <<<<<<<<<<<<<<
 *                           (numpy.int32, numpy.float32,
 *                            numpy.uint32, numpy.uint64, numpy.ulonglong)):
 */
    }

    /* "cupy/core/core.pyx":3031
 *                 'data type')
 *         _scatter_add_kernel(
 *             v, indices, cdim, rdim, adim, a.reduced_view())             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError('provided op is not supported')
 */
    __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_cdim); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3031, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_rdim); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3031, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_adim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3031, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->reduced_view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3031, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__scatter_add_kernel);
    __pyx_t_11 = __pyx_v_4cupy_4core_4core__scatter_add_kernel; __pyx_t_15 = NULL;
    __pyx_t_14 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_15)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_15);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
        __pyx_t_14 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[7] = {__pyx_t_15, __pyx_v_v, ((PyObject *)__pyx_v_indices), __pyx_t_12, __pyx_t_8, __pyx_t_2, __pyx_t_7};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_14, 6+__pyx_t_14); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3030, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[7] = {__pyx_t_15, __pyx_v_v, ((PyObject *)__pyx_v_indices), __pyx_t_12, __pyx_t_8, __pyx_t_2, __pyx_t_7};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_14, 6+__pyx_t_14); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3030, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_13 = PyTuple_New(6+__pyx_t_14); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3030, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (__pyx_t_15) {
        __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_15); __pyx_t_15 = NULL;
      }
      __Pyx_INCREF(__pyx_v_v);
      __Pyx_GIVEREF(__pyx_v_v);
      PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_14, __pyx_v_v);
      __Pyx_INCREF(((PyObject *)__pyx_v_indices));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_indices));
      PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_14, ((PyObject *)__pyx_v_indices));
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_14, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_13, 3+__pyx_t_14, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_13, 4+__pyx_t_14, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_13, 5+__pyx_t_14, __pyx_t_7);
      __pyx_t_12 = 0;
      __pyx_t_8 = 0;
      __pyx_t_2 = 0;
      __pyx_t_7 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_13, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3030, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3021
 *         _scatter_update_kernel(
 *             v, indices, cdim, rdim, adim, a.reduced_view())
 *     elif op == 'add':             # <<<<<<<<<<<<<<
 *         # There is constraints on types because atomicAdd() in CUDA 7.5
 *         # only supports int32, uint32, uint64, and float32.
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":3033
 *             v, indices, cdim, rdim, adim, a.reduced_view())
 *     else:
 *         raise ValueError('provided op is not supported')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__147, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3033, __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, 3033, __pyx_L1_error)
  }
  __pyx_L8:;

  /* "cupy/core/core.pyx":2974
 * 
 * 
 * cpdef _scatter_op_single(ndarray a, ndarray indices, v,             # <<<<<<<<<<<<<<
 *                          Py_ssize_t li=0, Py_ssize_t ri=0, op=''):
 *     # When op == 'update', this function behaves similarly to
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("cupy.core.core._scatter_op_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_a_shape);
  __Pyx_XDECREF(__pyx_v_indices_shape);
  __Pyx_XDECREF(__pyx_v_lshape);
  __Pyx_XDECREF(__pyx_v_rshape);
  __Pyx_XDECREF(__pyx_v_v_shape);
  __Pyx_XDECREF((PyObject *)__pyx_v_indices);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_85_scatter_op_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_84_scatter_op_single[] = "_scatter_op_single(ndarray a, ndarray indices, v, Py_ssize_t li=0, Py_ssize_t ri=0, op='')";
static PyObject *__pyx_pw_4cupy_4core_4core_85_scatter_op_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_indices = 0;
  PyObject *__pyx_v_v = 0;
  Py_ssize_t __pyx_v_li;
  Py_ssize_t __pyx_v_ri;
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_scatter_op_single (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_indices,&__pyx_n_s_v,&__pyx_n_s_li,&__pyx_n_s_ri,&__pyx_n_s_op,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[5] = ((PyObject *)__pyx_kp_s__5);
    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] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_indices)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op_single", 0, 3, 6, 1); __PYX_ERR(0, 2974, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_v)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op_single", 0, 3, 6, 2); __PYX_ERR(0, 2974, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_li);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ri);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_op);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_scatter_op_single") < 0)) __PYX_ERR(0, 2974, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_indices = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_v = values[2];
    if (values[3]) {
      __pyx_v_li = __Pyx_PyIndex_AsSsize_t(values[3]); if (unlikely((__pyx_v_li == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2975, __pyx_L3_error)
    } else {
      __pyx_v_li = ((Py_ssize_t)0);
    }
    if (values[4]) {
      __pyx_v_ri = __Pyx_PyIndex_AsSsize_t(values[4]); if (unlikely((__pyx_v_ri == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2975, __pyx_L3_error)
    } else {
      __pyx_v_ri = ((Py_ssize_t)0);
    }
    __pyx_v_op = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_scatter_op_single", 0, 3, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2974, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._scatter_op_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 2974, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_indices), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "indices", 0))) __PYX_ERR(0, 2974, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_84_scatter_op_single(__pyx_self, __pyx_v_a, __pyx_v_indices, __pyx_v_v, __pyx_v_li, __pyx_v_ri, __pyx_v_op);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_84_scatter_op_single(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_indices, PyObject *__pyx_v_v, Py_ssize_t __pyx_v_li, Py_ssize_t __pyx_v_ri, PyObject *__pyx_v_op) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__scatter_op_single __pyx_t_2;
  __Pyx_RefNannySetupContext("_scatter_op_single", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.li = __pyx_v_li;
  __pyx_t_2.ri = __pyx_v_ri;
  __pyx_t_2.op = __pyx_v_op;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__scatter_op_single(__pyx_v_a, __pyx_v_indices, __pyx_v_v, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2974, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._scatter_op_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3036
 * 
 * 
 * cpdef _scatter_op_mask_single(ndarray a, ndarray mask, v, Py_ssize_t axis, op):             # <<<<<<<<<<<<<<
 *     cdef ndarray mask_scanned
 *     cdef tuple masked_shape
 */

static PyObject *__pyx_pw_4cupy_4core_4core_87_scatter_op_mask_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__scatter_op_mask_single(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask, PyObject *__pyx_v_v, Py_ssize_t __pyx_v_axis, PyObject *__pyx_v_op, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask_scanned = 0;
  PyObject *__pyx_v_masked_shape = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  struct __pyx_opt_args_4cupy_4core_4core_array __pyx_t_10;
  int __pyx_t_11;
  __Pyx_RefNannySetupContext("_scatter_op_mask_single", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_mask);
  __Pyx_INCREF(__pyx_v_v);

  /* "cupy/core/core.pyx":3040
 *     cdef tuple masked_shape
 * 
 *     mask, mask_scanned, masked_shape = _prepare_mask_indexing_single(             # <<<<<<<<<<<<<<
 *         a, mask, axis)
 *     if internal.prod(masked_shape) == 0:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__prepare_mask_indexing_single(__pyx_v_a, __pyx_v_mask, __pyx_v_axis, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3040, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 3040, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3040, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3040, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3040, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3040, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 2; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 3) < 0) __PYX_ERR(0, 3040, __pyx_L1_error)
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 3040, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3040, __pyx_L1_error)
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3040, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 3040, __pyx_L1_error)
  __Pyx_DECREF_SET(__pyx_v_mask, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;
  __pyx_v_mask_scanned = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_masked_shape = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":3042
 *     mask, mask_scanned, masked_shape = _prepare_mask_indexing_single(
 *         a, mask, axis)
 *     if internal.prod(masked_shape) == 0:             # <<<<<<<<<<<<<<
 *         return
 * 
 */
  __pyx_t_7 = __pyx_f_4cupy_4core_8internal_prod(__pyx_v_masked_shape, 0, NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3042, __pyx_L1_error)
  __pyx_t_8 = ((__pyx_t_7 == 0) != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":3043
 *         a, mask, axis)
 *     if internal.prod(masked_shape) == 0:
 *         return             # <<<<<<<<<<<<<<
 * 
 *     if not isinstance(v, ndarray):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3042
 *     mask, mask_scanned, masked_shape = _prepare_mask_indexing_single(
 *         a, mask, axis)
 *     if internal.prod(masked_shape) == 0:             # <<<<<<<<<<<<<<
 *         return
 * 
 */
  }

  /* "cupy/core/core.pyx":3045
 *         return
 * 
 *     if not isinstance(v, ndarray):             # <<<<<<<<<<<<<<
 *         v = array(v, dtype=a.dtype)
 *     v = v.astype(a.dtype)
 */
  __pyx_t_8 = __Pyx_TypeCheck(__pyx_v_v, __pyx_ptype_4cupy_4core_4core_ndarray); 
  __pyx_t_9 = ((!(__pyx_t_8 != 0)) != 0);
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3046
 * 
 *     if not isinstance(v, ndarray):
 *         v = array(v, dtype=a.dtype)             # <<<<<<<<<<<<<<
 *     v = v.astype(a.dtype)
 *     # broadcast v to shape determined by the mask
 */
    __pyx_t_1 = __pyx_v_a->dtype;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_10.__pyx_n = 1;
    __pyx_t_10.dtype = __pyx_t_1;
    __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_v_v, 0, &__pyx_t_10)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3046, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3045
 *         return
 * 
 *     if not isinstance(v, ndarray):             # <<<<<<<<<<<<<<
 *         v = array(v, dtype=a.dtype)
 *     v = v.astype(a.dtype)
 */
  }

  /* "cupy/core/core.pyx":3047
 *     if not isinstance(v, ndarray):
 *         v = array(v, dtype=a.dtype)
 *     v = v.astype(a.dtype)             # <<<<<<<<<<<<<<
 *     # broadcast v to shape determined by the mask
 *     v = broadcast_to(v, masked_shape)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_v, __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3047, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_a->dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3047, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_a->dtype};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3047, __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_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_a->dtype};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3047, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3047, __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_INCREF(__pyx_v_a->dtype);
      __Pyx_GIVEREF(__pyx_v_a->dtype);
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_a->dtype);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3047, __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_DECREF_SET(__pyx_v_v, __pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":3049
 *     v = v.astype(a.dtype)
 *     # broadcast v to shape determined by the mask
 *     v = broadcast_to(v, masked_shape)             # <<<<<<<<<<<<<<
 * 
 *     if op == 'update':
 */
  if (!(likely(((__pyx_v_v) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_v, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3049, __pyx_L1_error)
  __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core_broadcast_to(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_v), __pyx_v_masked_shape, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3049, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":3051
 *     v = broadcast_to(v, masked_shape)
 * 
 *     if op == 'update':             # <<<<<<<<<<<<<<
 *         _scatter_update_mask_kernel(v, mask, mask_scanned, a)
 *     elif op == 'add':
 */
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_n_s_update, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3051, __pyx_L1_error)
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3052
 * 
 *     if op == 'update':
 *         _scatter_update_mask_kernel(v, mask, mask_scanned, a)             # <<<<<<<<<<<<<<
 *     elif op == 'add':
 *         _scatter_add_mask_kernel(v, mask, mask_scanned, a)
 */
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__scatter_update_mask_kernel);
    __pyx_t_1 = __pyx_v_4cupy_4core_4core__scatter_update_mask_kernel; __pyx_t_2 = NULL;
    __pyx_t_11 = 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_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[5] = {__pyx_t_2, __pyx_v_v, ((PyObject *)__pyx_v_mask), ((PyObject *)__pyx_v_mask_scanned), ((PyObject *)__pyx_v_a)};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3052, __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[5] = {__pyx_t_2, __pyx_v_v, ((PyObject *)__pyx_v_mask), ((PyObject *)__pyx_v_mask_scanned), ((PyObject *)__pyx_v_a)};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3052, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(4+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3052, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_INCREF(__pyx_v_v);
      __Pyx_GIVEREF(__pyx_v_v);
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_11, __pyx_v_v);
      __Pyx_INCREF(((PyObject *)__pyx_v_mask));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_mask));
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_11, ((PyObject *)__pyx_v_mask));
      __Pyx_INCREF(((PyObject *)__pyx_v_mask_scanned));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_mask_scanned));
      PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_11, ((PyObject *)__pyx_v_mask_scanned));
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
      PyTuple_SET_ITEM(__pyx_t_3, 3+__pyx_t_11, ((PyObject *)__pyx_v_a));
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3052, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3051
 *     v = broadcast_to(v, masked_shape)
 * 
 *     if op == 'update':             # <<<<<<<<<<<<<<
 *         _scatter_update_mask_kernel(v, mask, mask_scanned, a)
 *     elif op == 'add':
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":3053
 *     if op == 'update':
 *         _scatter_update_mask_kernel(v, mask, mask_scanned, a)
 *     elif op == 'add':             # <<<<<<<<<<<<<<
 *         _scatter_add_mask_kernel(v, mask, mask_scanned, a)
 *     else:
 */
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_n_s_add, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3053, __pyx_L1_error)
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3054
 *         _scatter_update_mask_kernel(v, mask, mask_scanned, a)
 *     elif op == 'add':
 *         _scatter_add_mask_kernel(v, mask, mask_scanned, a)             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError('provided op is not supported')
 */
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__scatter_add_mask_kernel);
    __pyx_t_1 = __pyx_v_4cupy_4core_4core__scatter_add_mask_kernel; __pyx_t_3 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_v_v, ((PyObject *)__pyx_v_mask), ((PyObject *)__pyx_v_mask_scanned), ((PyObject *)__pyx_v_a)};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3054, __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_1)) {
      PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_v_v, ((PyObject *)__pyx_v_mask), ((PyObject *)__pyx_v_mask_scanned), ((PyObject *)__pyx_v_a)};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3054, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    {
      __pyx_t_2 = PyTuple_New(4+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3054, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_INCREF(__pyx_v_v);
      __Pyx_GIVEREF(__pyx_v_v);
      PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_11, __pyx_v_v);
      __Pyx_INCREF(((PyObject *)__pyx_v_mask));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_mask));
      PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_11, ((PyObject *)__pyx_v_mask));
      __Pyx_INCREF(((PyObject *)__pyx_v_mask_scanned));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_mask_scanned));
      PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_11, ((PyObject *)__pyx_v_mask_scanned));
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
      PyTuple_SET_ITEM(__pyx_t_2, 3+__pyx_t_11, ((PyObject *)__pyx_v_a));
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3054, __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_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3053
 *     if op == 'update':
 *         _scatter_update_mask_kernel(v, mask, mask_scanned, a)
 *     elif op == 'add':             # <<<<<<<<<<<<<<
 *         _scatter_add_mask_kernel(v, mask, mask_scanned, a)
 *     else:
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":3056
 *         _scatter_add_mask_kernel(v, mask, mask_scanned, a)
 *     else:
 *         raise ValueError('provided op is not supported')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__148, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3056, __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, 3056, __pyx_L1_error)
  }
  __pyx_L7:;

  /* "cupy/core/core.pyx":3036
 * 
 * 
 * cpdef _scatter_op_mask_single(ndarray a, ndarray mask, v, Py_ssize_t axis, op):             # <<<<<<<<<<<<<<
 *     cdef ndarray mask_scanned
 *     cdef tuple masked_shape
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core._scatter_op_mask_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mask_scanned);
  __Pyx_XDECREF(__pyx_v_masked_shape);
  __Pyx_XDECREF((PyObject *)__pyx_v_mask);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_87_scatter_op_mask_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_86_scatter_op_mask_single[] = "_scatter_op_mask_single(ndarray a, ndarray mask, v, Py_ssize_t axis, op)";
static PyObject *__pyx_pw_4cupy_4core_4core_87_scatter_op_mask_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask = 0;
  PyObject *__pyx_v_v = 0;
  Py_ssize_t __pyx_v_axis;
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_scatter_op_mask_single (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_mask,&__pyx_n_s_v,&__pyx_n_s_axis,&__pyx_n_s_op,0};
    PyObject* values[5] = {0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mask)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op_mask_single", 1, 5, 5, 1); __PYX_ERR(0, 3036, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_v)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op_mask_single", 1, 5, 5, 2); __PYX_ERR(0, 3036, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op_mask_single", 1, 5, 5, 3); __PYX_ERR(0, 3036, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_op)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op_mask_single", 1, 5, 5, 4); __PYX_ERR(0, 3036, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_scatter_op_mask_single") < 0)) __PYX_ERR(0, 3036, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_mask = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_v = values[2];
    __pyx_v_axis = __Pyx_PyIndex_AsSsize_t(values[3]); if (unlikely((__pyx_v_axis == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3036, __pyx_L3_error)
    __pyx_v_op = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_scatter_op_mask_single", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3036, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._scatter_op_mask_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3036, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mask), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "mask", 0))) __PYX_ERR(0, 3036, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_86_scatter_op_mask_single(__pyx_self, __pyx_v_a, __pyx_v_mask, __pyx_v_v, __pyx_v_axis, __pyx_v_op);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_86_scatter_op_mask_single(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask, PyObject *__pyx_v_v, Py_ssize_t __pyx_v_axis, PyObject *__pyx_v_op) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_scatter_op_mask_single", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__scatter_op_mask_single(__pyx_v_a, __pyx_v_mask, __pyx_v_v, __pyx_v_axis, __pyx_v_op, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3036, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._scatter_op_mask_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3059
 * 
 * 
 * cpdef _scatter_op(ndarray a, slices, value, op):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, ndim, n_newaxes, n_ellipses, ellipsis, axis
 *     cdef Py_ssize_t n_not_slice_none, mask_i
 */

static PyObject *__pyx_pw_4cupy_4core_4core_89_scatter_op(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__scatter_op(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slices, PyObject *__pyx_v_value, PyObject *__pyx_v_op, CYTHON_UNUSED int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_n_newaxes;
  Py_ssize_t __pyx_v_n_ellipses;
  Py_ssize_t __pyx_v_ellipsis;
  Py_ssize_t __pyx_v_axis;
  Py_ssize_t __pyx_v_n_not_slice_none;
  Py_ssize_t __pyx_v_mask_i;
  Py_ssize_t __pyx_v_ellipsis_size;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_v = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a_interm = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_reduced_idx = 0;
  Py_ssize_t __pyx_v_li;
  Py_ssize_t __pyx_v_ri;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_v_noneslices = NULL;
  int __pyx_v_advanced;
  int __pyx_v_mask_exists;
  int __pyx_v_is_list;
  PyObject *__pyx_v_basic_slices = NULL;
  PyObject *__pyx_v_adv_slices = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_scalar_array = NULL;
  PyObject *__pyx_v_arr_slices_mask = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  struct __pyx_opt_args_4cupy_4core_4core__scatter_op_single __pyx_t_14;
  PyObject *(*__pyx_t_15)(PyObject *);
  size_t __pyx_t_16;
  struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_device_async __pyx_t_17;
  int __pyx_t_18;
  __Pyx_RefNannySetupContext("_scatter_op", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF(__pyx_v_slices);
  __Pyx_INCREF(__pyx_v_value);

  /* "cupy/core/core.pyx":3066
 *     cdef Py_ssize_t li, ri
 * 
 *     if isinstance(slices, tuple):             # <<<<<<<<<<<<<<
 *         slices = list(slices)
 *     elif isinstance(slices, list):
 */
  __pyx_t_1 = PyTuple_Check(__pyx_v_slices); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3067
 * 
 *     if isinstance(slices, tuple):
 *         slices = list(slices)             # <<<<<<<<<<<<<<
 *     elif isinstance(slices, list):
 *         slices = list(slices)  # copy list
 */
    __pyx_t_3 = PySequence_List(__pyx_v_slices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3067, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_slices, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3066
 *     cdef Py_ssize_t li, ri
 * 
 *     if isinstance(slices, tuple):             # <<<<<<<<<<<<<<
 *         slices = list(slices)
 *     elif isinstance(slices, list):
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":3068
 *     if isinstance(slices, tuple):
 *         slices = list(slices)
 *     elif isinstance(slices, list):             # <<<<<<<<<<<<<<
 *         slices = list(slices)  # copy list
 *         if all([isinstance(s, int) for s in slices]):
 */
  __pyx_t_2 = PyList_Check(__pyx_v_slices); 
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3069
 *         slices = list(slices)
 *     elif isinstance(slices, list):
 *         slices = list(slices)  # copy list             # <<<<<<<<<<<<<<
 *         if all([isinstance(s, int) for s in slices]):
 *             slices = [slices]
 */
    __pyx_t_3 = PySequence_List(__pyx_v_slices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3069, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_slices, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3070
 *     elif isinstance(slices, list):
 *         slices = list(slices)  # copy list
 *         if all([isinstance(s, int) for s in slices]):             # <<<<<<<<<<<<<<
 *             slices = [slices]
 *     else:
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3070, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (likely(PyList_CheckExact(__pyx_v_slices)) || PyTuple_CheckExact(__pyx_v_slices)) {
      __pyx_t_4 = __pyx_v_slices; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_slices); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3070, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3070, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 3070, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3070, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 3070, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3070, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        }
      } else {
        __pyx_t_7 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_7)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 3070, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_1 = PyInt_Check(__pyx_v_s); 
      __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3070, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 3070, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3070, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_all, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3070, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3070, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":3071
 *         slices = list(slices)  # copy list
 *         if all([isinstance(s, int) for s in slices]):
 *             slices = [slices]             # <<<<<<<<<<<<<<
 *     else:
 *         slices = [slices]
 */
      __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3071, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_slices);
      __Pyx_GIVEREF(__pyx_v_slices);
      PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_slices);
      __Pyx_DECREF_SET(__pyx_v_slices, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":3070
 *     elif isinstance(slices, list):
 *         slices = list(slices)  # copy list
 *         if all([isinstance(s, int) for s in slices]):             # <<<<<<<<<<<<<<
 *             slices = [slices]
 *     else:
 */
    }

    /* "cupy/core/core.pyx":3068
 *     if isinstance(slices, tuple):
 *         slices = list(slices)
 *     elif isinstance(slices, list):             # <<<<<<<<<<<<<<
 *         slices = list(slices)  # copy list
 *         if all([isinstance(s, int) for s in slices]):
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":3073
 *             slices = [slices]
 *     else:
 *         slices = [slices]             # <<<<<<<<<<<<<<
 * 
 *     # Expand ellipsis into empty slices
 */
  /*else*/ {
    __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3073, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_slices);
    __Pyx_GIVEREF(__pyx_v_slices);
    PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_slices);
    __Pyx_DECREF_SET(__pyx_v_slices, __pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":3076
 * 
 *     # Expand ellipsis into empty slices
 *     ellipsis = -1             # <<<<<<<<<<<<<<
 *     n_newaxes, n_ellipses = 0, 0
 *     for i, s in enumerate(slices):
 */
  __pyx_v_ellipsis = -1L;

  /* "cupy/core/core.pyx":3077
 *     # Expand ellipsis into empty slices
 *     ellipsis = -1
 *     n_newaxes, n_ellipses = 0, 0             # <<<<<<<<<<<<<<
 *     for i, s in enumerate(slices):
 *         if s is None:
 */
  __pyx_t_5 = 0;
  __pyx_t_8 = 0;
  __pyx_v_n_newaxes = __pyx_t_5;
  __pyx_v_n_ellipses = __pyx_t_8;

  /* "cupy/core/core.pyx":3078
 *     ellipsis = -1
 *     n_newaxes, n_ellipses = 0, 0
 *     for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *         if s is None:
 *             n_newaxes += 1
 */
  __pyx_t_8 = 0;
  if (likely(PyList_CheckExact(__pyx_v_slices)) || PyTuple_CheckExact(__pyx_v_slices)) {
    __pyx_t_3 = __pyx_v_slices; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_slices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3078, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3078, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_5 >= 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_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 3078, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3078, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 3078, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3078, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_6(__pyx_t_3);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3078, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_v_i = __pyx_t_8;
    __pyx_t_8 = (__pyx_t_8 + 1);

    /* "cupy/core/core.pyx":3079
 *     n_newaxes, n_ellipses = 0, 0
 *     for i, s in enumerate(slices):
 *         if s is None:             # <<<<<<<<<<<<<<
 *             n_newaxes += 1
 *         elif s is Ellipsis:
 */
    __pyx_t_1 = (__pyx_v_s == Py_None);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":3080
 *     for i, s in enumerate(slices):
 *         if s is None:
 *             n_newaxes += 1             # <<<<<<<<<<<<<<
 *         elif s is Ellipsis:
 *             n_ellipses += 1
 */
      __pyx_v_n_newaxes = (__pyx_v_n_newaxes + 1);

      /* "cupy/core/core.pyx":3079
 *     n_newaxes, n_ellipses = 0, 0
 *     for i, s in enumerate(slices):
 *         if s is None:             # <<<<<<<<<<<<<<
 *             n_newaxes += 1
 *         elif s is Ellipsis:
 */
      goto __pyx_L9;
    }

    /* "cupy/core/core.pyx":3081
 *         if s is None:
 *             n_newaxes += 1
 *         elif s is Ellipsis:             # <<<<<<<<<<<<<<
 *             n_ellipses += 1
 *             ellipsis = i
 */
    __pyx_t_2 = (__pyx_v_s == __pyx_builtin_Ellipsis);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":3082
 *             n_newaxes += 1
 *         elif s is Ellipsis:
 *             n_ellipses += 1             # <<<<<<<<<<<<<<
 *             ellipsis = i
 *     ndim = a._shape.size()
 */
      __pyx_v_n_ellipses = (__pyx_v_n_ellipses + 1);

      /* "cupy/core/core.pyx":3083
 *         elif s is Ellipsis:
 *             n_ellipses += 1
 *             ellipsis = i             # <<<<<<<<<<<<<<
 *     ndim = a._shape.size()
 *     noneslices = [slice(None)]
 */
      __pyx_v_ellipsis = __pyx_v_i;

      /* "cupy/core/core.pyx":3081
 *         if s is None:
 *             n_newaxes += 1
 *         elif s is Ellipsis:             # <<<<<<<<<<<<<<
 *             n_ellipses += 1
 *             ellipsis = i
 */
    }
    __pyx_L9:;

    /* "cupy/core/core.pyx":3078
 *     ellipsis = -1
 *     n_newaxes, n_ellipses = 0, 0
 *     for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *         if s is None:
 *             n_newaxes += 1
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3084
 *             n_ellipses += 1
 *             ellipsis = i
 *     ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *     noneslices = [slice(None)]
 *     if n_ellipses > 0:
 */
  __pyx_v_ndim = __pyx_v_a->_shape.size();

  /* "cupy/core/core.pyx":3085
 *             ellipsis = i
 *     ndim = a._shape.size()
 *     noneslices = [slice(None)]             # <<<<<<<<<<<<<<
 *     if n_ellipses > 0:
 *         if n_ellipses > 1:
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_slice__149);
  __Pyx_GIVEREF(__pyx_slice__149);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_slice__149);
  __pyx_v_noneslices = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3086
 *     ndim = a._shape.size()
 *     noneslices = [slice(None)]
 *     if n_ellipses > 0:             # <<<<<<<<<<<<<<
 *         if n_ellipses > 1:
 *             raise ValueError('Only one Ellipsis is allowed in index')
 */
  __pyx_t_1 = ((__pyx_v_n_ellipses > 0) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3087
 *     noneslices = [slice(None)]
 *     if n_ellipses > 0:
 *         if n_ellipses > 1:             # <<<<<<<<<<<<<<
 *             raise ValueError('Only one Ellipsis is allowed in index')
 *         ellipsis_size = ndim - (<Py_ssize_t>len(slices) - n_newaxes - 1)
 */
    __pyx_t_1 = ((__pyx_v_n_ellipses > 1) != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":3088
 *     if n_ellipses > 0:
 *         if n_ellipses > 1:
 *             raise ValueError('Only one Ellipsis is allowed in index')             # <<<<<<<<<<<<<<
 *         ellipsis_size = ndim - (<Py_ssize_t>len(slices) - n_newaxes - 1)
 *         slices[ellipsis:ellipsis + 1] = noneslices * ellipsis_size
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__150, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3088, __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, 3088, __pyx_L1_error)

      /* "cupy/core/core.pyx":3087
 *     noneslices = [slice(None)]
 *     if n_ellipses > 0:
 *         if n_ellipses > 1:             # <<<<<<<<<<<<<<
 *             raise ValueError('Only one Ellipsis is allowed in index')
 *         ellipsis_size = ndim - (<Py_ssize_t>len(slices) - n_newaxes - 1)
 */
    }

    /* "cupy/core/core.pyx":3089
 *         if n_ellipses > 1:
 *             raise ValueError('Only one Ellipsis is allowed in index')
 *         ellipsis_size = ndim - (<Py_ssize_t>len(slices) - n_newaxes - 1)             # <<<<<<<<<<<<<<
 *         slices[ellipsis:ellipsis + 1] = noneslices * ellipsis_size
 * 
 */
    __pyx_t_8 = PyObject_Length(__pyx_v_slices); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 3089, __pyx_L1_error)
    __pyx_v_ellipsis_size = (__pyx_v_ndim - ((((Py_ssize_t)__pyx_t_8) - __pyx_v_n_newaxes) - 1));

    /* "cupy/core/core.pyx":3090
 *             raise ValueError('Only one Ellipsis is allowed in index')
 *         ellipsis_size = ndim - (<Py_ssize_t>len(slices) - n_newaxes - 1)
 *         slices[ellipsis:ellipsis + 1] = noneslices * ellipsis_size             # <<<<<<<<<<<<<<
 * 
 *     slices += noneslices * (ndim - <Py_ssize_t>len(slices) + n_newaxes)
 */
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ellipsis_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3090, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Multiply(__pyx_v_noneslices, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3090, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__Pyx_PyObject_SetSlice(__pyx_v_slices, __pyx_t_4, __pyx_v_ellipsis, (__pyx_v_ellipsis + 1), NULL, NULL, NULL, 1, 1, 1) < 0) __PYX_ERR(0, 3090, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3086
 *     ndim = a._shape.size()
 *     noneslices = [slice(None)]
 *     if n_ellipses > 0:             # <<<<<<<<<<<<<<
 *         if n_ellipses > 1:
 *             raise ValueError('Only one Ellipsis is allowed in index')
 */
  }

  /* "cupy/core/core.pyx":3092
 *         slices[ellipsis:ellipsis + 1] = noneslices * ellipsis_size
 * 
 *     slices += noneslices * (ndim - <Py_ssize_t>len(slices) + n_newaxes)             # <<<<<<<<<<<<<<
 * 
 *     # Check if advanced is true,
 */
  __pyx_t_8 = PyObject_Length(__pyx_v_slices); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 3092, __pyx_L1_error)
  __pyx_t_4 = PyInt_FromSsize_t(((__pyx_v_ndim - ((Py_ssize_t)__pyx_t_8)) + __pyx_v_n_newaxes)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3092, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyNumber_Multiply(__pyx_v_noneslices, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3092, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_slices, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3092, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_slices, __pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":3096
 *     # Check if advanced is true,
 *     # and convert list/NumPy arrays to cupy.ndarray
 *     advanced = False             # <<<<<<<<<<<<<<
 *     mask_exists = False
 *     for i, s in enumerate(slices):
 */
  __pyx_v_advanced = 0;

  /* "cupy/core/core.pyx":3097
 *     # and convert list/NumPy arrays to cupy.ndarray
 *     advanced = False
 *     mask_exists = False             # <<<<<<<<<<<<<<
 *     for i, s in enumerate(slices):
 *         is_list = False
 */
  __pyx_v_mask_exists = 0;

  /* "cupy/core/core.pyx":3098
 *     advanced = False
 *     mask_exists = False
 *     for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *         is_list = False
 *         if isinstance(s, (list, numpy.ndarray)):
 */
  __pyx_t_8 = 0;
  if (likely(PyList_CheckExact(__pyx_v_slices)) || PyTuple_CheckExact(__pyx_v_slices)) {
    __pyx_t_4 = __pyx_v_slices; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_slices); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3098, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3098, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 3098, __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, 3098, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 3098, __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, 3098, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_6(__pyx_t_4);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3098, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_v_i = __pyx_t_8;
    __pyx_t_8 = (__pyx_t_8 + 1);

    /* "cupy/core/core.pyx":3099
 *     mask_exists = False
 *     for i, s in enumerate(slices):
 *         is_list = False             # <<<<<<<<<<<<<<
 *         if isinstance(s, (list, numpy.ndarray)):
 *             is_list = isinstance(s, list)
 */
    __pyx_v_is_list = 0;

    /* "cupy/core/core.pyx":3100
 *     for i, s in enumerate(slices):
 *         is_list = False
 *         if isinstance(s, (list, numpy.ndarray)):             # <<<<<<<<<<<<<<
 *             is_list = isinstance(s, list)
 *             s = array(s)
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3100, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3100, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = PyList_Check(__pyx_v_s); 
    __pyx_t_9 = (__pyx_t_2 != 0);
    if (!__pyx_t_9) {
    } else {
      __pyx_t_1 = __pyx_t_9;
      goto __pyx_L15_bool_binop_done;
    }
    __pyx_t_9 = PyObject_IsInstance(__pyx_v_s, __pyx_t_7); 
    __pyx_t_2 = (__pyx_t_9 != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L15_bool_binop_done:;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":3101
 *         is_list = False
 *         if isinstance(s, (list, numpy.ndarray)):
 *             is_list = isinstance(s, list)             # <<<<<<<<<<<<<<
 *             s = array(s)
 *             # handle the case when s is an empty list
 */
      __pyx_t_2 = PyList_Check(__pyx_v_s); 
      __pyx_v_is_list = __pyx_t_2;

      /* "cupy/core/core.pyx":3102
 *         if isinstance(s, (list, numpy.ndarray)):
 *             is_list = isinstance(s, list)
 *             s = array(s)             # <<<<<<<<<<<<<<
 *             # handle the case when s is an empty list
 *             if is_list and s.size == 0:
 */
      __pyx_t_7 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_v_s, 0, NULL)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3102, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "cupy/core/core.pyx":3104
 *             s = array(s)
 *             # handle the case when s is an empty list
 *             if is_list and s.size == 0:             # <<<<<<<<<<<<<<
 *                 s = s.astype(numpy.int32)
 *             slices[i] = s
 */
      __pyx_t_1 = (__pyx_v_is_list != 0);
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L18_bool_binop_done;
      }
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_7, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3104, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_2 = __pyx_t_1;
      __pyx_L18_bool_binop_done:;
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":3105
 *             # handle the case when s is an empty list
 *             if is_list and s.size == 0:
 *                 s = s.astype(numpy.int32)             # <<<<<<<<<<<<<<
 *             slices[i] = s
 *         if isinstance(s, ndarray):
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_astype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3105, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3105, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_int32); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3105, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3105, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10);
        __pyx_t_10 = 0;
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3105, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_10);
        __pyx_t_10 = 0;

        /* "cupy/core/core.pyx":3104
 *             s = array(s)
 *             # handle the case when s is an empty list
 *             if is_list and s.size == 0:             # <<<<<<<<<<<<<<
 *                 s = s.astype(numpy.int32)
 *             slices[i] = s
 */
      }

      /* "cupy/core/core.pyx":3106
 *             if is_list and s.size == 0:
 *                 s = s.astype(numpy.int32)
 *             slices[i] = s             # <<<<<<<<<<<<<<
 *         if isinstance(s, ndarray):
 *             if issubclass(s.dtype.type, numpy.integer):
 */
      if (unlikely(__Pyx_SetItemInt(__pyx_v_slices, __pyx_v_i, __pyx_v_s, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1) < 0)) __PYX_ERR(0, 3106, __pyx_L1_error)

      /* "cupy/core/core.pyx":3100
 *     for i, s in enumerate(slices):
 *         is_list = False
 *         if isinstance(s, (list, numpy.ndarray)):             # <<<<<<<<<<<<<<
 *             is_list = isinstance(s, list)
 *             s = array(s)
 */
    }

    /* "cupy/core/core.pyx":3107
 *                 s = s.astype(numpy.int32)
 *             slices[i] = s
 *         if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *             if issubclass(s.dtype.type, numpy.integer):
 *                 advanced = True
 */
    __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":3108
 *             slices[i] = s
 *         if isinstance(s, ndarray):
 *             if issubclass(s.dtype.type, numpy.integer):             # <<<<<<<<<<<<<<
 *                 advanced = True
 *             elif issubclass(s.dtype.type, numpy.bool_):
 */
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3108, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_type); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3108, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3108, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_integer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3108, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_1 = PyObject_IsSubclass(__pyx_t_7, __pyx_t_3); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 3108, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_2 = (__pyx_t_1 != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":3109
 *         if isinstance(s, ndarray):
 *             if issubclass(s.dtype.type, numpy.integer):
 *                 advanced = True             # <<<<<<<<<<<<<<
 *             elif issubclass(s.dtype.type, numpy.bool_):
 *                 mask_exists = not is_list
 */
        __pyx_v_advanced = 1;

        /* "cupy/core/core.pyx":3108
 *             slices[i] = s
 *         if isinstance(s, ndarray):
 *             if issubclass(s.dtype.type, numpy.integer):             # <<<<<<<<<<<<<<
 *                 advanced = True
 *             elif issubclass(s.dtype.type, numpy.bool_):
 */
        goto __pyx_L21;
      }

      /* "cupy/core/core.pyx":3110
 *             if issubclass(s.dtype.type, numpy.integer):
 *                 advanced = True
 *             elif issubclass(s.dtype.type, numpy.bool_):             # <<<<<<<<<<<<<<
 *                 mask_exists = not is_list
 *             else:
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_type); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_bool); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_2 = PyObject_IsSubclass(__pyx_t_7, __pyx_t_10); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 3110, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_1 = (__pyx_t_2 != 0);
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":3111
 *                 advanced = True
 *             elif issubclass(s.dtype.type, numpy.bool_):
 *                 mask_exists = not is_list             # <<<<<<<<<<<<<<
 *             else:
 *                 raise IndexError(
 */
        __pyx_v_mask_exists = (!(__pyx_v_is_list != 0));

        /* "cupy/core/core.pyx":3110
 *             if issubclass(s.dtype.type, numpy.integer):
 *                 advanced = True
 *             elif issubclass(s.dtype.type, numpy.bool_):             # <<<<<<<<<<<<<<
 *                 mask_exists = not is_list
 *             else:
 */
        goto __pyx_L21;
      }

      /* "cupy/core/core.pyx":3113
 *                 mask_exists = not is_list
 *             else:
 *                 raise IndexError(             # <<<<<<<<<<<<<<
 *                     'arrays used as indices must be of integer or boolean '
 *                     'type. (actual: {})'.format(s.dtype.type))
 */
      /*else*/ {

        /* "cupy/core/core.pyx":3115
 *                 raise IndexError(
 *                     'arrays used as indices must be of integer or boolean '
 *                     'type. (actual: {})'.format(s.dtype.type))             # <<<<<<<<<<<<<<
 * 
 *     if not mask_exists and len(slices) > a.ndim + n_newaxes:
 */
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_arrays_used_as_indices_must_be_o, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3115, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3115, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_type); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3115, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(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);
          }
        }
        if (!__pyx_t_3) {
          __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3115, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_t_10);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_7)) {
            PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_11};
            __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3115, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
            PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_11};
            __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3115, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          } else
          #endif
          {
            __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3115, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3); __pyx_t_3 = NULL;
            __Pyx_GIVEREF(__pyx_t_11);
            PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_11);
            __pyx_t_11 = 0;
            __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3115, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "cupy/core/core.pyx":3113
 *                 mask_exists = not is_list
 *             else:
 *                 raise IndexError(             # <<<<<<<<<<<<<<
 *                     'arrays used as indices must be of integer or boolean '
 *                     'type. (actual: {})'.format(s.dtype.type))
 */
        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3113, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10);
        __pyx_t_10 = 0;
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3113, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_Raise(__pyx_t_10, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __PYX_ERR(0, 3113, __pyx_L1_error)
      }
      __pyx_L21:;

      /* "cupy/core/core.pyx":3107
 *                 s = s.astype(numpy.int32)
 *             slices[i] = s
 *         if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *             if issubclass(s.dtype.type, numpy.integer):
 *                 advanced = True
 */
    }

    /* "cupy/core/core.pyx":3098
 *     advanced = False
 *     mask_exists = False
 *     for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *         is_list = False
 *         if isinstance(s, (list, numpy.ndarray)):
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":3117
 *                     'type. (actual: {})'.format(s.dtype.type))
 * 
 *     if not mask_exists and len(slices) > a.ndim + n_newaxes:             # <<<<<<<<<<<<<<
 *         raise IndexError('too many indices for array')
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_mask_exists != 0)) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L23_bool_binop_done;
  }
  __pyx_t_8 = PyObject_Length(__pyx_v_slices); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 3117, __pyx_L1_error)
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_n_newaxes); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_12 = PyNumber_Add(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyObject_RichCompare(__pyx_t_4, __pyx_t_12, Py_GT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3117, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3117, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_1 = __pyx_t_2;
  __pyx_L23_bool_binop_done:;
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3118
 * 
 *     if not mask_exists and len(slices) > a.ndim + n_newaxes:
 *         raise IndexError('too many indices for array')             # <<<<<<<<<<<<<<
 * 
 *     if mask_exists:
 */
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__151, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3118, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_Raise(__pyx_t_7, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __PYX_ERR(0, 3118, __pyx_L1_error)

    /* "cupy/core/core.pyx":3117
 *                     'type. (actual: {})'.format(s.dtype.type))
 * 
 *     if not mask_exists and len(slices) > a.ndim + n_newaxes:             # <<<<<<<<<<<<<<
 *         raise IndexError('too many indices for array')
 * 
 */
  }

  /* "cupy/core/core.pyx":3120
 *         raise IndexError('too many indices for array')
 * 
 *     if mask_exists:             # <<<<<<<<<<<<<<
 *         n_not_slice_none = 0
 *         for i, s in enumerate(slices):
 */
  __pyx_t_1 = (__pyx_v_mask_exists != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3121
 * 
 *     if mask_exists:
 *         n_not_slice_none = 0             # <<<<<<<<<<<<<<
 *         for i, s in enumerate(slices):
 *             if not isinstance(s, slice) or s != slice(None):
 */
    __pyx_v_n_not_slice_none = 0;

    /* "cupy/core/core.pyx":3122
 *     if mask_exists:
 *         n_not_slice_none = 0
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if not isinstance(s, slice) or s != slice(None):
 *                 n_not_slice_none += 1
 */
    __pyx_t_8 = 0;
    if (likely(PyList_CheckExact(__pyx_v_slices)) || PyTuple_CheckExact(__pyx_v_slices)) {
      __pyx_t_7 = __pyx_v_slices; __Pyx_INCREF(__pyx_t_7); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_slices); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3122, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3122, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_12 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_5); __Pyx_INCREF(__pyx_t_12); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 3122, __pyx_L1_error)
          #else
          __pyx_t_12 = PySequence_ITEM(__pyx_t_7, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3122, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_5); __Pyx_INCREF(__pyx_t_12); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 3122, __pyx_L1_error)
          #else
          __pyx_t_12 = PySequence_ITEM(__pyx_t_7, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3122, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          #endif
        }
      } else {
        __pyx_t_12 = __pyx_t_6(__pyx_t_7);
        if (unlikely(!__pyx_t_12)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 3122, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_12);
      }
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_12);
      __pyx_t_12 = 0;
      __pyx_v_i = __pyx_t_8;
      __pyx_t_8 = (__pyx_t_8 + 1);

      /* "cupy/core/core.pyx":3123
 *         n_not_slice_none = 0
 *         for i, s in enumerate(slices):
 *             if not isinstance(s, slice) or s != slice(None):             # <<<<<<<<<<<<<<
 *                 n_not_slice_none += 1
 *                 if issubclass(s.dtype.type, numpy.bool_):
 */
      __pyx_t_2 = PySlice_Check(__pyx_v_s); 
      __pyx_t_9 = ((!(__pyx_t_2 != 0)) != 0);
      if (!__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L29_bool_binop_done;
      }
      __pyx_t_12 = PyObject_RichCompare(__pyx_v_s, __pyx_slice__152, Py_NE); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3123, __pyx_L1_error)
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3123, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_1 = __pyx_t_9;
      __pyx_L29_bool_binop_done:;
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":3124
 *         for i, s in enumerate(slices):
 *             if not isinstance(s, slice) or s != slice(None):
 *                 n_not_slice_none += 1             # <<<<<<<<<<<<<<
 *                 if issubclass(s.dtype.type, numpy.bool_):
 *                     mask_i = i
 */
        __pyx_v_n_not_slice_none = (__pyx_v_n_not_slice_none + 1);

        /* "cupy/core/core.pyx":3125
 *             if not isinstance(s, slice) or s != slice(None):
 *                 n_not_slice_none += 1
 *                 if issubclass(s.dtype.type, numpy.bool_):             # <<<<<<<<<<<<<<
 *                     mask_i = i
 *         if n_not_slice_none != 1:
 */
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3125, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3125, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3125, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_bool); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3125, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_1 = PyObject_IsSubclass(__pyx_t_4, __pyx_t_10); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 3125, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_9 = (__pyx_t_1 != 0);
        if (__pyx_t_9) {

          /* "cupy/core/core.pyx":3126
 *                 n_not_slice_none += 1
 *                 if issubclass(s.dtype.type, numpy.bool_):
 *                     mask_i = i             # <<<<<<<<<<<<<<
 *         if n_not_slice_none != 1:
 *             raise ValueError('currently, CuPy only supports slices that '
 */
          __pyx_v_mask_i = __pyx_v_i;

          /* "cupy/core/core.pyx":3125
 *             if not isinstance(s, slice) or s != slice(None):
 *                 n_not_slice_none += 1
 *                 if issubclass(s.dtype.type, numpy.bool_):             # <<<<<<<<<<<<<<
 *                     mask_i = i
 *         if n_not_slice_none != 1:
 */
        }

        /* "cupy/core/core.pyx":3123
 *         n_not_slice_none = 0
 *         for i, s in enumerate(slices):
 *             if not isinstance(s, slice) or s != slice(None):             # <<<<<<<<<<<<<<
 *                 n_not_slice_none += 1
 *                 if issubclass(s.dtype.type, numpy.bool_):
 */
      }

      /* "cupy/core/core.pyx":3122
 *     if mask_exists:
 *         n_not_slice_none = 0
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if not isinstance(s, slice) or s != slice(None):
 *                 n_not_slice_none += 1
 */
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":3127
 *                 if issubclass(s.dtype.type, numpy.bool_):
 *                     mask_i = i
 *         if n_not_slice_none != 1:             # <<<<<<<<<<<<<<
 *             raise ValueError('currently, CuPy only supports slices that '
 *                              'consist of one boolean array.')
 */
    __pyx_t_9 = ((__pyx_v_n_not_slice_none != 1) != 0);
    if (__pyx_t_9) {

      /* "cupy/core/core.pyx":3128
 *                     mask_i = i
 *         if n_not_slice_none != 1:
 *             raise ValueError('currently, CuPy only supports slices that '             # <<<<<<<<<<<<<<
 *                              'consist of one boolean array.')
 *         _scatter_op_mask_single(a, slices[mask_i], value, mask_i, op)
 */
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__153, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3128, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __PYX_ERR(0, 3128, __pyx_L1_error)

      /* "cupy/core/core.pyx":3127
 *                 if issubclass(s.dtype.type, numpy.bool_):
 *                     mask_i = i
 *         if n_not_slice_none != 1:             # <<<<<<<<<<<<<<
 *             raise ValueError('currently, CuPy only supports slices that '
 *                              'consist of one boolean array.')
 */
    }

    /* "cupy/core/core.pyx":3130
 *             raise ValueError('currently, CuPy only supports slices that '
 *                              'consist of one boolean array.')
 *         _scatter_op_mask_single(a, slices[mask_i], value, mask_i, op)             # <<<<<<<<<<<<<<
 *         return
 * 
 */
    __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_slices, __pyx_v_mask_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3130, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3130, __pyx_L1_error)
    __pyx_t_10 = __pyx_f_4cupy_4core_4core__scatter_op_mask_single(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7), __pyx_v_value, __pyx_v_mask_i, __pyx_v_op, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3130, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":3131
 *                              'consist of one boolean array.')
 *         _scatter_op_mask_single(a, slices[mask_i], value, mask_i, op)
 *         return             # <<<<<<<<<<<<<<
 * 
 *     if advanced:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3120
 *         raise IndexError('too many indices for array')
 * 
 *     if mask_exists:             # <<<<<<<<<<<<<<
 *         n_not_slice_none = 0
 *         for i, s in enumerate(slices):
 */
  }

  /* "cupy/core/core.pyx":3133
 *         return
 * 
 *     if advanced:             # <<<<<<<<<<<<<<
 *         # split slices that can be handled by basic-indexing
 *         basic_slices = []
 */
  __pyx_t_9 = (__pyx_v_advanced != 0);
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3135
 *     if advanced:
 *         # split slices that can be handled by basic-indexing
 *         basic_slices = []             # <<<<<<<<<<<<<<
 *         adv_slices = []
 *         for i, s in enumerate(slices):
 */
    __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3135, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_v_basic_slices = ((PyObject*)__pyx_t_10);
    __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":3136
 *         # split slices that can be handled by basic-indexing
 *         basic_slices = []
 *         adv_slices = []             # <<<<<<<<<<<<<<
 *         for i, s in enumerate(slices):
 *             if type(s) is slice:
 */
    __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3136, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_v_adv_slices = ((PyObject*)__pyx_t_10);
    __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":3137
 *         basic_slices = []
 *         adv_slices = []
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if type(s) is slice:
 *                 basic_slices.append(s)
 */
    __pyx_t_8 = 0;
    if (likely(PyList_CheckExact(__pyx_v_slices)) || PyTuple_CheckExact(__pyx_v_slices)) {
      __pyx_t_10 = __pyx_v_slices; __Pyx_INCREF(__pyx_t_10); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_v_slices); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3137, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_6 = Py_TYPE(__pyx_t_10)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3137, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_10))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_10)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 3137, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_10, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3137, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_10)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 3137, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_10, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3137, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        }
      } else {
        __pyx_t_7 = __pyx_t_6(__pyx_t_10);
        if (unlikely(!__pyx_t_7)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 3137, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_v_i = __pyx_t_8;
      __pyx_t_8 = (__pyx_t_8 + 1);

      /* "cupy/core/core.pyx":3138
 *         adv_slices = []
 *         for i, s in enumerate(slices):
 *             if type(s) is slice:             # <<<<<<<<<<<<<<
 *                 basic_slices.append(s)
 *                 adv_slices.append(slice(None))
 */
      __pyx_t_9 = (((PyObject *)Py_TYPE(__pyx_v_s)) == ((PyObject *)(&PySlice_Type)));
      __pyx_t_1 = (__pyx_t_9 != 0);
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":3139
 *         for i, s in enumerate(slices):
 *             if type(s) is slice:
 *                 basic_slices.append(s)             # <<<<<<<<<<<<<<
 *                 adv_slices.append(slice(None))
 *             elif s is None:
 */
        __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_basic_slices, __pyx_v_s); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 3139, __pyx_L1_error)

        /* "cupy/core/core.pyx":3140
 *             if type(s) is slice:
 *                 basic_slices.append(s)
 *                 adv_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *             elif s is None:
 *                 basic_slices.append(None)
 */
        __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_adv_slices, __pyx_slice__154); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 3140, __pyx_L1_error)

        /* "cupy/core/core.pyx":3138
 *         adv_slices = []
 *         for i, s in enumerate(slices):
 *             if type(s) is slice:             # <<<<<<<<<<<<<<
 *                 basic_slices.append(s)
 *                 adv_slices.append(slice(None))
 */
        goto __pyx_L36;
      }

      /* "cupy/core/core.pyx":3141
 *                 basic_slices.append(s)
 *                 adv_slices.append(slice(None))
 *             elif s is None:             # <<<<<<<<<<<<<<
 *                 basic_slices.append(None)
 *                 adv_slices.append(slice(None))
 */
      __pyx_t_1 = (__pyx_v_s == Py_None);
      __pyx_t_9 = (__pyx_t_1 != 0);
      if (__pyx_t_9) {

        /* "cupy/core/core.pyx":3142
 *                 adv_slices.append(slice(None))
 *             elif s is None:
 *                 basic_slices.append(None)             # <<<<<<<<<<<<<<
 *                 adv_slices.append(slice(None))
 *             elif (isinstance(s, ndarray) and
 */
        __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_basic_slices, Py_None); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 3142, __pyx_L1_error)

        /* "cupy/core/core.pyx":3143
 *             elif s is None:
 *                 basic_slices.append(None)
 *                 adv_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *             elif (isinstance(s, ndarray) and
 *                     issubclass(s.dtype.type, numpy.integer)):
 */
        __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_adv_slices, __pyx_slice__155); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 3143, __pyx_L1_error)

        /* "cupy/core/core.pyx":3141
 *                 basic_slices.append(s)
 *                 adv_slices.append(slice(None))
 *             elif s is None:             # <<<<<<<<<<<<<<
 *                 basic_slices.append(None)
 *                 adv_slices.append(slice(None))
 */
        goto __pyx_L36;
      }

      /* "cupy/core/core.pyx":3144
 *                 basic_slices.append(None)
 *                 adv_slices.append(slice(None))
 *             elif (isinstance(s, ndarray) and             # <<<<<<<<<<<<<<
 *                     issubclass(s.dtype.type, numpy.integer)):
 *                 basic_slices.append(slice(None))
 */
      __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
      __pyx_t_2 = (__pyx_t_1 != 0);
      if (__pyx_t_2) {
      } else {
        __pyx_t_9 = __pyx_t_2;
        goto __pyx_L37_bool_binop_done;
      }

      /* "cupy/core/core.pyx":3145
 *                 adv_slices.append(slice(None))
 *             elif (isinstance(s, ndarray) and
 *                     issubclass(s.dtype.type, numpy.integer)):             # <<<<<<<<<<<<<<
 *                 basic_slices.append(slice(None))
 *                 adv_slices.append(s)
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3145, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3145, __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, 3145, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_integer); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3145, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_2 = PyObject_IsSubclass(__pyx_t_4, __pyx_t_12); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 3145, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_1 = (__pyx_t_2 != 0);
      __pyx_t_9 = __pyx_t_1;
      __pyx_L37_bool_binop_done:;

      /* "cupy/core/core.pyx":3144
 *                 basic_slices.append(None)
 *                 adv_slices.append(slice(None))
 *             elif (isinstance(s, ndarray) and             # <<<<<<<<<<<<<<
 *                     issubclass(s.dtype.type, numpy.integer)):
 *                 basic_slices.append(slice(None))
 */
      if (__pyx_t_9) {

        /* "cupy/core/core.pyx":3146
 *             elif (isinstance(s, ndarray) and
 *                     issubclass(s.dtype.type, numpy.integer)):
 *                 basic_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *                 adv_slices.append(s)
 *             elif isinstance(s, int):
 */
        __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_basic_slices, __pyx_slice__156); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 3146, __pyx_L1_error)

        /* "cupy/core/core.pyx":3147
 *                     issubclass(s.dtype.type, numpy.integer)):
 *                 basic_slices.append(slice(None))
 *                 adv_slices.append(s)             # <<<<<<<<<<<<<<
 *             elif isinstance(s, int):
 *                 basic_slices.append(slice(None))
 */
        __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_adv_slices, __pyx_v_s); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 3147, __pyx_L1_error)

        /* "cupy/core/core.pyx":3144
 *                 basic_slices.append(None)
 *                 adv_slices.append(slice(None))
 *             elif (isinstance(s, ndarray) and             # <<<<<<<<<<<<<<
 *                     issubclass(s.dtype.type, numpy.integer)):
 *                 basic_slices.append(slice(None))
 */
        goto __pyx_L36;
      }

      /* "cupy/core/core.pyx":3148
 *                 basic_slices.append(slice(None))
 *                 adv_slices.append(s)
 *             elif isinstance(s, int):             # <<<<<<<<<<<<<<
 *                 basic_slices.append(slice(None))
 *                 scalar_array = ndarray((), dtype=numpy.int64)
 */
      __pyx_t_9 = PyInt_Check(__pyx_v_s); 
      __pyx_t_1 = (__pyx_t_9 != 0);
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":3149
 *                 adv_slices.append(s)
 *             elif isinstance(s, int):
 *                 basic_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *                 scalar_array = ndarray((), dtype=numpy.int64)
 *                 scalar_array.fill(s)
 */
        __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_basic_slices, __pyx_slice__157); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 3149, __pyx_L1_error)

        /* "cupy/core/core.pyx":3150
 *             elif isinstance(s, int):
 *                 basic_slices.append(slice(None))
 *                 scalar_array = ndarray((), dtype=numpy.int64)             # <<<<<<<<<<<<<<
 *                 scalar_array.fill(s)
 *                 adv_slices.append(scalar_array)
 */
        __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3150, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3150, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int64); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3150, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 3150, __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_tuple__158, __pyx_t_12); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3150, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF_SET(__pyx_v_scalar_array, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7));
        __pyx_t_7 = 0;

        /* "cupy/core/core.pyx":3151
 *                 basic_slices.append(slice(None))
 *                 scalar_array = ndarray((), dtype=numpy.int64)
 *                 scalar_array.fill(s)             # <<<<<<<<<<<<<<
 *                 adv_slices.append(scalar_array)
 *             else:
 */
        __pyx_t_7 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_scalar_array->__pyx_vtab)->fill(__pyx_v_scalar_array, __pyx_v_s, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3151, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "cupy/core/core.pyx":3152
 *                 scalar_array = ndarray((), dtype=numpy.int64)
 *                 scalar_array.fill(s)
 *                 adv_slices.append(scalar_array)             # <<<<<<<<<<<<<<
 *             else:
 *                 raise IndexError(
 */
        __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_adv_slices, ((PyObject *)__pyx_v_scalar_array)); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 3152, __pyx_L1_error)

        /* "cupy/core/core.pyx":3148
 *                 basic_slices.append(slice(None))
 *                 adv_slices.append(s)
 *             elif isinstance(s, int):             # <<<<<<<<<<<<<<
 *                 basic_slices.append(slice(None))
 *                 scalar_array = ndarray((), dtype=numpy.int64)
 */
        goto __pyx_L36;
      }

      /* "cupy/core/core.pyx":3154
 *                 adv_slices.append(scalar_array)
 *             else:
 *                 raise IndexError(             # <<<<<<<<<<<<<<
 *                     'only integers, slices (`:`), ellipsis (`...`),'
 *                     'numpy.newaxis (`None`) and integer or '
 */
      /*else*/ {
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__159, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3154, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_Raise(__pyx_t_7, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __PYX_ERR(0, 3154, __pyx_L1_error)
      }
      __pyx_L36:;

      /* "cupy/core/core.pyx":3137
 *         basic_slices = []
 *         adv_slices = []
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if type(s) is slice:
 *                 basic_slices.append(s)
 */
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":3160
 * 
 *         # check if this is a combination of basic and advanced indexing
 *         for s in basic_slices:             # <<<<<<<<<<<<<<
 *             if s is None or (isinstance(s, slice) and s != slice(None)):
 *                 # returns a view of a
 */
    __pyx_t_10 = __pyx_v_basic_slices; __Pyx_INCREF(__pyx_t_10); __pyx_t_8 = 0;
    for (;;) {
      if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_10)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_7 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_8); __Pyx_INCREF(__pyx_t_7); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 3160, __pyx_L1_error)
      #else
      __pyx_t_7 = PySequence_ITEM(__pyx_t_10, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "cupy/core/core.pyx":3161
 *         # check if this is a combination of basic and advanced indexing
 *         for s in basic_slices:
 *             if s is None or (isinstance(s, slice) and s != slice(None)):             # <<<<<<<<<<<<<<
 *                 # returns a view of a
 *                 a = a[tuple(basic_slices)]
 */
      __pyx_t_9 = (__pyx_v_s == Py_None);
      __pyx_t_2 = (__pyx_t_9 != 0);
      if (!__pyx_t_2) {
      } else {
        __pyx_t_1 = __pyx_t_2;
        goto __pyx_L42_bool_binop_done;
      }
      __pyx_t_2 = PySlice_Check(__pyx_v_s); 
      __pyx_t_9 = (__pyx_t_2 != 0);
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L42_bool_binop_done;
      }
      __pyx_t_7 = PyObject_RichCompare(__pyx_v_s, __pyx_slice__160, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3161, __pyx_L1_error)
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3161, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_1 = __pyx_t_9;
      __pyx_L42_bool_binop_done:;
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":3163
 *             if s is None or (isinstance(s, slice) and s != slice(None)):
 *                 # returns a view of a
 *                 a = a[tuple(basic_slices)]             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
        __pyx_t_7 = PyList_AsTuple(__pyx_v_basic_slices); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3163, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3163, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3163, __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":3164
 *                 # returns a view of a
 *                 a = a[tuple(basic_slices)]
 *                 break             # <<<<<<<<<<<<<<
 * 
 *         arr_slices_mask = [not isinstance(s, slice) for s in adv_slices]
 */
        goto __pyx_L40_break;

        /* "cupy/core/core.pyx":3161
 *         # check if this is a combination of basic and advanced indexing
 *         for s in basic_slices:
 *             if s is None or (isinstance(s, slice) and s != slice(None)):             # <<<<<<<<<<<<<<
 *                 # returns a view of a
 *                 a = a[tuple(basic_slices)]
 */
      }

      /* "cupy/core/core.pyx":3160
 * 
 *         # check if this is a combination of basic and advanced indexing
 *         for s in basic_slices:             # <<<<<<<<<<<<<<
 *             if s is None or (isinstance(s, slice) and s != slice(None)):
 *                 # returns a view of a
 */
    }
    __pyx_L40_break:;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":3166
 *                 break
 * 
 *         arr_slices_mask = [not isinstance(s, slice) for s in adv_slices]             # <<<<<<<<<<<<<<
 *         if sum(arr_slices_mask) == 1:
 *             axis = arr_slices_mask.index(True)
 */
    __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3166, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_12 = __pyx_v_adv_slices; __Pyx_INCREF(__pyx_t_12); __pyx_t_8 = 0;
    for (;;) {
      if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_12)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_7 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_8); __Pyx_INCREF(__pyx_t_7); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 3166, __pyx_L1_error)
      #else
      __pyx_t_7 = PySequence_ITEM(__pyx_t_12, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3166, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_1 = PySlice_Check(__pyx_v_s); 
      __pyx_t_7 = __Pyx_PyBool_FromLong((!(__pyx_t_1 != 0))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3166, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_10, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 3166, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_v_arr_slices_mask = ((PyObject*)__pyx_t_10);
    __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":3167
 * 
 *         arr_slices_mask = [not isinstance(s, slice) for s in adv_slices]
 *         if sum(arr_slices_mask) == 1:             # <<<<<<<<<<<<<<
 *             axis = arr_slices_mask.index(True)
 *             _scatter_op_single(a, adv_slices[axis], value,
 */
    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3167, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_INCREF(__pyx_v_arr_slices_mask);
    __Pyx_GIVEREF(__pyx_v_arr_slices_mask);
    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_arr_slices_mask);
    __pyx_t_12 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_10, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3167, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyInt_EqObjC(__pyx_t_12, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3167, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3167, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":3168
 *         arr_slices_mask = [not isinstance(s, slice) for s in adv_slices]
 *         if sum(arr_slices_mask) == 1:
 *             axis = arr_slices_mask.index(True)             # <<<<<<<<<<<<<<
 *             _scatter_op_single(a, adv_slices[axis], value,
 *                                li=axis, ri=axis, op=op)
 */
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr_slices_mask, __pyx_n_s_index); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3168, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__161, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3168, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_12); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3168, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_v_axis = __pyx_t_8;

      /* "cupy/core/core.pyx":3169
 *         if sum(arr_slices_mask) == 1:
 *             axis = arr_slices_mask.index(True)
 *             _scatter_op_single(a, adv_slices[axis], value,             # <<<<<<<<<<<<<<
 *                                li=axis, ri=axis, op=op)
 *             return
 */
      __pyx_t_12 = __Pyx_GetItemInt_List(__pyx_v_adv_slices, __pyx_v_axis, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3169, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3169, __pyx_L1_error)

      /* "cupy/core/core.pyx":3170
 *             axis = arr_slices_mask.index(True)
 *             _scatter_op_single(a, adv_slices[axis], value,
 *                                li=axis, ri=axis, op=op)             # <<<<<<<<<<<<<<
 *             return
 * 
 */
      __pyx_t_14.__pyx_n = 3;
      __pyx_t_14.li = __pyx_v_axis;
      __pyx_t_14.ri = __pyx_v_axis;
      __pyx_t_14.op = __pyx_v_op;
      __pyx_t_10 = __pyx_f_4cupy_4core_4core__scatter_op_single(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_12), __pyx_v_value, 0, &__pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3169, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

      /* "cupy/core/core.pyx":3171
 *             _scatter_op_single(a, adv_slices[axis], value,
 *                                li=axis, ri=axis, op=op)
 *             return             # <<<<<<<<<<<<<<
 * 
 *         # scatter_op with multiple integer arrays
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;

      /* "cupy/core/core.pyx":3167
 * 
 *         arr_slices_mask = [not isinstance(s, slice) for s in adv_slices]
 *         if sum(arr_slices_mask) == 1:             # <<<<<<<<<<<<<<
 *             axis = arr_slices_mask.index(True)
 *             _scatter_op_single(a, adv_slices[axis], value,
 */
    }

    /* "cupy/core/core.pyx":3175
 *         # scatter_op with multiple integer arrays
 *         a_interm, reduced_idx, li, ri =\
 *             _prepare_multiple_array_indexing(a, adv_slices)             # <<<<<<<<<<<<<<
 *         _scatter_op_single(a_interm, reduced_idx, value, li=li, ri=ri, op=op)
 *         return
 */
    __pyx_t_10 = __pyx_f_4cupy_4core_4core__prepare_multiple_array_indexing(__pyx_v_a, __pyx_v_adv_slices, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3175, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if ((likely(PyTuple_CheckExact(__pyx_t_10))) || (PyList_CheckExact(__pyx_t_10))) {
      PyObject* sequence = __pyx_t_10;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 4)) {
        if (size > 4) __Pyx_RaiseTooManyValuesError(4);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 3174, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_12 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
        __pyx_t_11 = PyTuple_GET_ITEM(sequence, 3); 
      } else {
        __pyx_t_12 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
        __pyx_t_11 = PyList_GET_ITEM(sequence, 3); 
      }
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_11);
      #else
      {
        Py_ssize_t i;
        PyObject** temps[4] = {&__pyx_t_12,&__pyx_t_7,&__pyx_t_4,&__pyx_t_11};
        for (i=0; i < 4; i++) {
          PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 3174, __pyx_L1_error)
          __Pyx_GOTREF(item);
          *(temps[i]) = item;
        }
      }
      #endif
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else {
      Py_ssize_t index = -1;
      PyObject** temps[4] = {&__pyx_t_12,&__pyx_t_7,&__pyx_t_4,&__pyx_t_11};
      __pyx_t_3 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_15 = Py_TYPE(__pyx_t_3)->tp_iternext;
      for (index=0; index < 4; index++) {
        PyObject* item = __pyx_t_15(__pyx_t_3); if (unlikely(!item)) goto __pyx_L48_unpacking_failed;
        __Pyx_GOTREF(item);
        *(temps[index]) = item;
      }
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_3), 4) < 0) __PYX_ERR(0, 3174, __pyx_L1_error)
      __pyx_t_15 = NULL;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L49_unpacking_done;
      __pyx_L48_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_15 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 3174, __pyx_L1_error)
      __pyx_L49_unpacking_done:;
    }

    /* "cupy/core/core.pyx":3174
 * 
 *         # scatter_op with multiple integer arrays
 *         a_interm, reduced_idx, li, ri =\             # <<<<<<<<<<<<<<
 *             _prepare_multiple_array_indexing(a, adv_slices)
 *         _scatter_op_single(a_interm, reduced_idx, value, li=li, ri=ri, op=op)
 */
    if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3174, __pyx_L1_error)
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3174, __pyx_L1_error)
    __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3174, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_11); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3174, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_v_a_interm = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_v_reduced_idx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_v_li = __pyx_t_8;
    __pyx_v_ri = __pyx_t_5;

    /* "cupy/core/core.pyx":3176
 *         a_interm, reduced_idx, li, ri =\
 *             _prepare_multiple_array_indexing(a, adv_slices)
 *         _scatter_op_single(a_interm, reduced_idx, value, li=li, ri=ri, op=op)             # <<<<<<<<<<<<<<
 *         return
 * 
 */
    __pyx_t_14.__pyx_n = 3;
    __pyx_t_14.li = __pyx_v_li;
    __pyx_t_14.ri = __pyx_v_ri;
    __pyx_t_14.op = __pyx_v_op;
    __pyx_t_10 = __pyx_f_4cupy_4core_4core__scatter_op_single(__pyx_v_a_interm, __pyx_v_reduced_idx, __pyx_v_value, 0, &__pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3176, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":3177
 *             _prepare_multiple_array_indexing(a, adv_slices)
 *         _scatter_op_single(a_interm, reduced_idx, value, li=li, ri=ri, op=op)
 *         return             # <<<<<<<<<<<<<<
 * 
 *     if op == 'update':
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3133
 *         return
 * 
 *     if advanced:             # <<<<<<<<<<<<<<
 *         # split slices that can be handled by basic-indexing
 *         basic_slices = []
 */
  }

  /* "cupy/core/core.pyx":3179
 *         return
 * 
 *     if op == 'update':             # <<<<<<<<<<<<<<
 *         v = a[tuple(slices)]
 *         if isinstance(value, ndarray):
 */
  __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_n_s_update, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3179, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3180
 * 
 *     if op == 'update':
 *         v = a[tuple(slices)]             # <<<<<<<<<<<<<<
 *         if isinstance(value, ndarray):
 *             y, x = broadcast(v, value).values
 */
    __pyx_t_10 = PySequence_Tuple(__pyx_v_slices); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3180, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3180, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3180, __pyx_L1_error)
    __pyx_v_v = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_11);
    __pyx_t_11 = 0;

    /* "cupy/core/core.pyx":3181
 *     if op == 'update':
 *         v = a[tuple(slices)]
 *         if isinstance(value, ndarray):             # <<<<<<<<<<<<<<
 *             y, x = broadcast(v, value).values
 *             if (internal.vector_equal(y._shape, x._shape) and
 */
    __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_value, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_9 = (__pyx_t_1 != 0);
    if (__pyx_t_9) {

      /* "cupy/core/core.pyx":3182
 *         v = a[tuple(slices)]
 *         if isinstance(value, ndarray):
 *             y, x = broadcast(v, value).values             # <<<<<<<<<<<<<<
 *             if (internal.vector_equal(y._shape, x._shape) and
 *                     internal.vector_equal(y._strides, x._strides)):
 */
      __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3182, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_INCREF(((PyObject *)__pyx_v_v));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_v));
      PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_v_v));
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_v_value);
      __pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_broadcast), __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3182, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = ((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_t_10)->values;
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (likely(__pyx_t_11 != Py_None)) {
        PyObject* sequence = __pyx_t_11;
        #if !CYTHON_COMPILING_IN_PYPY
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 3182, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_4);
        #else
        __pyx_t_10 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3182, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3182, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      } else {
        __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 3182, __pyx_L1_error)
      }
      if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3182, __pyx_L1_error)
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3182, __pyx_L1_error)
      __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10);
      __pyx_t_10 = 0;
      __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":3183
 *         if isinstance(value, ndarray):
 *             y, x = broadcast(v, value).values
 *             if (internal.vector_equal(y._shape, x._shape) and             # <<<<<<<<<<<<<<
 *                     internal.vector_equal(y._strides, x._strides)):
 *                 if y.data.ptr == x.data.ptr:
 */
      __pyx_t_1 = (__pyx_f_4cupy_4core_8internal_vector_equal(__pyx_v_y->_shape, __pyx_v_x->_shape, 0) != 0);
      if (__pyx_t_1) {
      } else {
        __pyx_t_9 = __pyx_t_1;
        goto __pyx_L53_bool_binop_done;
      }

      /* "cupy/core/core.pyx":3184
 *             y, x = broadcast(v, value).values
 *             if (internal.vector_equal(y._shape, x._shape) and
 *                     internal.vector_equal(y._strides, x._strides)):             # <<<<<<<<<<<<<<
 *                 if y.data.ptr == x.data.ptr:
 *                     return  # Skip since x and y are the same array
 */
      __pyx_t_1 = (__pyx_f_4cupy_4core_8internal_vector_equal(__pyx_v_y->_strides, __pyx_v_x->_strides, 0) != 0);
      __pyx_t_9 = __pyx_t_1;
      __pyx_L53_bool_binop_done:;

      /* "cupy/core/core.pyx":3183
 *         if isinstance(value, ndarray):
 *             y, x = broadcast(v, value).values
 *             if (internal.vector_equal(y._shape, x._shape) and             # <<<<<<<<<<<<<<
 *                     internal.vector_equal(y._strides, x._strides)):
 *                 if y.data.ptr == x.data.ptr:
 */
      if (__pyx_t_9) {

        /* "cupy/core/core.pyx":3185
 *             if (internal.vector_equal(y._shape, x._shape) and
 *                     internal.vector_equal(y._strides, x._strides)):
 *                 if y.data.ptr == x.data.ptr:             # <<<<<<<<<<<<<<
 *                     return  # Skip since x and y are the same array
 *                 elif y._c_contiguous and x.dtype == y.dtype:
 */
        __pyx_t_9 = ((__pyx_v_y->data->ptr == __pyx_v_x->data->ptr) != 0);
        if (__pyx_t_9) {

          /* "cupy/core/core.pyx":3186
 *                     internal.vector_equal(y._strides, x._strides)):
 *                 if y.data.ptr == x.data.ptr:
 *                     return  # Skip since x and y are the same array             # <<<<<<<<<<<<<<
 *                 elif y._c_contiguous and x.dtype == y.dtype:
 *                     y.data.copy_from_device_async(x.data, x.nbytes,
 */
          __Pyx_XDECREF(__pyx_r);
          __pyx_r = Py_None; __Pyx_INCREF(Py_None);
          goto __pyx_L0;

          /* "cupy/core/core.pyx":3185
 *             if (internal.vector_equal(y._shape, x._shape) and
 *                     internal.vector_equal(y._strides, x._strides)):
 *                 if y.data.ptr == x.data.ptr:             # <<<<<<<<<<<<<<
 *                     return  # Skip since x and y are the same array
 *                 elif y._c_contiguous and x.dtype == y.dtype:
 */
        }

        /* "cupy/core/core.pyx":3187
 *                 if y.data.ptr == x.data.ptr:
 *                     return  # Skip since x and y are the same array
 *                 elif y._c_contiguous and x.dtype == y.dtype:             # <<<<<<<<<<<<<<
 *                     y.data.copy_from_device_async(x.data, x.nbytes,
 *                                                   cuda.Stream.null)
 */
        __pyx_t_1 = (__pyx_v_y->_c_contiguous != 0);
        if (__pyx_t_1) {
        } else {
          __pyx_t_9 = __pyx_t_1;
          goto __pyx_L56_bool_binop_done;
        }
        __pyx_t_11 = PyObject_RichCompare(__pyx_v_x->dtype, __pyx_v_y->dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3187, __pyx_L1_error)
        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3187, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_9 = __pyx_t_1;
        __pyx_L56_bool_binop_done:;
        if (__pyx_t_9) {

          /* "cupy/core/core.pyx":3188
 *                     return  # Skip since x and y are the same array
 *                 elif y._c_contiguous and x.dtype == y.dtype:
 *                     y.data.copy_from_device_async(x.data, x.nbytes,             # <<<<<<<<<<<<<<
 *                                                   cuda.Stream.null)
 *                     return
 */
          __pyx_t_11 = ((PyObject *)__pyx_v_x->data);
          __Pyx_INCREF(__pyx_t_11);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3188, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_16 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_16 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3188, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "cupy/core/core.pyx":3189
 *                 elif y._c_contiguous and x.dtype == y.dtype:
 *                     y.data.copy_from_device_async(x.data, x.nbytes,
 *                                                   cuda.Stream.null)             # <<<<<<<<<<<<<<
 *                     return
 *             elementwise_copy(x, y)
 */
          __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3189, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_Stream); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3189, __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_null); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3189, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

          /* "cupy/core/core.pyx":3188
 *                     return  # Skip since x and y are the same array
 *                 elif y._c_contiguous and x.dtype == y.dtype:
 *                     y.data.copy_from_device_async(x.data, x.nbytes,             # <<<<<<<<<<<<<<
 *                                                   cuda.Stream.null)
 *                     return
 */
          __pyx_t_17.__pyx_n = 1;
          __pyx_t_17.stream = __pyx_t_4;
          __pyx_t_10 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_y->data->__pyx_vtab)->copy_from_device_async(__pyx_v_y->data, ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_11), __pyx_t_16, 0, &__pyx_t_17); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3188, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

          /* "cupy/core/core.pyx":3190
 *                     y.data.copy_from_device_async(x.data, x.nbytes,
 *                                                   cuda.Stream.null)
 *                     return             # <<<<<<<<<<<<<<
 *             elementwise_copy(x, y)
 *         else:
 */
          __Pyx_XDECREF(__pyx_r);
          __pyx_r = Py_None; __Pyx_INCREF(Py_None);
          goto __pyx_L0;

          /* "cupy/core/core.pyx":3187
 *                 if y.data.ptr == x.data.ptr:
 *                     return  # Skip since x and y are the same array
 *                 elif y._c_contiguous and x.dtype == y.dtype:             # <<<<<<<<<<<<<<
 *                     y.data.copy_from_device_async(x.data, x.nbytes,
 *                                                   cuda.Stream.null)
 */
        }

        /* "cupy/core/core.pyx":3183
 *         if isinstance(value, ndarray):
 *             y, x = broadcast(v, value).values
 *             if (internal.vector_equal(y._shape, x._shape) and             # <<<<<<<<<<<<<<
 *                     internal.vector_equal(y._strides, x._strides)):
 *                 if y.data.ptr == x.data.ptr:
 */
      }

      /* "cupy/core/core.pyx":3191
 *                                                   cuda.Stream.null)
 *                     return
 *             elementwise_copy(x, y)             # <<<<<<<<<<<<<<
 *         else:
 *             v.fill(value)
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3191, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_11 = NULL;
      __pyx_t_18 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_18 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y)};
        __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_18, 2+__pyx_t_18); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3191, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_10);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y)};
        __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_18, 2+__pyx_t_18); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3191, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_10);
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(2+__pyx_t_18); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3191, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (__pyx_t_11) {
          __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_11); __pyx_t_11 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_x));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_x));
        PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_18, ((PyObject *)__pyx_v_x));
        __Pyx_INCREF(((PyObject *)__pyx_v_y));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_y));
        PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_18, ((PyObject *)__pyx_v_y));
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3191, __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_10); __pyx_t_10 = 0;

      /* "cupy/core/core.pyx":3181
 *     if op == 'update':
 *         v = a[tuple(slices)]
 *         if isinstance(value, ndarray):             # <<<<<<<<<<<<<<
 *             y, x = broadcast(v, value).values
 *             if (internal.vector_equal(y._shape, x._shape) and
 */
      goto __pyx_L51;
    }

    /* "cupy/core/core.pyx":3193
 *             elementwise_copy(x, y)
 *         else:
 *             v.fill(value)             # <<<<<<<<<<<<<<
 *     elif op == 'add':
 *         v = a[tuple(slices)]
 */
    /*else*/ {
      __pyx_t_10 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_v->__pyx_vtab)->fill(__pyx_v_v, __pyx_v_value, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3193, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __pyx_L51:;

    /* "cupy/core/core.pyx":3179
 *         return
 * 
 *     if op == 'update':             # <<<<<<<<<<<<<<
 *         v = a[tuple(slices)]
 *         if isinstance(value, ndarray):
 */
    goto __pyx_L50;
  }

  /* "cupy/core/core.pyx":3194
 *         else:
 *             v.fill(value)
 *     elif op == 'add':             # <<<<<<<<<<<<<<
 *         v = a[tuple(slices)]
 *         if not isinstance(value, ndarray):
 */
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_n_s_add, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3194, __pyx_L1_error)
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3195
 *             v.fill(value)
 *     elif op == 'add':
 *         v = a[tuple(slices)]             # <<<<<<<<<<<<<<
 *         if not isinstance(value, ndarray):
 *             value = ndarray(value)
 */
    __pyx_t_10 = PySequence_Tuple(__pyx_v_slices); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3195, __pyx_L1_error)
    __pyx_v_v = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3196
 *     elif op == 'add':
 *         v = a[tuple(slices)]
 *         if not isinstance(value, ndarray):             # <<<<<<<<<<<<<<
 *             value = ndarray(value)
 *         y, x = broadcast(v, value).values
 */
    __pyx_t_9 = __Pyx_TypeCheck(__pyx_v_value, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_1 = ((!(__pyx_t_9 != 0)) != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":3197
 *         v = a[tuple(slices)]
 *         if not isinstance(value, ndarray):
 *             value = ndarray(value)             # <<<<<<<<<<<<<<
 *         y, x = broadcast(v, value).values
 *         elementwise_copy(x + y, y)
 */
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3197, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_value);
      __pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_4, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3197, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_10);
      __pyx_t_10 = 0;

      /* "cupy/core/core.pyx":3196
 *     elif op == 'add':
 *         v = a[tuple(slices)]
 *         if not isinstance(value, ndarray):             # <<<<<<<<<<<<<<
 *             value = ndarray(value)
 *         y, x = broadcast(v, value).values
 */
    }

    /* "cupy/core/core.pyx":3198
 *         if not isinstance(value, ndarray):
 *             value = ndarray(value)
 *         y, x = broadcast(v, value).values             # <<<<<<<<<<<<<<
 *         elementwise_copy(x + y, y)
 *     else:
 */
    __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3198, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_INCREF(((PyObject *)__pyx_v_v));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_v));
    PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_v_v));
    __Pyx_INCREF(__pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_value);
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_broadcast), __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3198, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = ((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_t_4)->values;
    __Pyx_INCREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (likely(__pyx_t_10 != Py_None)) {
      PyObject* sequence = __pyx_t_10;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 3198, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3198, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3198, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 3198, __pyx_L1_error)
    }
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3198, __pyx_L1_error)
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3198, __pyx_L1_error)
    __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":3199
 *             value = ndarray(value)
 *         y, x = broadcast(v, value).values
 *         elementwise_copy(x + y, y)             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError('this op is not supported')
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3199, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = PyNumber_Add(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3199, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_11 = NULL;
    __pyx_t_18 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
        __pyx_t_18 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_4, ((PyObject *)__pyx_v_y)};
      __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_18, 2+__pyx_t_18); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3199, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_4, ((PyObject *)__pyx_v_y)};
      __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_18, 2+__pyx_t_18); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3199, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(2+__pyx_t_18); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3199, __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_18, __pyx_t_4);
      __Pyx_INCREF(((PyObject *)__pyx_v_y));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_y));
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_18, ((PyObject *)__pyx_v_y));
      __pyx_t_4 = 0;
      __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":3194
 *         else:
 *             v.fill(value)
 *     elif op == 'add':             # <<<<<<<<<<<<<<
 *         v = a[tuple(slices)]
 *         if not isinstance(value, ndarray):
 */
    goto __pyx_L50;
  }

  /* "cupy/core/core.pyx":3201
 *         elementwise_copy(x + y, y)
 *     else:
 *         raise ValueError('this op is not supported')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__162, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3201, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_Raise(__pyx_t_10, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __PYX_ERR(0, 3201, __pyx_L1_error)
  }
  __pyx_L50:;

  /* "cupy/core/core.pyx":3059
 * 
 * 
 * cpdef _scatter_op(ndarray a, slices, value, op):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, ndim, n_newaxes, n_ellipses, ellipsis, axis
 *     cdef Py_ssize_t n_not_slice_none, mask_i
 */

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core._scatter_op", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_v);
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_y);
  __Pyx_XDECREF((PyObject *)__pyx_v_a_interm);
  __Pyx_XDECREF((PyObject *)__pyx_v_reduced_idx);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_noneslices);
  __Pyx_XDECREF(__pyx_v_basic_slices);
  __Pyx_XDECREF(__pyx_v_adv_slices);
  __Pyx_XDECREF((PyObject *)__pyx_v_scalar_array);
  __Pyx_XDECREF(__pyx_v_arr_slices_mask);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_slices);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_89_scatter_op(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_88_scatter_op[] = "_scatter_op(ndarray a, slices, value, op)";
static PyObject *__pyx_pw_4cupy_4core_4core_89_scatter_op(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_slices = 0;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_scatter_op (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_slices,&__pyx_n_s_value,&__pyx_n_s_op,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_slices)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op", 1, 4, 4, 1); __PYX_ERR(0, 3059, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op", 1, 4, 4, 2); __PYX_ERR(0, 3059, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_op)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op", 1, 4, 4, 3); __PYX_ERR(0, 3059, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_scatter_op") < 0)) __PYX_ERR(0, 3059, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_slices = values[1];
    __pyx_v_value = values[2];
    __pyx_v_op = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_scatter_op", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3059, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._scatter_op", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3059, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_88_scatter_op(__pyx_self, __pyx_v_a, __pyx_v_slices, __pyx_v_value, __pyx_v_op);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_88_scatter_op(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slices, PyObject *__pyx_v_value, PyObject *__pyx_v_op) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_scatter_op", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__scatter_op(__pyx_v_a, __pyx_v_slices, __pyx_v_value, __pyx_v_op, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3059, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._scatter_op", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3204
 * 
 * 
 * cpdef ndarray _diagonal(ndarray a, Py_ssize_t offset=0, Py_ssize_t axis1=0,             # <<<<<<<<<<<<<<
 *                         Py_ssize_t axis2=1):
 *     cdef Py_ssize_t ndim = a.ndim
 */

static PyObject *__pyx_pw_4cupy_4core_4core_91_diagonal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__diagonal(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__diagonal *__pyx_optional_args) {
  Py_ssize_t __pyx_v_offset = ((Py_ssize_t)0);
  Py_ssize_t __pyx_v_axis1 = ((Py_ssize_t)0);
  Py_ssize_t __pyx_v_axis2 = ((Py_ssize_t)1);
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_min_axis;
  Py_ssize_t __pyx_v_max_axis;
  PyObject *__pyx_v_tr = NULL;
  PyObject *__pyx_v_diag_size = NULL;
  PyObject *__pyx_v_ret_shape = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  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;
  Py_ssize_t __pyx_t_12;
  long __pyx_t_13;
  std::vector<Py_ssize_t>  __pyx_t_14;
  std::vector<Py_ssize_t>  __pyx_t_15;
  __Pyx_RefNannySetupContext("_diagonal", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_offset = __pyx_optional_args->offset;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_axis1 = __pyx_optional_args->axis1;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_axis2 = __pyx_optional_args->axis2;
        }
      }
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_a);

  /* "cupy/core/core.pyx":3206
 * cpdef ndarray _diagonal(ndarray a, Py_ssize_t offset=0, Py_ssize_t axis1=0,
 *                         Py_ssize_t axis2=1):
 *     cdef Py_ssize_t ndim = a.ndim             # <<<<<<<<<<<<<<
 *     if (axis1 >= ndim or abs(axis2) >= ndim or
 *             axis1 < - ndim or axis2 < - ndim):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3206, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_2;

  /* "cupy/core/core.pyx":3207
 *                         Py_ssize_t axis2=1):
 *     cdef Py_ssize_t ndim = a.ndim
 *     if (axis1 >= ndim or abs(axis2) >= ndim or             # <<<<<<<<<<<<<<
 *             axis1 < - ndim or axis2 < - ndim):
 *         raise ValueError('axis1(={0}) and axis2(={1}) must be within range '
 */
  __pyx_t_4 = ((__pyx_v_axis1 >= __pyx_v_ndim) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_axis2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyNumber_Absolute(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyObject_RichCompare(__pyx_t_5, __pyx_t_1, Py_GE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3207, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 3207, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }

  /* "cupy/core/core.pyx":3208
 *     cdef Py_ssize_t ndim = a.ndim
 *     if (axis1 >= ndim or abs(axis2) >= ndim or
 *             axis1 < - ndim or axis2 < - ndim):             # <<<<<<<<<<<<<<
 *         raise ValueError('axis1(={0}) and axis2(={1}) must be within range '
 *                          '(ndim={2})'.format(axis1, axis2, ndim))
 */
  __pyx_t_4 = ((__pyx_v_axis1 < (-__pyx_v_ndim)) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_axis2 < (-__pyx_v_ndim)) != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;

  /* "cupy/core/core.pyx":3207
 *                         Py_ssize_t axis2=1):
 *     cdef Py_ssize_t ndim = a.ndim
 *     if (axis1 >= ndim or abs(axis2) >= ndim or             # <<<<<<<<<<<<<<
 *             axis1 < - ndim or axis2 < - ndim):
 *         raise ValueError('axis1(={0}) and axis2(={1}) must be within range '
 */
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":3210
 *             axis1 < - ndim or axis2 < - ndim):
 *         raise ValueError('axis1(={0}) and axis2(={1}) must be within range '
 *                          '(ndim={2})'.format(axis1, axis2, ndim))             # <<<<<<<<<<<<<<
 * 
 *     axis1 %= ndim
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_axis1_0_and_axis2_1_must_be_with, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3210, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_axis1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3210, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_axis2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3210, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3210, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_5, __pyx_t_7, __pyx_t_8};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3210, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_5, __pyx_t_7, __pyx_t_8};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3210, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3210, __pyx_L1_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_7);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_8);
      __pyx_t_5 = 0;
      __pyx_t_7 = 0;
      __pyx_t_8 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3210, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3209
 *     if (axis1 >= ndim or abs(axis2) >= ndim or
 *             axis1 < - ndim or axis2 < - ndim):
 *         raise ValueError('axis1(={0}) and axis2(={1}) must be within range '             # <<<<<<<<<<<<<<
 *                          '(ndim={2})'.format(axis1, axis2, ndim))
 * 
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3209, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3209, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __PYX_ERR(0, 3209, __pyx_L1_error)

    /* "cupy/core/core.pyx":3207
 *                         Py_ssize_t axis2=1):
 *     cdef Py_ssize_t ndim = a.ndim
 *     if (axis1 >= ndim or abs(axis2) >= ndim or             # <<<<<<<<<<<<<<
 *             axis1 < - ndim or axis2 < - ndim):
 *         raise ValueError('axis1(={0}) and axis2(={1}) must be within range '
 */
  }

  /* "cupy/core/core.pyx":3212
 *                          '(ndim={2})'.format(axis1, axis2, ndim))
 * 
 *     axis1 %= ndim             # <<<<<<<<<<<<<<
 *     axis2 %= ndim
 *     if axis1 < axis2:
 */
  if (unlikely(__pyx_v_ndim == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 3212, __pyx_L1_error)
  }
  __pyx_v_axis1 = __Pyx_mod_Py_ssize_t(__pyx_v_axis1, __pyx_v_ndim);

  /* "cupy/core/core.pyx":3213
 * 
 *     axis1 %= ndim
 *     axis2 %= ndim             # <<<<<<<<<<<<<<
 *     if axis1 < axis2:
 *         min_axis, max_axis = axis1, axis2
 */
  if (unlikely(__pyx_v_ndim == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 3213, __pyx_L1_error)
  }
  __pyx_v_axis2 = __Pyx_mod_Py_ssize_t(__pyx_v_axis2, __pyx_v_ndim);

  /* "cupy/core/core.pyx":3214
 *     axis1 %= ndim
 *     axis2 %= ndim
 *     if axis1 < axis2:             # <<<<<<<<<<<<<<
 *         min_axis, max_axis = axis1, axis2
 *     else:
 */
  __pyx_t_3 = ((__pyx_v_axis1 < __pyx_v_axis2) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":3215
 *     axis2 %= ndim
 *     if axis1 < axis2:
 *         min_axis, max_axis = axis1, axis2             # <<<<<<<<<<<<<<
 *     else:
 *         min_axis, max_axis = axis2, axis1
 */
    __pyx_t_2 = __pyx_v_axis1;
    __pyx_t_12 = __pyx_v_axis2;
    __pyx_v_min_axis = __pyx_t_2;
    __pyx_v_max_axis = __pyx_t_12;

    /* "cupy/core/core.pyx":3214
 *     axis1 %= ndim
 *     axis2 %= ndim
 *     if axis1 < axis2:             # <<<<<<<<<<<<<<
 *         min_axis, max_axis = axis1, axis2
 *     else:
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":3217
 *         min_axis, max_axis = axis1, axis2
 *     else:
 *         min_axis, max_axis = axis2, axis1             # <<<<<<<<<<<<<<
 * 
 *     tr = list(range(ndim))
 */
  /*else*/ {
    __pyx_t_12 = __pyx_v_axis2;
    __pyx_t_2 = __pyx_v_axis1;
    __pyx_v_min_axis = __pyx_t_12;
    __pyx_v_max_axis = __pyx_t_2;
  }
  __pyx_L8:;

  /* "cupy/core/core.pyx":3219
 *         min_axis, max_axis = axis2, axis1
 * 
 *     tr = list(range(ndim))             # <<<<<<<<<<<<<<
 *     del tr[max_axis]
 *     del tr[min_axis]
 */
  __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PySequence_List(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_tr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3220
 * 
 *     tr = list(range(ndim))
 *     del tr[max_axis]             # <<<<<<<<<<<<<<
 *     del tr[min_axis]
 *     if offset >= 0:
 */
  if (unlikely(__Pyx_DelItemInt(__pyx_v_tr, __pyx_v_max_axis, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(0, 3220, __pyx_L1_error)

  /* "cupy/core/core.pyx":3221
 *     tr = list(range(ndim))
 *     del tr[max_axis]
 *     del tr[min_axis]             # <<<<<<<<<<<<<<
 *     if offset >= 0:
 *         a = a.transpose(tr + [axis1, axis2])
 */
  if (unlikely(__Pyx_DelItemInt(__pyx_v_tr, __pyx_v_min_axis, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(0, 3221, __pyx_L1_error)

  /* "cupy/core/core.pyx":3222
 *     del tr[max_axis]
 *     del tr[min_axis]
 *     if offset >= 0:             # <<<<<<<<<<<<<<
 *         a = a.transpose(tr + [axis1, axis2])
 *     else:
 */
  __pyx_t_3 = ((__pyx_v_offset >= 0) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":3223
 *     del tr[min_axis]
 *     if offset >= 0:
 *         a = a.transpose(tr + [axis1, axis2])             # <<<<<<<<<<<<<<
 *     else:
 *         a = a.transpose(tr + [axis2, axis1])
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_transpose_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3223, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_11 = PyInt_FromSsize_t(__pyx_v_axis1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3223, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_axis2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3223, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3223, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_11);
    PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_8);
    PyList_SET_ITEM(__pyx_t_7, 1, __pyx_t_8);
    __pyx_t_11 = 0;
    __pyx_t_8 = 0;
    __pyx_t_8 = PyNumber_Add(__pyx_v_tr, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3223, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3223, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_8};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3223, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_8};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3223, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3223, __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_8);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_8);
        __pyx_t_8 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3223, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3223, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3222
 *     del tr[max_axis]
 *     del tr[min_axis]
 *     if offset >= 0:             # <<<<<<<<<<<<<<
 *         a = a.transpose(tr + [axis1, axis2])
 *     else:
 */
    goto __pyx_L9;
  }

  /* "cupy/core/core.pyx":3225
 *         a = a.transpose(tr + [axis1, axis2])
 *     else:
 *         a = a.transpose(tr + [axis2, axis1])             # <<<<<<<<<<<<<<
 *         offset = -offset
 * 
 */
  /*else*/ {
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_transpose_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3225, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_11 = PyInt_FromSsize_t(__pyx_v_axis2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3225, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_axis1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3225, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3225, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_11);
    PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_8);
    PyList_SET_ITEM(__pyx_t_7, 1, __pyx_t_8);
    __pyx_t_11 = 0;
    __pyx_t_8 = 0;
    __pyx_t_8 = PyNumber_Add(__pyx_v_tr, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3225, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3225, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_8};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3225, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_8};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3225, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3225, __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_8);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_8);
        __pyx_t_8 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3225, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3225, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3226
 *     else:
 *         a = a.transpose(tr + [axis2, axis1])
 *         offset = -offset             # <<<<<<<<<<<<<<
 * 
 *     diag_size = max(0, min(a.shape[-2], a.shape[-1] - offset))
 */
    __pyx_v_offset = (-__pyx_v_offset);
  }
  __pyx_L9:;

  /* "cupy/core/core.pyx":3228
 *         offset = -offset
 * 
 *     diag_size = max(0, min(a.shape[-2], a.shape[-1] - offset))             # <<<<<<<<<<<<<<
 *     ret_shape = a.shape[:-2] + (diag_size,)
 *     if diag_size == 0:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_1, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_offset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_11 = PyNumber_Subtract(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_1, -2L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_8 = PyObject_RichCompare(__pyx_t_11, __pyx_t_6, Py_LT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3228, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 3228, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__pyx_t_3) {
    __Pyx_INCREF(__pyx_t_11);
    __pyx_t_1 = __pyx_t_11;
  } else {
    __Pyx_INCREF(__pyx_t_6);
    __pyx_t_1 = __pyx_t_6;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_11 = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_13 = 0;
  __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_t_13); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = PyObject_RichCompare(__pyx_t_11, __pyx_t_6, Py_GT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3228, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 3228, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__pyx_t_3) {
    __Pyx_INCREF(__pyx_t_11);
    __pyx_t_1 = __pyx_t_11;
  } else {
    __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_t_13); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3228, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_1 = __pyx_t_8;
    __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __pyx_t_1;
  __Pyx_INCREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_diag_size = __pyx_t_11;
  __pyx_t_11 = 0;

  /* "cupy/core/core.pyx":3229
 * 
 *     diag_size = max(0, min(a.shape[-2], a.shape[-1] - offset))
 *     ret_shape = a.shape[:-2] + (diag_size,)             # <<<<<<<<<<<<<<
 *     if diag_size == 0:
 *         return ndarray(ret_shape, dtype=a.dtype)
 */
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3229, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_11, 0, -2L, NULL, NULL, &__pyx_slice__163, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3229, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3229, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_INCREF(__pyx_v_diag_size);
  __Pyx_GIVEREF(__pyx_v_diag_size);
  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_diag_size);
  __pyx_t_8 = PyNumber_Add(__pyx_t_1, __pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3229, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_v_ret_shape = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3230
 *     diag_size = max(0, min(a.shape[-2], a.shape[-1] - offset))
 *     ret_shape = a.shape[:-2] + (diag_size,)
 *     if diag_size == 0:             # <<<<<<<<<<<<<<
 *         return ndarray(ret_shape, dtype=a.dtype)
 * 
 */
  __pyx_t_8 = __Pyx_PyInt_EqObjC(__pyx_v_diag_size, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 3230, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":3231
 *     ret_shape = a.shape[:-2] + (diag_size,)
 *     if diag_size == 0:
 *         return ndarray(ret_shape, dtype=a.dtype)             # <<<<<<<<<<<<<<
 * 
 *     a = a[..., :diag_size, offset:offset + diag_size]
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3231, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v_ret_shape);
    __Pyx_GIVEREF(__pyx_v_ret_shape);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_ret_shape);
    __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3231, __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, 3231, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_8, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3231, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3230
 *     diag_size = max(0, min(a.shape[-2], a.shape[-1] - offset))
 *     ret_shape = a.shape[:-2] + (diag_size,)
 *     if diag_size == 0:             # <<<<<<<<<<<<<<
 *         return ndarray(ret_shape, dtype=a.dtype)
 * 
 */
  }

  /* "cupy/core/core.pyx":3233
 *         return ndarray(ret_shape, dtype=a.dtype)
 * 
 *     a = a[..., :diag_size, offset:offset + diag_size]             # <<<<<<<<<<<<<<
 * 
 *     ret = a.view()
 */
  __pyx_t_1 = PySlice_New(Py_None, __pyx_v_diag_size, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_11 = PyInt_FromSsize_t(__pyx_v_offset); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_offset); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = PyNumber_Add(__pyx_t_8, __pyx_v_diag_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PySlice_New(__pyx_t_11, __pyx_t_6, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(Py_Ellipsis);
  __Pyx_GIVEREF(Py_Ellipsis);
  PyTuple_SET_ITEM(__pyx_t_6, 0, Py_Ellipsis);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_8);
  __pyx_t_1 = 0;
  __pyx_t_8 = 0;
  __pyx_t_8 = PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3233, __pyx_L1_error)
  __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8));
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3235
 *     a = a[..., :diag_size, offset:offset + diag_size]
 * 
 *     ret = a.view()             # <<<<<<<<<<<<<<
 *     ret._set_shape_and_strides(
 *         a.shape[:-2] + (diag_size,),
 */
  __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, 3235, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3237
 *     ret = a.view()
 *     ret._set_shape_and_strides(
 *         a.shape[:-2] + (diag_size,),             # <<<<<<<<<<<<<<
 *         a.strides[:-2] + (a.strides[-1] + a.strides[-2],))
 *     return ret
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_t_8, 0, -2L, NULL, NULL, &__pyx_slice__164, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_v_diag_size);
  __Pyx_GIVEREF(__pyx_v_diag_size);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_diag_size);
  __pyx_t_1 = PyNumber_Add(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_14 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3237, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3238
 *     ret._set_shape_and_strides(
 *         a.shape[:-2] + (diag_size,),
 *         a.strides[:-2] + (a.strides[-1] + a.strides[-2],))             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyObject_GetSlice(__pyx_t_1, 0, -2L, NULL, NULL, &__pyx_slice__165, 0, 1, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_1, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_11 = __Pyx_GetItemInt(__pyx_t_1, -2L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Add(__pyx_t_6, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Add(__pyx_t_8, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_15 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3238, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3236
 * 
 *     ret = a.view()
 *     ret._set_shape_and_strides(             # <<<<<<<<<<<<<<
 *         a.shape[:-2] + (diag_size,),
 *         a.strides[:-2] + (a.strides[-1] + a.strides[-2],))
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ret->__pyx_vtab)->_set_shape_and_strides(__pyx_v_ret, __pyx_t_14, __pyx_t_15, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3236, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3239
 *         a.shape[:-2] + (diag_size,),
 *         a.strides[:-2] + (a.strides[-1] + a.strides[-2],))
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3204
 * 
 * 
 * cpdef ndarray _diagonal(ndarray a, Py_ssize_t offset=0, Py_ssize_t axis1=0,             # <<<<<<<<<<<<<<
 *                         Py_ssize_t axis2=1):
 *     cdef Py_ssize_t ndim = a.ndim
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_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._diagonal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_tr);
  __Pyx_XDECREF(__pyx_v_diag_size);
  __Pyx_XDECREF(__pyx_v_ret_shape);
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_91_diagonal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_90_diagonal[] = "_diagonal(ndarray a, Py_ssize_t offset=0, Py_ssize_t axis1=0, Py_ssize_t axis2=1) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_91_diagonal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  Py_ssize_t __pyx_v_offset;
  Py_ssize_t __pyx_v_axis1;
  Py_ssize_t __pyx_v_axis2;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_diagonal (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_offset,&__pyx_n_s_axis1,&__pyx_n_s_axis2,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__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 = PyDict_GetItem(__pyx_kwds, __pyx_n_s_offset);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis1);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis2);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_diagonal") < 0)) __PYX_ERR(0, 3204, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    if (values[1]) {
      __pyx_v_offset = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_offset == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3204, __pyx_L3_error)
    } else {
      __pyx_v_offset = ((Py_ssize_t)0);
    }
    if (values[2]) {
      __pyx_v_axis1 = __Pyx_PyIndex_AsSsize_t(values[2]); if (unlikely((__pyx_v_axis1 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3204, __pyx_L3_error)
    } else {
      __pyx_v_axis1 = ((Py_ssize_t)0);
    }
    if (values[3]) {
      __pyx_v_axis2 = __Pyx_PyIndex_AsSsize_t(values[3]); if (unlikely((__pyx_v_axis2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3205, __pyx_L3_error)
    } else {
      __pyx_v_axis2 = ((Py_ssize_t)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_diagonal", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3204, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._diagonal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3204, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_90_diagonal(__pyx_self, __pyx_v_a, __pyx_v_offset, __pyx_v_axis1, __pyx_v_axis2);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_90_diagonal(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, Py_ssize_t __pyx_v_offset, Py_ssize_t __pyx_v_axis1, Py_ssize_t __pyx_v_axis2) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__diagonal __pyx_t_2;
  __Pyx_RefNannySetupContext("_diagonal", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.offset = __pyx_v_offset;
  __pyx_t_2.axis1 = __pyx_v_axis1;
  __pyx_t_2.axis2 = __pyx_v_axis2;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__diagonal(__pyx_v_a, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._diagonal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3242
 * 
 * 
 * cpdef _prepare_multiple_array_indexing(ndarray a, list slices):             # <<<<<<<<<<<<<<
 *     # slices consist of either slice(None) or ndarray
 *     cdef Py_ssize_t i, p, li, ri
 */

static PyObject *__pyx_pw_4cupy_4core_4core_93_prepare_multiple_array_indexing(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__prepare_multiple_array_indexing(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slices, CYTHON_UNUSED int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_li;
  Py_ssize_t __pyx_v_ri;
  struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_br = NULL;
  int __pyx_v_do_transpose;
  PyObject *__pyx_v_prev_arr_i = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_v_transp_a = NULL;
  PyObject *__pyx_v_transp_b = NULL;
  PyObject *__pyx_v_slices_a = NULL;
  PyObject *__pyx_v_slices_b = NULL;
  PyObject *__pyx_v_a_interm_shape = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a_interm = NULL;
  PyObject *__pyx_v_strides = NULL;
  PyObject *__pyx_v_flattened_indexes = NULL;
  PyObject *__pyx_v_concat_shape = NULL;
  PyObject *__pyx_v_reduced_idx = NULL;
  PyObject *__pyx_v_stride = NULL;
  PyObject *__pyx_v_a_interm_shape_i = NULL;
  PyObject *__pyx_v_index = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *(*__pyx_t_15)(PyObject *);
  __Pyx_RefNannySetupContext("_prepare_multiple_array_indexing", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF(__pyx_v_slices);

  /* "cupy/core/core.pyx":3248
 *     cdef tuple a_shape
 * 
 *     br = broadcast(*slices)             # <<<<<<<<<<<<<<
 *     slices = list(br.values)
 * 
 */
  __pyx_t_1 = PySequence_Tuple(__pyx_v_slices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_broadcast), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_br = ((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":3249
 * 
 *     br = broadcast(*slices)
 *     slices = list(br.values)             # <<<<<<<<<<<<<<
 * 
 *     # check if transpose is necessasry
 */
  __pyx_t_2 = PySequence_List(__pyx_v_br->values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_slices, ((PyObject*)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":3254
 *     # li:  index of the leftmost array in slices
 *     # ri:  index of the rightmost array in slices
 *     do_transpose = False             # <<<<<<<<<<<<<<
 *     prev_arr_i = None
 *     li = 0
 */
  __pyx_v_do_transpose = 0;

  /* "cupy/core/core.pyx":3255
 *     # ri:  index of the rightmost array in slices
 *     do_transpose = False
 *     prev_arr_i = None             # <<<<<<<<<<<<<<
 *     li = 0
 *     ri = 0
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_prev_arr_i = Py_None;

  /* "cupy/core/core.pyx":3256
 *     do_transpose = False
 *     prev_arr_i = None
 *     li = 0             # <<<<<<<<<<<<<<
 *     ri = 0
 *     for i, s in enumerate(slices):
 */
  __pyx_v_li = 0;

  /* "cupy/core/core.pyx":3257
 *     prev_arr_i = None
 *     li = 0
 *     ri = 0             # <<<<<<<<<<<<<<
 *     for i, s in enumerate(slices):
 *         if isinstance(s, ndarray):
 */
  __pyx_v_ri = 0;

  /* "cupy/core/core.pyx":3258
 *     li = 0
 *     ri = 0
 *     for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *         if isinstance(s, ndarray):
 *             if prev_arr_i is None:
 */
  __pyx_t_3 = 0;
  __pyx_t_2 = __pyx_v_slices; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 3258, __pyx_L1_error)
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3258, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_v_i = __pyx_t_3;
    __pyx_t_3 = (__pyx_t_3 + 1);

    /* "cupy/core/core.pyx":3259
 *     ri = 0
 *     for i, s in enumerate(slices):
 *         if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *             if prev_arr_i is None:
 *                 prev_arr_i = i
 */
    __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_6 = (__pyx_t_5 != 0);
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":3260
 *     for i, s in enumerate(slices):
 *         if isinstance(s, ndarray):
 *             if prev_arr_i is None:             # <<<<<<<<<<<<<<
 *                 prev_arr_i = i
 *                 li = i
 */
      __pyx_t_6 = (__pyx_v_prev_arr_i == Py_None);
      __pyx_t_5 = (__pyx_t_6 != 0);
      if (__pyx_t_5) {

        /* "cupy/core/core.pyx":3261
 *         if isinstance(s, ndarray):
 *             if prev_arr_i is None:
 *                 prev_arr_i = i             # <<<<<<<<<<<<<<
 *                 li = i
 *             elif prev_arr_i is not None and i - prev_arr_i > 1:
 */
        __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3261, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF_SET(__pyx_v_prev_arr_i, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "cupy/core/core.pyx":3262
 *             if prev_arr_i is None:
 *                 prev_arr_i = i
 *                 li = i             # <<<<<<<<<<<<<<
 *             elif prev_arr_i is not None and i - prev_arr_i > 1:
 *                 do_transpose = True
 */
        __pyx_v_li = __pyx_v_i;

        /* "cupy/core/core.pyx":3260
 *     for i, s in enumerate(slices):
 *         if isinstance(s, ndarray):
 *             if prev_arr_i is None:             # <<<<<<<<<<<<<<
 *                 prev_arr_i = i
 *                 li = i
 */
        goto __pyx_L6;
      }

      /* "cupy/core/core.pyx":3263
 *                 prev_arr_i = i
 *                 li = i
 *             elif prev_arr_i is not None and i - prev_arr_i > 1:             # <<<<<<<<<<<<<<
 *                 do_transpose = True
 *             else:
 */
      __pyx_t_6 = (__pyx_v_prev_arr_i != Py_None);
      __pyx_t_7 = (__pyx_t_6 != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_5 = __pyx_t_7;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3263, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = PyNumber_Subtract(__pyx_t_1, __pyx_v_prev_arr_i); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3263, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_8, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3263, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 3263, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = __pyx_t_7;
      __pyx_L7_bool_binop_done:;
      if (__pyx_t_5) {

        /* "cupy/core/core.pyx":3264
 *                 li = i
 *             elif prev_arr_i is not None and i - prev_arr_i > 1:
 *                 do_transpose = True             # <<<<<<<<<<<<<<
 *             else:
 *                 prev_arr_i = i
 */
        __pyx_v_do_transpose = 1;

        /* "cupy/core/core.pyx":3263
 *                 prev_arr_i = i
 *                 li = i
 *             elif prev_arr_i is not None and i - prev_arr_i > 1:             # <<<<<<<<<<<<<<
 *                 do_transpose = True
 *             else:
 */
        goto __pyx_L6;
      }

      /* "cupy/core/core.pyx":3266
 *                 do_transpose = True
 *             else:
 *                 prev_arr_i = i             # <<<<<<<<<<<<<<
 *                 ri = i
 * 
 */
      /*else*/ {
        __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3266, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF_SET(__pyx_v_prev_arr_i, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "cupy/core/core.pyx":3267
 *             else:
 *                 prev_arr_i = i
 *                 ri = i             # <<<<<<<<<<<<<<
 * 
 *     if do_transpose:
 */
        __pyx_v_ri = __pyx_v_i;
      }
      __pyx_L6:;

      /* "cupy/core/core.pyx":3259
 *     ri = 0
 *     for i, s in enumerate(slices):
 *         if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *             if prev_arr_i is None:
 *                 prev_arr_i = i
 */
    }

    /* "cupy/core/core.pyx":3258
 *     li = 0
 *     ri = 0
 *     for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *         if isinstance(s, ndarray):
 *             if prev_arr_i is None:
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":3269
 *                 ri = i
 * 
 *     if do_transpose:             # <<<<<<<<<<<<<<
 *         transp_a = []
 *         transp_b = []
 */
  __pyx_t_5 = (__pyx_v_do_transpose != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":3270
 * 
 *     if do_transpose:
 *         transp_a = []             # <<<<<<<<<<<<<<
 *         transp_b = []
 *         slices_a = []
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3270, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_transp_a = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3271
 *     if do_transpose:
 *         transp_a = []
 *         transp_b = []             # <<<<<<<<<<<<<<
 *         slices_a = []
 *         slices_b = []
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3271, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_transp_b = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3272
 *         transp_a = []
 *         transp_b = []
 *         slices_a = []             # <<<<<<<<<<<<<<
 *         slices_b = []
 * 
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3272, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_slices_a = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3273
 *         transp_b = []
 *         slices_a = []
 *         slices_b = []             # <<<<<<<<<<<<<<
 * 
 *         for i, s in enumerate(slices):
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3273, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_slices_b = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3275
 *         slices_b = []
 * 
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if isinstance(s, ndarray):
 *                 transp_a.append(i)
 */
    __pyx_t_3 = 0;
    __pyx_t_2 = __pyx_v_slices; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 3275, __pyx_L1_error)
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3275, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_v_i = __pyx_t_3;
      __pyx_t_3 = (__pyx_t_3 + 1);

      /* "cupy/core/core.pyx":3276
 * 
 *         for i, s in enumerate(slices):
 *             if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *                 transp_a.append(i)
 *                 slices_a.append(s)
 */
      __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
      __pyx_t_7 = (__pyx_t_5 != 0);
      if (__pyx_t_7) {

        /* "cupy/core/core.pyx":3277
 *         for i, s in enumerate(slices):
 *             if isinstance(s, ndarray):
 *                 transp_a.append(i)             # <<<<<<<<<<<<<<
 *                 slices_a.append(s)
 *             else:
 */
        __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3277, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_transp_a, __pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 3277, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cupy/core/core.pyx":3278
 *             if isinstance(s, ndarray):
 *                 transp_a.append(i)
 *                 slices_a.append(s)             # <<<<<<<<<<<<<<
 *             else:
 *                 transp_b.append(i)
 */
        __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_slices_a, __pyx_v_s); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 3278, __pyx_L1_error)

        /* "cupy/core/core.pyx":3276
 * 
 *         for i, s in enumerate(slices):
 *             if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *                 transp_a.append(i)
 *                 slices_a.append(s)
 */
        goto __pyx_L12;
      }

      /* "cupy/core/core.pyx":3280
 *                 slices_a.append(s)
 *             else:
 *                 transp_b.append(i)             # <<<<<<<<<<<<<<
 *                 slices_b.append(s)
 *         a = a.transpose(*(transp_a + transp_b))
 */
      /*else*/ {
        __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3280, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_transp_b, __pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 3280, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cupy/core/core.pyx":3281
 *             else:
 *                 transp_b.append(i)
 *                 slices_b.append(s)             # <<<<<<<<<<<<<<
 *         a = a.transpose(*(transp_a + transp_b))
 *         slices = slices_a + slices_b
 */
        __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_slices_b, __pyx_v_s); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 3281, __pyx_L1_error)
      }
      __pyx_L12:;

      /* "cupy/core/core.pyx":3275
 *         slices_b = []
 * 
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if isinstance(s, ndarray):
 *                 transp_a.append(i)
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3282
 *                 transp_b.append(i)
 *                 slices_b.append(s)
 *         a = a.transpose(*(transp_a + transp_b))             # <<<<<<<<<<<<<<
 *         slices = slices_a + slices_b
 *         li = 0
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_transpose_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3282, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_Add(__pyx_v_transp_a, __pyx_v_transp_b); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3282, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3282, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3282, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3282, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3283
 *                 slices_b.append(s)
 *         a = a.transpose(*(transp_a + transp_b))
 *         slices = slices_a + slices_b             # <<<<<<<<<<<<<<
 *         li = 0
 *         ri = len(transp_a) - 1
 */
    __pyx_t_1 = PyNumber_Add(__pyx_v_slices_a, __pyx_v_slices_b); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_slices, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3284
 *         a = a.transpose(*(transp_a + transp_b))
 *         slices = slices_a + slices_b
 *         li = 0             # <<<<<<<<<<<<<<
 *         ri = len(transp_a) - 1
 * 
 */
    __pyx_v_li = 0;

    /* "cupy/core/core.pyx":3285
 *         slices = slices_a + slices_b
 *         li = 0
 *         ri = len(transp_a) - 1             # <<<<<<<<<<<<<<
 * 
 *     a_interm_shape = a.shape
 */
    __pyx_t_3 = PyList_GET_SIZE(__pyx_v_transp_a); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 3285, __pyx_L1_error)
    __pyx_v_ri = (__pyx_t_3 - 1);

    /* "cupy/core/core.pyx":3269
 *                 ri = i
 * 
 *     if do_transpose:             # <<<<<<<<<<<<<<
 *         transp_a = []
 *         transp_b = []
 */
  }

  /* "cupy/core/core.pyx":3287
 *         ri = len(transp_a) - 1
 * 
 *     a_interm_shape = a.shape             # <<<<<<<<<<<<<<
 *     a_interm = a
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_a_interm_shape = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3288
 * 
 *     a_interm_shape = a.shape
 *     a_interm = a             # <<<<<<<<<<<<<<
 * 
 *     # build the strides
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_a));
  __pyx_v_a_interm = __pyx_v_a;

  /* "cupy/core/core.pyx":3291
 * 
 *     # build the strides
 *     strides = [1]             # <<<<<<<<<<<<<<
 *     for s in a.shape[ri:li:-1]:
 *         strides.insert(0, s * strides[0])
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_1);
  __pyx_v_strides = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3292
 *     # build the strides
 *     strides = [1]
 *     for s in a.shape[ri:li:-1]:             # <<<<<<<<<<<<<<
 *         strides.insert(0, s * strides[0])
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_ri); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_li); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = PySlice_New(__pyx_t_8, __pyx_t_2, __pyx_int_neg_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_10 = __pyx_t_2; __Pyx_INCREF(__pyx_t_10); __pyx_t_3 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3292, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3292, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_11)) {
      if (likely(PyList_CheckExact(__pyx_t_10))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_10)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 3292, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_10, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3292, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_10)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 3292, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_10, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3292, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_11(__pyx_t_10);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3292, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3293
 *     strides = [1]
 *     for s in a.shape[ri:li:-1]:
 *         strides.insert(0, s * strides[0])             # <<<<<<<<<<<<<<
 * 
 *     # wrap all out-of-bound indices
 */
    __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_strides, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_Multiply(__pyx_v_s, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_9 = PyList_Insert(__pyx_v_strides, 0, __pyx_t_1); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 3293, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3292
 *     # build the strides
 *     strides = [1]
 *     for s in a.shape[ri:li:-1]:             # <<<<<<<<<<<<<<
 *         strides.insert(0, s * strides[0])
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":3296
 * 
 *     # wrap all out-of-bound indices
 *     flattened_indexes = [             # <<<<<<<<<<<<<<
 *         stride * (s % a_interm_shape_i) for stride, s, a_interm_shape_i
 *         in zip(strides, slices[li:ri + 1], a_interm_shape[li:ri + 1])]
 */
  __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);

  /* "cupy/core/core.pyx":3298
 *     flattened_indexes = [
 *         stride * (s % a_interm_shape_i) for stride, s, a_interm_shape_i
 *         in zip(strides, slices[li:ri + 1], a_interm_shape[li:ri + 1])]             # <<<<<<<<<<<<<<
 * 
 *     # do stack: flattened_indexes = stack(flattened_indexes, axis=0)
 */
  __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_v_slices, __pyx_v_li, (__pyx_v_ri + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_a_interm_shape, __pyx_v_li, (__pyx_v_ri + 1), NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_v_strides);
  __Pyx_GIVEREF(__pyx_v_strides);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_strides);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_8 = __pyx_t_2; __Pyx_INCREF(__pyx_t_8); __pyx_t_3 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_11 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3298, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_11)) {
      if (likely(PyList_CheckExact(__pyx_t_8))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 3298, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_8, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3298, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 3298, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_8, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3298, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_11(__pyx_t_8);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3298, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 3297, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_13 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_12 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_13 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_13);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3297, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3297, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3297, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_14 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3297, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_15 = Py_TYPE(__pyx_t_14)->tp_iternext;
      index = 0; __pyx_t_1 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_1)) goto __pyx_L17_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 1; __pyx_t_12 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_12)) goto __pyx_L17_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_12);
      index = 2; __pyx_t_13 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_13)) goto __pyx_L17_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_13);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_14), 3) < 0) __PYX_ERR(0, 3297, __pyx_L1_error)
      __pyx_t_15 = NULL;
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      goto __pyx_L18_unpacking_done;
      __pyx_L17_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_15 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 3297, __pyx_L1_error)
      __pyx_L18_unpacking_done:;
    }

    /* "cupy/core/core.pyx":3297
 *     # wrap all out-of-bound indices
 *     flattened_indexes = [
 *         stride * (s % a_interm_shape_i) for stride, s, a_interm_shape_i             # <<<<<<<<<<<<<<
 *         in zip(strides, slices[li:ri + 1], a_interm_shape[li:ri + 1])]
 * 
 */
    __Pyx_XDECREF_SET(__pyx_v_stride, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_12);
    __pyx_t_12 = 0;
    __Pyx_XDECREF_SET(__pyx_v_a_interm_shape_i, __pyx_t_13);
    __pyx_t_13 = 0;
    __pyx_t_2 = PyNumber_Remainder(__pyx_v_s, __pyx_v_a_interm_shape_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3297, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_13 = PyNumber_Multiply(__pyx_v_stride, __pyx_t_2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3297, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_10, (PyObject*)__pyx_t_13))) __PYX_ERR(0, 3296, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_flattened_indexes = __pyx_t_10;
  __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":3301
 * 
 *     # do stack: flattened_indexes = stack(flattened_indexes, axis=0)
 *     concat_shape = (len(flattened_indexes),) + br.shape             # <<<<<<<<<<<<<<
 *     flattened_indexes = concatenate(
 *         [index._reshape((1,) + index.shape) for index in flattened_indexes],
 */
  __pyx_t_3 = PyObject_Length(__pyx_v_flattened_indexes); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 3301, __pyx_L1_error)
  __pyx_t_10 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10);
  __pyx_t_10 = 0;
  __pyx_t_10 = PyNumber_Add(__pyx_t_8, __pyx_v_br->shape); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_concat_shape = __pyx_t_10;
  __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":3303
 *     concat_shape = (len(flattened_indexes),) + br.shape
 *     flattened_indexes = concatenate(
 *         [index._reshape((1,) + index.shape) for index in flattened_indexes],             # <<<<<<<<<<<<<<
 *         axis=0, shape=concat_shape, dtype=flattened_indexes[0].dtype)
 * 
 */
  __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_8 = __pyx_v_flattened_indexes; __Pyx_INCREF(__pyx_t_8); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_8)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_13 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_3); __Pyx_INCREF(__pyx_t_13); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 3303, __pyx_L1_error)
    #else
    __pyx_t_13 = PySequence_ITEM(__pyx_t_8, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3303, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_13);
    __pyx_t_13 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_reshape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3303, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_shape); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3303, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_1 = PyNumber_Add(__pyx_tuple__166, __pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3303, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_12) {
      __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3303, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_13);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_1};
        __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3303, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_13);
        __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[2] = {__pyx_t_12, __pyx_t_1};
        __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3303, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      {
        __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3303, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); __pyx_t_12 = NULL;
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_1);
        __pyx_t_1 = 0;
        __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_14, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3303, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_10, (PyObject*)__pyx_t_13))) __PYX_ERR(0, 3303, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3304
 *     flattened_indexes = concatenate(
 *         [index._reshape((1,) + index.shape) for index in flattened_indexes],
 *         axis=0, shape=concat_shape, dtype=flattened_indexes[0].dtype)             # <<<<<<<<<<<<<<
 * 
 *     reduced_idx = _sum(flattened_indexes, axis=0)
 */
  __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_flattened_indexes, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dtype); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3302
 *     # do stack: flattened_indexes = stack(flattened_indexes, axis=0)
 *     concat_shape = (len(flattened_indexes),) + br.shape
 *     flattened_indexes = concatenate(             # <<<<<<<<<<<<<<
 *         [index._reshape((1,) + index.shape) for index in flattened_indexes],
 *         axis=0, shape=concat_shape, dtype=flattened_indexes[0].dtype)
 */
  __pyx_t_8 = ((PyObject *)__pyx_f_4cupy_4core_4core_concatenate(__pyx_t_10, __pyx_int_0, __pyx_v_concat_shape, __pyx_t_13, 0)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF_SET(__pyx_v_flattened_indexes, __pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3306
 *         axis=0, shape=concat_shape, dtype=flattened_indexes[0].dtype)
 * 
 *     reduced_idx = _sum(flattened_indexes, axis=0)             # <<<<<<<<<<<<<<
 * 
 *     return a_interm, reduced_idx, li, ri
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_sum_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_INCREF(__pyx_v_flattened_indexes);
  __Pyx_GIVEREF(__pyx_v_flattened_indexes);
  PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_flattened_indexes);
  __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_axis, __pyx_int_0) < 0) __PYX_ERR(0, 3306, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_13, __pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_v_reduced_idx = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":3308
 *     reduced_idx = _sum(flattened_indexes, axis=0)
 * 
 *     return a_interm, reduced_idx, li, ri             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_li); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = PyInt_FromSsize_t(__pyx_v_ri); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_13 = PyTuple_New(4); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_INCREF(((PyObject *)__pyx_v_a_interm));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_a_interm));
  PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)__pyx_v_a_interm));
  __Pyx_INCREF(__pyx_v_reduced_idx);
  __Pyx_GIVEREF(__pyx_v_reduced_idx);
  PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_reduced_idx);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_10);
  __pyx_t_2 = 0;
  __pyx_t_10 = 0;
  __pyx_r = __pyx_t_13;
  __pyx_t_13 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3242
 * 
 * 
 * cpdef _prepare_multiple_array_indexing(ndarray a, list slices):             # <<<<<<<<<<<<<<
 *     # slices consist of either slice(None) or ndarray
 *     cdef Py_ssize_t i, p, li, ri
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("cupy.core.core._prepare_multiple_array_indexing", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_br);
  __Pyx_XDECREF(__pyx_v_prev_arr_i);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_transp_a);
  __Pyx_XDECREF(__pyx_v_transp_b);
  __Pyx_XDECREF(__pyx_v_slices_a);
  __Pyx_XDECREF(__pyx_v_slices_b);
  __Pyx_XDECREF(__pyx_v_a_interm_shape);
  __Pyx_XDECREF((PyObject *)__pyx_v_a_interm);
  __Pyx_XDECREF(__pyx_v_strides);
  __Pyx_XDECREF(__pyx_v_flattened_indexes);
  __Pyx_XDECREF(__pyx_v_concat_shape);
  __Pyx_XDECREF(__pyx_v_reduced_idx);
  __Pyx_XDECREF(__pyx_v_stride);
  __Pyx_XDECREF(__pyx_v_a_interm_shape_i);
  __Pyx_XDECREF(__pyx_v_index);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_slices);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_93_prepare_multiple_array_indexing(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_92_prepare_multiple_array_indexing[] = "_prepare_multiple_array_indexing(ndarray a, list slices)";
static PyObject *__pyx_pw_4cupy_4core_4core_93_prepare_multiple_array_indexing(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_slices = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_prepare_multiple_array_indexing (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_slices,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_slices)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_prepare_multiple_array_indexing", 1, 2, 2, 1); __PYX_ERR(0, 3242, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_prepare_multiple_array_indexing") < 0)) __PYX_ERR(0, 3242, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_slices = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_prepare_multiple_array_indexing", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3242, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._prepare_multiple_array_indexing", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3242, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_slices), (&PyList_Type), 1, "slices", 1))) __PYX_ERR(0, 3242, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_92_prepare_multiple_array_indexing(__pyx_self, __pyx_v_a, __pyx_v_slices);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_92_prepare_multiple_array_indexing(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slices) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_prepare_multiple_array_indexing", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__prepare_multiple_array_indexing(__pyx_v_a, __pyx_v_slices, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._prepare_multiple_array_indexing", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3311
 * 
 * 
 * cpdef ndarray _getitem_multiple(ndarray a, list slices):             # <<<<<<<<<<<<<<
 *     cdef ndarray a_interm, reduced_idx, ret, ret_flat
 *     cdef tuple a_interm_shape, kern_input_shape, out_shape
 */

static PyObject *__pyx_pw_4cupy_4core_4core_95_getitem_multiple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__getitem_multiple(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slices, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a_interm = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_reduced_idx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret_flat = 0;
  PyObject *__pyx_v_a_interm_shape = 0;
  PyObject *__pyx_v_out_shape = 0;
  int __pyx_v_li;
  int __pyx_v_ri;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  int __pyx_t_9;
  struct __pyx_opt_args_4cupy_4core_4core__take __pyx_t_10;
  std::vector<Py_ssize_t>  __pyx_t_11;
  __Pyx_RefNannySetupContext("_getitem_multiple", 0);

  /* "cupy/core/core.pyx":3316
 *     cdef int li, ri
 * 
 *     a_interm, reduced_idx, li, ri = _prepare_multiple_array_indexing(a, slices)             # <<<<<<<<<<<<<<
 * 
 *     a_interm_shape = a_interm.shape
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__prepare_multiple_array_indexing(__pyx_v_a, __pyx_v_slices, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3316, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 3316, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_4,&__pyx_t_5};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 3316, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_4,&__pyx_t_5};
    __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3316, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_7(__pyx_t_6); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 3316, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 3316, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3316, __pyx_L1_error)
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3316, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3316, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3316, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_a_interm = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_v_reduced_idx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_li = __pyx_t_8;
  __pyx_v_ri = __pyx_t_9;

  /* "cupy/core/core.pyx":3318
 *     a_interm, reduced_idx, li, ri = _prepare_multiple_array_indexing(a, slices)
 * 
 *     a_interm_shape = a_interm.shape             # <<<<<<<<<<<<<<
 *     out_shape = a_interm_shape[:li] + \
 *         reduced_idx.shape + a_interm_shape[ri + 1:]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a_interm), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3318, __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, 3318, __pyx_L1_error)
  __pyx_v_a_interm_shape = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3319
 * 
 *     a_interm_shape = a_interm.shape
 *     out_shape = a_interm_shape[:li] + \             # <<<<<<<<<<<<<<
 *         reduced_idx.shape + a_interm_shape[ri + 1:]
 *     ret_flat = _take(a_interm, reduced_idx.ravel(), li=li, ri=ri)
 */
  if (unlikely(__pyx_v_a_interm_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 3319, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyTuple_GetSlice(__pyx_v_a_interm_shape, 0, __pyx_v_li); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":3320
 *     a_interm_shape = a_interm.shape
 *     out_shape = a_interm_shape[:li] + \
 *         reduced_idx.shape + a_interm_shape[ri + 1:]             # <<<<<<<<<<<<<<
 *     ret_flat = _take(a_interm, reduced_idx.ravel(), li=li, ri=ri)
 *     ret = ret_flat._reshape(out_shape)
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_reduced_idx), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/core.pyx":3319
 * 
 *     a_interm_shape = a_interm.shape
 *     out_shape = a_interm_shape[:li] + \             # <<<<<<<<<<<<<<
 *         reduced_idx.shape + a_interm_shape[ri + 1:]
 *     ret_flat = _take(a_interm, reduced_idx.ravel(), li=li, ri=ri)
 */
  __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3320
 *     a_interm_shape = a_interm.shape
 *     out_shape = a_interm_shape[:li] + \
 *         reduced_idx.shape + a_interm_shape[ri + 1:]             # <<<<<<<<<<<<<<
 *     ret_flat = _take(a_interm, reduced_idx.ravel(), li=li, ri=ri)
 *     ret = ret_flat._reshape(out_shape)
 */
  if (unlikely(__pyx_v_a_interm_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 3320, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyTuple_GetSlice(__pyx_v_a_interm_shape, (__pyx_v_ri + 1), PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyNumber_Add(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 3320, __pyx_L1_error)
  __pyx_v_out_shape = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3321
 *     out_shape = a_interm_shape[:li] + \
 *         reduced_idx.shape + a_interm_shape[ri + 1:]
 *     ret_flat = _take(a_interm, reduced_idx.ravel(), li=li, ri=ri)             # <<<<<<<<<<<<<<
 *     ret = ret_flat._reshape(out_shape)
 *     return ret
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_reduced_idx->__pyx_vtab)->ravel(__pyx_v_reduced_idx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3321, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_li); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3321, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_ri); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3321, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10.__pyx_n = 2;
  __pyx_t_10.li = __pyx_t_5;
  __pyx_t_10.ri = __pyx_t_4;
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core__take(__pyx_v_a_interm, __pyx_t_1, 0, &__pyx_t_10)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3321, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_ret_flat = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3322
 *         reduced_idx.shape + a_interm_shape[ri + 1:]
 *     ret_flat = _take(a_interm, reduced_idx.ravel(), li=li, ri=ri)
 *     ret = ret_flat._reshape(out_shape)             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
  __pyx_t_11 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_out_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3322, __pyx_L1_error)
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ret_flat->__pyx_vtab)->_reshape(__pyx_v_ret_flat, __pyx_t_11, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3322, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3323
 *     ret_flat = _take(a_interm, reduced_idx.ravel(), li=li, ri=ri)
 *     ret = ret_flat._reshape(out_shape)
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3311
 * 
 * 
 * cpdef ndarray _getitem_multiple(ndarray a, list slices):             # <<<<<<<<<<<<<<
 *     cdef ndarray a_interm, reduced_idx, ret, ret_flat
 *     cdef tuple a_interm_shape, kern_input_shape, out_shape
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core._getitem_multiple", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_a_interm);
  __Pyx_XDECREF((PyObject *)__pyx_v_reduced_idx);
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XDECREF((PyObject *)__pyx_v_ret_flat);
  __Pyx_XDECREF(__pyx_v_a_interm_shape);
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_95_getitem_multiple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_94_getitem_multiple[] = "_getitem_multiple(ndarray a, list slices) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_95_getitem_multiple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_slices = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_getitem_multiple (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_slices,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_slices)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_getitem_multiple", 1, 2, 2, 1); __PYX_ERR(0, 3311, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_getitem_multiple") < 0)) __PYX_ERR(0, 3311, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_slices = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_getitem_multiple", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3311, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._getitem_multiple", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3311, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_slices), (&PyList_Type), 1, "slices", 1))) __PYX_ERR(0, 3311, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_94_getitem_multiple(__pyx_self, __pyx_v_a, __pyx_v_slices);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_94_getitem_multiple(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slices) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_getitem_multiple", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__getitem_multiple(__pyx_v_a, __pyx_v_slices, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._getitem_multiple", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3330
 * # -----------------------------------------------------------------------------
 * 
 * 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_97dot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_dot(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_dot *__pyx_optional_args) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);
  Py_ssize_t __pyx_v_a_ndim;
  Py_ssize_t __pyx_v_b_ndim;
  Py_ssize_t __pyx_v_a_axis;
  Py_ssize_t __pyx_v_b_axis;
  Py_ssize_t __pyx_v_n;
  Py_ssize_t __pyx_v_m;
  Py_ssize_t __pyx_v_k;
  int __pyx_v_input_a_is_vec;
  int __pyx_v_input_b_is_vec;
  std::vector<Py_ssize_t>  __pyx_v_ret_shape;
  std::vector<Py_ssize_t>  __pyx_v_shape;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_rollaxis __pyx_t_9;
  __Pyx_RefNannySetupContext("dot", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_out = __pyx_optional_args->out;
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF((PyObject *)__pyx_v_b);

  /* "cupy/core/core.pyx":3336
 *     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":3337
 * 
 *     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":3339
 *     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, 3339, __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, 3339, __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, 3339, __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, 3339, __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, 3339, __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, 3339, __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, 3339, __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, 3339, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3340
 * 
 *     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__167, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3340, __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, 3340, __pyx_L1_error)

    /* "cupy/core/core.pyx":3339
 *     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":3342
 *         raise ValueError('Not supported dtype combination.')
 * 
 *     if a_ndim == 0 or b_ndim == 0:             # <<<<<<<<<<<<<<
 *         return multiply(a, b, out=out)
 * 
 */
  __pyx_t_3 = ((__pyx_v_a_ndim == 0) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_3 = ((__pyx_v_b_ndim == 0) != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3343
 * 
 *     if a_ndim == 0 or b_ndim == 0:
 *         return multiply(a, b, out=out)             # <<<<<<<<<<<<<<
 * 
 *     input_a_is_vec = a_ndim == 1
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_multiply); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3343, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3343, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_a));
    __Pyx_INCREF(((PyObject *)__pyx_v_b));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_b));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_b));
    __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3343, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_out, ((PyObject *)__pyx_v_out)) < 0) __PYX_ERR(0, 3343, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3343, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3343, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3342
 *         raise ValueError('Not supported dtype combination.')
 * 
 *     if a_ndim == 0 or b_ndim == 0:             # <<<<<<<<<<<<<<
 *         return multiply(a, b, out=out)
 * 
 */
  }

  /* "cupy/core/core.pyx":3345
 *         return multiply(a, b, out=out)
 * 
 *     input_a_is_vec = a_ndim == 1             # <<<<<<<<<<<<<<
 *     input_b_is_vec = b_ndim == 1
 *     if input_a_is_vec:
 */
  __pyx_v_input_a_is_vec = (__pyx_v_a_ndim == 1);

  /* "cupy/core/core.pyx":3346
 * 
 *     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":3347
 *     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":3348
 *     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":3349
 *     if input_a_is_vec:
 *         shape.clear()
 *         shape.push_back(1)             # <<<<<<<<<<<<<<
 *         shape.push_back(a.size)
 *         a = a._reshape(shape)
 */
    try {
      __pyx_v_shape.push_back(1);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3349, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3350
 *         shape.clear()
 *         shape.push_back(1)
 *         shape.push_back(a.size)             # <<<<<<<<<<<<<<
 *         a = a._reshape(shape)
 *         a_ndim = 2
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_a->size);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3350, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3351
 *         shape.push_back(1)
 *         shape.push_back(a.size)
 *         a = a._reshape(shape)             # <<<<<<<<<<<<<<
 *         a_ndim = 2
 *     if input_b_is_vec:
 */
    __pyx_t_5 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->_reshape(__pyx_v_a, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3351, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3352
 *         shape.push_back(a.size)
 *         a = a._reshape(shape)
 *         a_ndim = 2             # <<<<<<<<<<<<<<
 *     if input_b_is_vec:
 *         shape.clear()
 */
    __pyx_v_a_ndim = 2;

    /* "cupy/core/core.pyx":3347
 *     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":3353
 *         a = a._reshape(shape)
 *         a_ndim = 2
 *     if input_b_is_vec:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(b.size)
 */
  __pyx_t_1 = (__pyx_v_input_b_is_vec != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3354
 *         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":3355
 *     if input_b_is_vec:
 *         shape.clear()
 *         shape.push_back(b.size)             # <<<<<<<<<<<<<<
 *         shape.push_back(1)
 *         b = b._reshape(shape)
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_b->size);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3355, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3356
 *         shape.clear()
 *         shape.push_back(b.size)
 *         shape.push_back(1)             # <<<<<<<<<<<<<<
 *         b = b._reshape(shape)
 *         b_ndim = 2
 */
    try {
      __pyx_v_shape.push_back(1);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3356, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3357
 *         shape.push_back(b.size)
 *         shape.push_back(1)
 *         b = b._reshape(shape)             # <<<<<<<<<<<<<<
 *         b_ndim = 2
 * 
 */
    __pyx_t_5 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_b->__pyx_vtab)->_reshape(__pyx_v_b, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3357, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3358
 *         shape.push_back(1)
 *         b = b._reshape(shape)
 *         b_ndim = 2             # <<<<<<<<<<<<<<
 * 
 *     a_axis = a_ndim - 1
 */
    __pyx_v_b_ndim = 2;

    /* "cupy/core/core.pyx":3353
 *         a = a._reshape(shape)
 *         a_ndim = 2
 *     if input_b_is_vec:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(b.size)
 */
  }

  /* "cupy/core/core.pyx":3360
 *         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":3361
 * 
 *     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":3363
 *     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 (__pyx_t_1) {

    /* "cupy/core/core.pyx":3364
 * 
 *     if a._shape[a_axis] != b._shape[b_axis]:
 *         raise ValueError('Axis dimension mismatch')             # <<<<<<<<<<<<<<
 * 
 *     if a_axis:
 */
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__168, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3364, __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, 3364, __pyx_L1_error)

    /* "cupy/core/core.pyx":3363
 *     b_axis = b_ndim - 2
 * 
 *     if a._shape[a_axis] != b._shape[b_axis]:             # <<<<<<<<<<<<<<
 *         raise ValueError('Axis dimension mismatch')
 * 
 */
  }

  /* "cupy/core/core.pyx":3366
 *         raise ValueError('Axis dimension mismatch')
 * 
 *     if a_axis:             # <<<<<<<<<<<<<<
 *         a = rollaxis(a, a_axis, 0)
 *     if b_axis:
 */
  __pyx_t_1 = (__pyx_v_a_axis != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3367
 * 
 *     if a_axis:
 *         a = rollaxis(a, a_axis, 0)             # <<<<<<<<<<<<<<
 *     if b_axis:
 *         b = rollaxis(b, b_axis, 0)
 */
    __pyx_t_9.__pyx_n = 1;
    __pyx_t_9.start = 0;
    __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_rollaxis(__pyx_v_a, __pyx_v_a_axis, 0, &__pyx_t_9)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3367, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3366
 *         raise ValueError('Axis dimension mismatch')
 * 
 *     if a_axis:             # <<<<<<<<<<<<<<
 *         a = rollaxis(a, a_axis, 0)
 *     if b_axis:
 */
  }

  /* "cupy/core/core.pyx":3368
 *     if a_axis:
 *         a = rollaxis(a, a_axis, 0)
 *     if b_axis:             # <<<<<<<<<<<<<<
 *         b = rollaxis(b, b_axis, 0)
 * 
 */
  __pyx_t_1 = (__pyx_v_b_axis != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3369
 *         a = rollaxis(a, a_axis, 0)
 *     if b_axis:
 *         b = rollaxis(b, b_axis, 0)             # <<<<<<<<<<<<<<
 * 
 *     k = a._shape[0]
 */
    __pyx_t_9.__pyx_n = 1;
    __pyx_t_9.start = 0;
    __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_rollaxis(__pyx_v_b, __pyx_v_b_axis, 0, &__pyx_t_9)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3369, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3368
 *     if a_axis:
 *         a = rollaxis(a, a_axis, 0)
 *     if b_axis:             # <<<<<<<<<<<<<<
 *         b = rollaxis(b, b_axis, 0)
 * 
 */
  }

  /* "cupy/core/core.pyx":3371
 *         b = rollaxis(b, b_axis, 0)
 * 
 *     k = a._shape[0]             # <<<<<<<<<<<<<<
 *     if k != 0:
 *         m = b.size // k
 */
  __pyx_v_k = (__pyx_v_a->_shape[0]);

  /* "cupy/core/core.pyx":3372
 * 
 *     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":3373
 *     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, 3373, __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, 3373, __pyx_L1_error)
    }
    __pyx_v_m = __Pyx_div_Py_ssize_t(__pyx_v_b->size, __pyx_v_k);

    /* "cupy/core/core.pyx":3374
 *     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, 3374, __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, 3374, __pyx_L1_error)
    }
    __pyx_v_n = __Pyx_div_Py_ssize_t(__pyx_v_a->size, __pyx_v_k);

    /* "cupy/core/core.pyx":3372
 * 
 *     k = a._shape[0]
 *     if k != 0:             # <<<<<<<<<<<<<<
 *         m = b.size // k
 *         n = a.size // k
 */
    goto __pyx_L14;
  }

  /* "cupy/core/core.pyx":3378
 *         # 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":3379
 *         # like NumPy.
 *         m = 0
 *         n = 0             # <<<<<<<<<<<<<<
 * 
 *     if not input_a_is_vec:
 */
    __pyx_v_n = 0;
  }
  __pyx_L14:;

  /* "cupy/core/core.pyx":3381
 *         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":3382
 * 
 *     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, 3382, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3381
 *         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":3383
 *     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":3384
 *         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, 3384, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3383
 *     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":3385
 *     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":3386
 *         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 (__pyx_t_3) {

      /* "cupy/core/core.pyx":3387
 *     if out is not None:
 *         if k != 0 and out.size != n * m:
 *             raise ValueError('Output array has an invalid size')             # <<<<<<<<<<<<<<
 *         if not out._c_contiguous:
 *             raise ValueError('Output array must be C-contiguous')
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__169, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3387, __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, 3387, __pyx_L1_error)

      /* "cupy/core/core.pyx":3386
 *         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":3388
 *         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 (__pyx_t_3) {

      /* "cupy/core/core.pyx":3389
 *             raise ValueError('Output array has an invalid size')
 *         if not out._c_contiguous:
 *             raise ValueError('Output array must be C-contiguous')             # <<<<<<<<<<<<<<
 * 
 *     return tensordot_core(a, b, out, n, m, k, ret_shape)
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__170, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3389, __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, 3389, __pyx_L1_error)

      /* "cupy/core/core.pyx":3388
 *         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":3385
 *     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":3391
 *             raise ValueError('Output array must be C-contiguous')
 * 
 *     return tensordot_core(a, b, out, n, m, k, ret_shape)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_tensordot_core(__pyx_v_a, __pyx_v_b, __pyx_v_out, __pyx_v_n, __pyx_v_m, __pyx_v_k, __pyx_v_ret_shape, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3330
 * # -----------------------------------------------------------------------------
 * 
 * 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_97dot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_96dot[] = "dot(ndarray a, ndarray b, ndarray out=None) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_97dot(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] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_b)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("dot", 0, 2, 3, 1); __PYX_ERR(0, 3330, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 3330, __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, 3330, __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, 3330, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) __PYX_ERR(0, 3330, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(0, 3330, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_96dot(__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_96dot(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, 3330, __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":3394
 * 
 * 
 * cpdef ndarray _get_all_addresses(size_t start_adr,             # <<<<<<<<<<<<<<
 *                                  vector.vector[size_t] & shape,
 *                                  vector.vector[size_t] & strides):
 */

static PyObject *__pyx_pw_4cupy_4core_4core_99_get_all_addresses(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__get_all_addresses(size_t __pyx_v_start_adr, std::vector<size_t>  &__pyx_v_shape, std::vector<size_t>  &__pyx_v_strides, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_idx = NULL;
  PyObject *__pyx_v_sh_ = NULL;
  PyObject *__pyx_v_st_ = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("_get_all_addresses", 0);

  /* "cupy/core/core.pyx":3397
 *                                  vector.vector[size_t] & shape,
 *                                  vector.vector[size_t] & strides):
 *     idx = numpy.array([start_adr])             # <<<<<<<<<<<<<<
 *     for sh_, st_ in zip(shape, strides):
 *         idx = (idx[:, None] + (numpy.arange(sh_) * st_)[None, :]).ravel()
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_start_adr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3397, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3397, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3397, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3397, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3397, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_idx = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3398
 *                                  vector.vector[size_t] & strides):
 *     idx = numpy.array([start_adr])
 *     for sh_, st_ in zip(shape, strides):             # <<<<<<<<<<<<<<
 *         idx = (idx[:, None] + (numpy.arange(sh_) * st_)[None, :]).ravel()
 *     idx = idx.astype(numpy.uintp)
 */
  __pyx_t_1 = __pyx_convert_vector_to_py_size_t(__pyx_v_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __pyx_convert_vector_to_py_size_t(__pyx_v_strides); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_5 = __pyx_t_3; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3398, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3398, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 3398, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3398, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 3398, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3398, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_7(__pyx_t_5);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3398, __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;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 3398, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3398, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3398, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3398, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext;
      index = 0; __pyx_t_1 = __pyx_t_8(__pyx_t_2); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 1; __pyx_t_4 = __pyx_t_8(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_2), 2) < 0) __PYX_ERR(0, 3398, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 3398, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_sh_, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_st_, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3399
 *     idx = numpy.array([start_adr])
 *     for sh_, st_ in zip(shape, strides):
 *         idx = (idx[:, None] + (numpy.arange(sh_) * st_)[None, :]).ravel()             # <<<<<<<<<<<<<<
 *     idx = idx.astype(numpy.uintp)
 * 
 */
    __pyx_t_4 = PyObject_GetItem(__pyx_v_idx, __pyx_tuple__172); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_arange); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_2) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_sh_); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3399, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_sh_};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3399, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_sh_};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3399, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3399, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); __pyx_t_2 = NULL;
        __Pyx_INCREF(__pyx_v_sh_);
        __Pyx_GIVEREF(__pyx_v_sh_);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_sh_);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3399, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyNumber_Multiply(__pyx_t_1, __pyx_v_st_); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_GetItem(__pyx_t_9, __pyx_tuple__174); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyNumber_Add(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_ravel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (__pyx_t_9) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3399, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3399, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_idx, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3398
 *                                  vector.vector[size_t] & strides):
 *     idx = numpy.array([start_adr])
 *     for sh_, st_ in zip(shape, strides):             # <<<<<<<<<<<<<<
 *         idx = (idx[:, None] + (numpy.arange(sh_) * st_)[None, :]).ravel()
 *     idx = idx.astype(numpy.uintp)
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3400
 *     for sh_, st_ in zip(shape, strides):
 *         idx = (idx[:, None] + (numpy.arange(sh_) * st_)[None, :]).ravel()
 *     idx = idx.astype(numpy.uintp)             # <<<<<<<<<<<<<<
 * 
 *     ret = ndarray((idx.size,), dtype=numpy.uintp)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_idx, __pyx_n_s_astype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uintp); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3400, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_9};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3400, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_9};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3400, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3400, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL;
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3400, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_idx, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3402
 *     idx = idx.astype(numpy.uintp)
 * 
 *     ret = ndarray((idx.size,), dtype=numpy.uintp)             # <<<<<<<<<<<<<<
 *     ret.set(idx)
 *     return ret
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_idx, __pyx_n_s_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uintp); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_9) < 0) __PYX_ERR(0, 3402, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":3403
 * 
 *     ret = ndarray((idx.size,), dtype=numpy.uintp)
 *     ret.set(idx)             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
  __pyx_t_9 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ret->__pyx_vtab)->set(__pyx_v_ret, __pyx_v_idx, 0, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":3404
 *     ret = ndarray((idx.size,), dtype=numpy.uintp)
 *     ret.set(idx)
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3394
 * 
 * 
 * cpdef ndarray _get_all_addresses(size_t start_adr,             # <<<<<<<<<<<<<<
 *                                  vector.vector[size_t] & shape,
 *                                  vector.vector[size_t] & strides):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cupy.core.core._get_all_addresses", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_idx);
  __Pyx_XDECREF(__pyx_v_sh_);
  __Pyx_XDECREF(__pyx_v_st_);
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_99_get_all_addresses(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_98_get_all_addresses[] = "_get_all_addresses(size_t start_adr, vector[size_t] shape, vector[size_t] strides) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_99_get_all_addresses(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  size_t __pyx_v_start_adr;
  std::vector<size_t>  __pyx_v_shape;
  std::vector<size_t>  __pyx_v_strides;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_all_addresses (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_start_adr,&__pyx_n_s_shape,&__pyx_n_s_strides,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start_adr)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_all_addresses", 1, 3, 3, 1); __PYX_ERR(0, 3394, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_strides)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_all_addresses", 1, 3, 3, 2); __PYX_ERR(0, 3394, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_all_addresses") < 0)) __PYX_ERR(0, 3394, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_start_adr = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_start_adr == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3394, __pyx_L3_error)
    __pyx_v_shape = __pyx_convert_vector_from_py_size_t(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3395, __pyx_L3_error)
    __pyx_v_strides = __pyx_convert_vector_from_py_size_t(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3396, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_all_addresses", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3394, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_all_addresses", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_98_get_all_addresses(__pyx_self, __pyx_v_start_adr, __pyx_v_shape, __pyx_v_strides);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_98_get_all_addresses(CYTHON_UNUSED PyObject *__pyx_self, size_t __pyx_v_start_adr, std::vector<size_t>  __pyx_v_shape, std::vector<size_t>  __pyx_v_strides) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_all_addresses", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__get_all_addresses(__pyx_v_start_adr, __pyx_v_shape, __pyx_v_strides, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._get_all_addresses", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3407
 * 
 * 
 * cdef ndarray _mat_ptrs(ndarray a):             # <<<<<<<<<<<<<<
 *     """Creates an array of pointers to matrices
 *     Args:
 */

static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__mat_ptrs(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  std::vector<size_t>  __pyx_t_5;
  std::vector<size_t>  __pyx_t_6;
  __Pyx_RefNannySetupContext("_mat_ptrs", 0);

  /* "cupy/core/core.pyx":3422
 *     cdef Py_ssize_t stride, ptr, pointer, i
 *     cdef ndarray ret
 *     if a.ndim <= 2:             # <<<<<<<<<<<<<<
 *         ret = ndarray((1,), dtype=numpy.uintp)
 *         ret.fill(a.data.ptr)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_2, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3422, __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, 3422, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":3423
 *     cdef ndarray ret
 *     if a.ndim <= 2:
 *         ret = ndarray((1,), dtype=numpy.uintp)             # <<<<<<<<<<<<<<
 *         ret.fill(a.data.ptr)
 *         return ret
 */
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3423, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3423, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uintp); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3423, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 3423, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_tuple__176, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3423, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3424
 *     if a.ndim <= 2:
 *         ret = ndarray((1,), dtype=numpy.uintp)
 *         ret.fill(a.data.ptr)             # <<<<<<<<<<<<<<
 *         return ret
 *     else:
 */
    __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_a->data->ptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ret->__pyx_vtab)->fill(__pyx_v_ret, __pyx_t_4, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3425
 *         ret = ndarray((1,), dtype=numpy.uintp)
 *         ret.fill(a.data.ptr)
 *         return ret             # <<<<<<<<<<<<<<
 *     else:
 *         return _get_all_addresses(a.data.ptr, a.shape[:-2], a.strides[:-2])
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_ret));
    __pyx_r = __pyx_v_ret;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3422
 *     cdef Py_ssize_t stride, ptr, pointer, i
 *     cdef ndarray ret
 *     if a.ndim <= 2:             # <<<<<<<<<<<<<<
 *         ret = ndarray((1,), dtype=numpy.uintp)
 *         ret.fill(a.data.ptr)
 */
  }

  /* "cupy/core/core.pyx":3427
 *         return ret
 *     else:
 *         return _get_all_addresses(a.data.ptr, a.shape[:-2], a.strides[:-2])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3427, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_t_2, 0, -2L, NULL, NULL, &__pyx_slice__177, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3427, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = __pyx_convert_vector_from_py_size_t(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3427, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3427, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_t_4, 0, -2L, NULL, NULL, &__pyx_slice__178, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3427, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_convert_vector_from_py_size_t(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3427, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__get_all_addresses(__pyx_v_a->data->ptr, __pyx_t_5, __pyx_t_6, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3427, __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":3407
 * 
 * 
 * cdef ndarray _mat_ptrs(ndarray a):             # <<<<<<<<<<<<<<
 *     """Creates an array of pointers to matrices
 *     Args:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core._mat_ptrs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3430
 * 
 * 
 * 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_101matmul(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_matmul(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_matmul *__pyx_optional_args) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_n;
  Py_ssize_t __pyx_v_m;
  Py_ssize_t __pyx_v_ka;
  Py_ssize_t __pyx_v_kb;
  Py_ssize_t __pyx_v_batchCount;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ap = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_bp = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_outp = 0;
  PyObject *__pyx_v_orig_a_shape = NULL;
  PyObject *__pyx_v_orig_b_shape = NULL;
  PyObject *__pyx_v_ret_dtype = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_a_part_outshape = NULL;
  PyObject *__pyx_v_b_part_outshape = NULL;
  PyObject *__pyx_v_ldout = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_view = NULL;
  PyObject *__pyx_v_broatcast_pre_shape = NULL;
  PyObject *__pyx_v_out_shape = NULL;
  PyObject *__pyx_v_a_strides = NULL;
  PyObject *__pyx_v_a_shape = NULL;
  PyObject *__pyx_v_b_strides = NULL;
  PyObject *__pyx_v_b_shape = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out_view = NULL;
  PyObject *__pyx_v_out_view_shape = NULL;
  PyObject *__pyx_v_out_view_strides = NULL;
  PyObject *__pyx_v_lda = NULL;
  PyObject *__pyx_v_ldb = NULL;
  PyObject *__pyx_v_la = NULL;
  PyObject *__pyx_v_lb = NULL;
  PyObject *__pyx_v_la_ = NULL;
  PyObject *__pyx_v_lb_ = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = NULL;
  PyObject *__pyx_v__ = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  std::vector<Py_ssize_t>  __pyx_t_10;
  std::vector<Py_ssize_t>  __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray __pyx_t_13;
  Py_ssize_t __pyx_t_14;
  size_t __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  Py_ssize_t __pyx_t_18;
  PyObject *(*__pyx_t_19)(PyObject *);
  PyObject *__pyx_t_20 = NULL;
  PyObject *(*__pyx_t_21)(PyObject *);
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  __Pyx_RefNannySetupContext("matmul", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_out = __pyx_optional_args->out;
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF((PyObject *)__pyx_v_b);
  __Pyx_INCREF((PyObject *)__pyx_v_out);

  /* "cupy/core/core.pyx":3461
 *     # ToDo: remove python object out_shape
 *     # ToDo: remove python object .reshape
 *     if out is not None:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError('The out array as input is currently not '
 *                                   'supported')
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_out) != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3462
 *     # ToDo: remove python object .reshape
 *     if out is not None:
 *         raise NotImplementedError('The out array as input is currently not '             # <<<<<<<<<<<<<<
 *                                   'supported')
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__179, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3462, __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, 3462, __pyx_L1_error)

    /* "cupy/core/core.pyx":3461
 *     # ToDo: remove python object out_shape
 *     # ToDo: remove python object .reshape
 *     if out is not None:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError('The out array as input is currently not '
 *                                   'supported')
 */
  }

  /* "cupy/core/core.pyx":3469
 *     cdef ndarray ap, bp, outp
 * 
 *     orig_a_shape = a.shape             # <<<<<<<<<<<<<<
 *     orig_b_shape = b.shape
 *     if len(orig_a_shape) == 0 or len(orig_b_shape) == 0:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3469, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_orig_a_shape = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3470
 * 
 *     orig_a_shape = a.shape
 *     orig_b_shape = b.shape             # <<<<<<<<<<<<<<
 *     if len(orig_a_shape) == 0 or len(orig_b_shape) == 0:
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3470, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_orig_b_shape = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3471
 *     orig_a_shape = a.shape
 *     orig_b_shape = b.shape
 *     if len(orig_a_shape) == 0 or len(orig_b_shape) == 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')
 * 
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_orig_a_shape); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 3471, __pyx_L1_error)
  __pyx_t_1 = ((__pyx_t_4 == 0) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_4 = PyObject_Length(__pyx_v_orig_b_shape); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 3471, __pyx_L1_error)
  __pyx_t_1 = ((__pyx_t_4 == 0) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3472
 *     orig_b_shape = b.shape
 *     if len(orig_a_shape) == 0 or len(orig_b_shape) == 0:
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')             # <<<<<<<<<<<<<<
 * 
 *     ret_dtype = numpy.result_type(a.dtype, b.dtype)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__180, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3472, __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, 3472, __pyx_L1_error)

    /* "cupy/core/core.pyx":3471
 *     orig_a_shape = a.shape
 *     orig_b_shape = b.shape
 *     if len(orig_a_shape) == 0 or len(orig_b_shape) == 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')
 * 
 */
  }

  /* "cupy/core/core.pyx":3474
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')
 * 
 *     ret_dtype = numpy.result_type(a.dtype, b.dtype)             # <<<<<<<<<<<<<<
 *     dtype = numpy.find_common_type((ret_dtype, 'f'), ())
 * 
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3474, __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, 3474, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_a->dtype, __pyx_v_b->dtype};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3474, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_a->dtype, __pyx_v_b->dtype};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3474, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3474, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(__pyx_v_a->dtype);
    __Pyx_GIVEREF(__pyx_v_a->dtype);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_a->dtype);
    __Pyx_INCREF(__pyx_v_b->dtype);
    __Pyx_GIVEREF(__pyx_v_b->dtype);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_b->dtype);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3474, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_ret_dtype = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3475
 * 
 *     ret_dtype = numpy.result_type(a.dtype, b.dtype)
 *     dtype = numpy.find_common_type((ret_dtype, 'f'), ())             # <<<<<<<<<<<<<<
 * 
 *     a = a.astype(dtype, copy=False)
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3475, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_find_common_type); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3475, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3475, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_ret_dtype);
  __Pyx_GIVEREF(__pyx_v_ret_dtype);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_ret_dtype);
  __Pyx_INCREF(__pyx_n_s_f);
  __Pyx_GIVEREF(__pyx_n_s_f);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_f);
  __pyx_t_5 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_6, __pyx_empty_tuple};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3475, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_6, __pyx_empty_tuple};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3475, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3475, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_7, __pyx_t_6);
    __Pyx_INCREF(__pyx_empty_tuple);
    __Pyx_GIVEREF(__pyx_empty_tuple);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_7, __pyx_empty_tuple);
    __pyx_t_6 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3475, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_dtype = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3477
 *     dtype = numpy.find_common_type((ret_dtype, 'f'), ())
 * 
 *     a = a.astype(dtype, copy=False)             # <<<<<<<<<<<<<<
 *     b = b.astype(dtype, copy=False)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_astype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_v_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_dtype);
  __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 3477, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3477, __pyx_L1_error)
  __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6));
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3478
 * 
 *     a = a.astype(dtype, copy=False)
 *     b = b.astype(dtype, copy=False)             # <<<<<<<<<<<<<<
 * 
 *     if a.ndim == 1:
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_astype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_v_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_dtype);
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 3478, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3478, __pyx_L1_error)
  __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3480
 *     b = b.astype(dtype, copy=False)
 * 
 *     if a.ndim == 1:             # <<<<<<<<<<<<<<
 *         a = a.reshape(1, len(a))
 *         a_part_outshape = ()
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3480, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3481
 * 
 *     if a.ndim == 1:
 *         a = a.reshape(1, len(a))             # <<<<<<<<<<<<<<
 *         a_part_outshape = ()
 *     else:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3481, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_a)); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 3481, __pyx_L1_error)
    __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3481, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_6 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_int_1, __pyx_t_9};
      __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3481, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_int_1, __pyx_t_9};
      __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3481, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3481, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_int_1);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3481, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3481, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8));
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":3482
 *     if a.ndim == 1:
 *         a = a.reshape(1, len(a))
 *         a_part_outshape = ()             # <<<<<<<<<<<<<<
 *     else:
 *         a_part_outshape = (a.shape[-2],)
 */
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_v_a_part_outshape = __pyx_empty_tuple;

    /* "cupy/core/core.pyx":3480
 *     b = b.astype(dtype, copy=False)
 * 
 *     if a.ndim == 1:             # <<<<<<<<<<<<<<
 *         a = a.reshape(1, len(a))
 *         a_part_outshape = ()
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":3484
 *         a_part_outshape = ()
 *     else:
 *         a_part_outshape = (a.shape[-2],)             # <<<<<<<<<<<<<<
 *     if b.ndim == 1:
 *         b = b.reshape(len(b), 1)
 */
  /*else*/ {
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3484, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_8, -2L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3484, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3484, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_v_a_part_outshape = ((PyObject*)__pyx_t_8);
    __pyx_t_8 = 0;
  }
  __pyx_L7:;

  /* "cupy/core/core.pyx":3485
 *     else:
 *         a_part_outshape = (a.shape[-2],)
 *     if b.ndim == 1:             # <<<<<<<<<<<<<<
 *         b = b.reshape(len(b), 1)
 *         b_part_outshape = ()
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_8, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3485, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3486
 *         a_part_outshape = (a.shape[-2],)
 *     if b.ndim == 1:
 *         b = b.reshape(len(b), 1)             # <<<<<<<<<<<<<<
 *         b_part_outshape = ()
 *         ldout = 1
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3486, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_b)); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 3486, __pyx_L1_error)
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3486, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_5, __pyx_int_1};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3486, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_5, __pyx_int_1};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3486, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3486, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_9) {
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_t_5);
      __Pyx_INCREF(__pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_int_1);
      __pyx_t_5 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3486, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3486, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3487
 *     if b.ndim == 1:
 *         b = b.reshape(len(b), 1)
 *         b_part_outshape = ()             # <<<<<<<<<<<<<<
 *         ldout = 1
 *     else:
 */
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_v_b_part_outshape = __pyx_empty_tuple;

    /* "cupy/core/core.pyx":3488
 *         b = b.reshape(len(b), 1)
 *         b_part_outshape = ()
 *         ldout = 1             # <<<<<<<<<<<<<<
 *     else:
 *         b_part_outshape = b.shape[-1:]
 */
    __Pyx_INCREF(__pyx_int_1);
    __pyx_v_ldout = __pyx_int_1;

    /* "cupy/core/core.pyx":3485
 *     else:
 *         a_part_outshape = (a.shape[-2],)
 *     if b.ndim == 1:             # <<<<<<<<<<<<<<
 *         b = b.reshape(len(b), 1)
 *         b_part_outshape = ()
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":3490
 *         ldout = 1
 *     else:
 *         b_part_outshape = b.shape[-1:]             # <<<<<<<<<<<<<<
 *         ldout = b.shape[-1]
 * 
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3490, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = __Pyx_PyObject_GetSlice(__pyx_t_3, -1L, 0, NULL, NULL, &__pyx_slice__181, 1, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3490, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_b_part_outshape = __pyx_t_8;
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":3491
 *     else:
 *         b_part_outshape = b.shape[-1:]
 *         ldout = b.shape[-1]             # <<<<<<<<<<<<<<
 * 
 *     # expand dims
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3491, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_8, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3491, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_v_ldout = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_L8:;

  /* "cupy/core/core.pyx":3494
 * 
 *     # expand dims
 *     if a.ndim < b.ndim:             # <<<<<<<<<<<<<<
 *         view = a.view()
 *         view._set_shape_and_strides(
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3494, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3494, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = PyObject_RichCompare(__pyx_t_3, __pyx_t_8, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3494, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3494, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3495
 *     # expand dims
 *     if a.ndim < b.ndim:
 *         view = a.view()             # <<<<<<<<<<<<<<
 *         view._set_shape_and_strides(
 *             (1,) * (b.ndim - a.ndim) + a.shape,
 */
    __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3495, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_view = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":3497
 *         view = a.view()
 *         view._set_shape_and_strides(
 *             (1,) * (b.ndim - a.ndim) + a.shape,             # <<<<<<<<<<<<<<
 *             (0,) * (b.ndim - a.ndim) + a.strides)
 *         a = view
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3497, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3497, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3497, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyNumber_Multiply(__pyx_tuple__182, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3497, __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, 3497, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyNumber_Add(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3497, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_10 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3497, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":3498
 *         view._set_shape_and_strides(
 *             (1,) * (b.ndim - a.ndim) + a.shape,
 *             (0,) * (b.ndim - a.ndim) + a.strides)             # <<<<<<<<<<<<<<
 *         a = view
 *     elif a.ndim > b.ndim:
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3498, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3498, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = PyNumber_Subtract(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3498, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__183, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3498, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3498, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = PyNumber_Add(__pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3498, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_11 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3498, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":3496
 *     if a.ndim < b.ndim:
 *         view = a.view()
 *         view._set_shape_and_strides(             # <<<<<<<<<<<<<<
 *             (1,) * (b.ndim - a.ndim) + a.shape,
 *             (0,) * (b.ndim - a.ndim) + a.strides)
 */
    __pyx_t_6 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_t_10, __pyx_t_11, 0, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3496, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":3499
 *             (1,) * (b.ndim - a.ndim) + a.shape,
 *             (0,) * (b.ndim - a.ndim) + a.strides)
 *         a = view             # <<<<<<<<<<<<<<
 *     elif a.ndim > b.ndim:
 *         view = b.view()
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_view));
    __Pyx_DECREF_SET(__pyx_v_a, __pyx_v_view);

    /* "cupy/core/core.pyx":3494
 * 
 *     # expand dims
 *     if a.ndim < b.ndim:             # <<<<<<<<<<<<<<
 *         view = a.view()
 *         view._set_shape_and_strides(
 */
    goto __pyx_L9;
  }

  /* "cupy/core/core.pyx":3500
 *             (0,) * (b.ndim - a.ndim) + a.strides)
 *         a = view
 *     elif a.ndim > b.ndim:             # <<<<<<<<<<<<<<
 *         view = b.view()
 *         view._set_shape_and_strides(
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_6, __pyx_t_8, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3500, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3500, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3501
 *         a = view
 *     elif a.ndim > b.ndim:
 *         view = b.view()             # <<<<<<<<<<<<<<
 *         view._set_shape_and_strides(
 *             (1,) * (a.ndim - b.ndim) + b.shape,
 */
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_b->__pyx_vtab)->view(__pyx_v_b, 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3501, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_view = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3503
 *         view = b.view()
 *         view._set_shape_and_strides(
 *             (1,) * (a.ndim - b.ndim) + b.shape,             # <<<<<<<<<<<<<<
 *             (0,) * (a.ndim - b.ndim) + b.strides)
 *         b = view
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = PyNumber_Subtract(__pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyNumber_Multiply(__pyx_tuple__184, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyNumber_Add(__pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_11 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3503, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3504
 *         view._set_shape_and_strides(
 *             (1,) * (a.ndim - b.ndim) + b.shape,
 *             (0,) * (a.ndim - b.ndim) + b.strides)             # <<<<<<<<<<<<<<
 *         b = view
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = PyNumber_Subtract(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_Multiply(__pyx_tuple__185, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_strides); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = PyNumber_Add(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_10 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3504, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3502
 *     elif a.ndim > b.ndim:
 *         view = b.view()
 *         view._set_shape_and_strides(             # <<<<<<<<<<<<<<
 *             (1,) * (a.ndim - b.ndim) + b.shape,
 *             (0,) * (a.ndim - b.ndim) + b.strides)
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_t_11, __pyx_t_10, 0, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3502, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3505
 *             (1,) * (a.ndim - b.ndim) + b.shape,
 *             (0,) * (a.ndim - b.ndim) + b.strides)
 *         b = view             # <<<<<<<<<<<<<<
 * 
 *     broatcast_pre_shape = numpy.maximum(a.shape[:-2], b.shape[:-2])
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_view));
    __Pyx_DECREF_SET(__pyx_v_b, __pyx_v_view);

    /* "cupy/core/core.pyx":3500
 *             (0,) * (b.ndim - a.ndim) + a.strides)
 *         a = view
 *     elif a.ndim > b.ndim:             # <<<<<<<<<<<<<<
 *         view = b.view()
 *         view._set_shape_and_strides(
 */
  }
  __pyx_L9:;

  /* "cupy/core/core.pyx":3507
 *         b = view
 * 
 *     broatcast_pre_shape = numpy.maximum(a.shape[:-2], b.shape[:-2])             # <<<<<<<<<<<<<<
 * 
 *     out_shape = (*broatcast_pre_shape, *a_part_outshape, *b_part_outshape)
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_maximum); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_t_8, 0, -2L, NULL, NULL, &__pyx_slice__186, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __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, 3507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyObject_GetSlice(__pyx_t_8, 0, -2L, NULL, NULL, &__pyx_slice__187, 0, 1, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_5, __pyx_t_9};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3507, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_5, __pyx_t_9};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3507, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  {
    __pyx_t_12 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3507, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_7, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_7, __pyx_t_9);
    __pyx_t_5 = 0;
    __pyx_t_9 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3507, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_broatcast_pre_shape = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3509
 *     broatcast_pre_shape = numpy.maximum(a.shape[:-2], b.shape[:-2])
 * 
 *     out_shape = (*broatcast_pre_shape, *a_part_outshape, *b_part_outshape)             # <<<<<<<<<<<<<<
 * 
 *     a = ascontiguousarray(a, dtype=dtype)
 */
  __pyx_t_3 = PySequence_List(__pyx_v_broatcast_pre_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_PyList_Extend(__pyx_t_3, __pyx_v_a_part_outshape) < 0) __PYX_ERR(0, 3509, __pyx_L1_error)
  if (__Pyx_PyList_Extend(__pyx_t_3, __pyx_v_b_part_outshape) < 0) __PYX_ERR(0, 3509, __pyx_L1_error)
  {
    PyObject *__pyx_temp = PyList_AsTuple(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_3 = __pyx_temp; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3509, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  __pyx_v_out_shape = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3511
 *     out_shape = (*broatcast_pre_shape, *a_part_outshape, *b_part_outshape)
 * 
 *     a = ascontiguousarray(a, dtype=dtype)             # <<<<<<<<<<<<<<
 *     b = ascontiguousarray(b, dtype=dtype)
 * 
 */
  __pyx_t_13.__pyx_n = 1;
  __pyx_t_13.dtype = __pyx_v_dtype;
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_ascontiguousarray(__pyx_v_a, 0, &__pyx_t_13)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3511, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3512
 * 
 *     a = ascontiguousarray(a, dtype=dtype)
 *     b = ascontiguousarray(b, dtype=dtype)             # <<<<<<<<<<<<<<
 * 
 *     # broadcast
 */
  __pyx_t_13.__pyx_n = 1;
  __pyx_t_13.dtype = __pyx_v_dtype;
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_ascontiguousarray(__pyx_v_b, 0, &__pyx_t_13)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3512, __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":3515
 * 
 *     # broadcast
 *     a_strides = list(a.strides)             # <<<<<<<<<<<<<<
 *     a_shape = list(a.shape)
 *     b_strides = list(b.strides)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_a_strides = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3516
 *     # broadcast
 *     a_strides = list(a.strides)
 *     a_shape = list(a.shape)             # <<<<<<<<<<<<<<
 *     b_strides = list(b.strides)
 *     b_shape = list(b.shape)
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3516, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = PySequence_List(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3516, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_a_shape = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3517
 *     a_strides = list(a.strides)
 *     a_shape = list(a.shape)
 *     b_strides = list(b.strides)             # <<<<<<<<<<<<<<
 *     b_shape = list(b.shape)
 *     for i in range(len(a_strides) - 2):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_strides); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_b_strides = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3518
 *     a_shape = list(a.shape)
 *     b_strides = list(b.strides)
 *     b_shape = list(b.shape)             # <<<<<<<<<<<<<<
 *     for i in range(len(a_strides) - 2):
 *         if a_shape[i] == 1 and broatcast_pre_shape[i] > 1:
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = PySequence_List(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_b_shape = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3519
 *     b_strides = list(b.strides)
 *     b_shape = list(b.shape)
 *     for i in range(len(a_strides) - 2):             # <<<<<<<<<<<<<<
 *         if a_shape[i] == 1 and broatcast_pre_shape[i] > 1:
 *             a_strides[i] = 0
 */
  __pyx_t_4 = PyList_GET_SIZE(__pyx_v_a_strides); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 3519, __pyx_L1_error)
  __pyx_t_14 = (__pyx_t_4 - 2);
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_14; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "cupy/core/core.pyx":3520
 *     b_shape = list(b.shape)
 *     for i in range(len(a_strides) - 2):
 *         if a_shape[i] == 1 and broatcast_pre_shape[i] > 1:             # <<<<<<<<<<<<<<
 *             a_strides[i] = 0
 *             a_shape[i] = broatcast_pre_shape[i]
 */
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_a_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3520, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3520, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3520, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 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_broatcast_pre_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3520, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_6, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3520, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3520, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __pyx_t_1;
    __pyx_L13_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":3521
 *     for i in range(len(a_strides) - 2):
 *         if a_shape[i] == 1 and broatcast_pre_shape[i] > 1:
 *             a_strides[i] = 0             # <<<<<<<<<<<<<<
 *             a_shape[i] = broatcast_pre_shape[i]
 *     for i in range(len(b_strides) - 2):
 */
      if (unlikely(__Pyx_SetItemInt(__pyx_v_a_strides, __pyx_v_i, __pyx_int_0, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(0, 3521, __pyx_L1_error)

      /* "cupy/core/core.pyx":3522
 *         if a_shape[i] == 1 and broatcast_pre_shape[i] > 1:
 *             a_strides[i] = 0
 *             a_shape[i] = broatcast_pre_shape[i]             # <<<<<<<<<<<<<<
 *     for i in range(len(b_strides) - 2):
 *         if b_shape[i] == 1 and broatcast_pre_shape[i] > 1:
 */
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_broatcast_pre_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3522, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (unlikely(__Pyx_SetItemInt(__pyx_v_a_shape, __pyx_v_i, __pyx_t_3, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(0, 3522, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":3520
 *     b_shape = list(b.shape)
 *     for i in range(len(a_strides) - 2):
 *         if a_shape[i] == 1 and broatcast_pre_shape[i] > 1:             # <<<<<<<<<<<<<<
 *             a_strides[i] = 0
 *             a_shape[i] = broatcast_pre_shape[i]
 */
    }
  }

  /* "cupy/core/core.pyx":3523
 *             a_strides[i] = 0
 *             a_shape[i] = broatcast_pre_shape[i]
 *     for i in range(len(b_strides) - 2):             # <<<<<<<<<<<<<<
 *         if b_shape[i] == 1 and broatcast_pre_shape[i] > 1:
 *             b_strides[i] = 0
 */
  __pyx_t_14 = PyList_GET_SIZE(__pyx_v_b_strides); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(0, 3523, __pyx_L1_error)
  __pyx_t_4 = (__pyx_t_14 - 2);
  for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_4; __pyx_t_14+=1) {
    __pyx_v_i = __pyx_t_14;

    /* "cupy/core/core.pyx":3524
 *             a_shape[i] = broatcast_pre_shape[i]
 *     for i in range(len(b_strides) - 2):
 *         if b_shape[i] == 1 and broatcast_pre_shape[i] > 1:             # <<<<<<<<<<<<<<
 *             b_strides[i] = 0
 *             b_shape[i] = broatcast_pre_shape[i]
 */
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_b_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3524, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3524, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3524, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L18_bool_binop_done;
    }
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_broatcast_pre_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3524, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_6, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3524, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3524, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __pyx_t_1;
    __pyx_L18_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":3525
 *     for i in range(len(b_strides) - 2):
 *         if b_shape[i] == 1 and broatcast_pre_shape[i] > 1:
 *             b_strides[i] = 0             # <<<<<<<<<<<<<<
 *             b_shape[i] = broatcast_pre_shape[i]
 * 
 */
      if (unlikely(__Pyx_SetItemInt(__pyx_v_b_strides, __pyx_v_i, __pyx_int_0, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(0, 3525, __pyx_L1_error)

      /* "cupy/core/core.pyx":3526
 *         if b_shape[i] == 1 and broatcast_pre_shape[i] > 1:
 *             b_strides[i] = 0
 *             b_shape[i] = broatcast_pre_shape[i]             # <<<<<<<<<<<<<<
 * 
 *     view = a.view()
 */
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_broatcast_pre_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3526, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (unlikely(__Pyx_SetItemInt(__pyx_v_b_shape, __pyx_v_i, __pyx_t_3, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(0, 3526, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":3524
 *             a_shape[i] = broatcast_pre_shape[i]
 *     for i in range(len(b_strides) - 2):
 *         if b_shape[i] == 1 and broatcast_pre_shape[i] > 1:             # <<<<<<<<<<<<<<
 *             b_strides[i] = 0
 *             b_shape[i] = broatcast_pre_shape[i]
 */
    }
  }

  /* "cupy/core/core.pyx":3528
 *             b_shape[i] = broatcast_pre_shape[i]
 * 
 *     view = a.view()             # <<<<<<<<<<<<<<
 *     view._set_shape_and_strides(a_shape, a_strides)
 *     a = view
 */
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_XDECREF_SET(__pyx_v_view, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3529
 * 
 *     view = a.view()
 *     view._set_shape_and_strides(a_shape, a_strides)             # <<<<<<<<<<<<<<
 *     a = view
 *     view = b.view()
 */
  __pyx_t_10 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_a_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3529, __pyx_L1_error)
  __pyx_t_11 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_a_strides); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3529, __pyx_L1_error)
  __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_t_10, __pyx_t_11, 0, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3529, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3530
 *     view = a.view()
 *     view._set_shape_and_strides(a_shape, a_strides)
 *     a = view             # <<<<<<<<<<<<<<
 *     view = b.view()
 *     view._set_shape_and_strides(b_shape, b_strides)
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_view));
  __Pyx_DECREF_SET(__pyx_v_a, __pyx_v_view);

  /* "cupy/core/core.pyx":3531
 *     view._set_shape_and_strides(a_shape, a_strides)
 *     a = view
 *     view = b.view()             # <<<<<<<<<<<<<<
 *     view._set_shape_and_strides(b_shape, b_strides)
 *     b = view
 */
  __pyx_t_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, 3531, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF_SET(__pyx_v_view, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3532
 *     a = view
 *     view = b.view()
 *     view._set_shape_and_strides(b_shape, b_strides)             # <<<<<<<<<<<<<<
 *     b = view
 * 
 */
  __pyx_t_11 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_b_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3532, __pyx_L1_error)
  __pyx_t_10 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_b_strides); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3532, __pyx_L1_error)
  __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_t_11, __pyx_t_10, 0, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3533
 *     view = b.view()
 *     view._set_shape_and_strides(b_shape, b_strides)
 *     b = view             # <<<<<<<<<<<<<<
 * 
 *     out = ndarray(out_shape, dtype=dtype)
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_view));
  __Pyx_DECREF_SET(__pyx_v_b, __pyx_v_view);

  /* "cupy/core/core.pyx":3535
 *     b = view
 * 
 *     out = ndarray(out_shape, dtype=dtype)             # <<<<<<<<<<<<<<
 *     out.data.memset_async(0, out.nbytes)
 * 
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_out_shape);
  __Pyx_GIVEREF(__pyx_v_out_shape);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_out_shape);
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 3535, __pyx_L1_error)
  __pyx_t_12 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_12));
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":3536
 * 
 *     out = ndarray(out_shape, dtype=dtype)
 *     out.data.memset_async(0, out.nbytes)             # <<<<<<<<<<<<<<
 * 
 *     out_view = out.view()
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_15 = __Pyx_PyInt_As_size_t(__pyx_t_12); if (unlikely((__pyx_t_15 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3536, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_out->data->__pyx_vtab)->memset_async(__pyx_v_out->data, 0, __pyx_t_15, 0, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":3538
 *     out.data.memset_async(0, out.nbytes)
 * 
 *     out_view = out.view()             # <<<<<<<<<<<<<<
 *     out_view_shape = out.shape
 *     out_view_strides = out.strides
 */
  __pyx_t_12 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_out->__pyx_vtab)->view(__pyx_v_out, 0, NULL)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_v_out_view = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":3539
 * 
 *     out_view = out.view()
 *     out_view_shape = out.shape             # <<<<<<<<<<<<<<
 *     out_view_strides = out.strides
 *     if a_part_outshape == ():
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_v_out_view_shape = __pyx_t_12;
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":3540
 *     out_view = out.view()
 *     out_view_shape = out.shape
 *     out_view_strides = out.strides             # <<<<<<<<<<<<<<
 *     if a_part_outshape == ():
 *         out_view_shape += (1,)
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_strides); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3540, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_v_out_view_strides = __pyx_t_12;
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":3541
 *     out_view_shape = out.shape
 *     out_view_strides = out.strides
 *     if a_part_outshape == ():             # <<<<<<<<<<<<<<
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 */
  __pyx_t_12 = PyObject_RichCompare(__pyx_v_a_part_outshape, __pyx_empty_tuple, Py_EQ); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3541, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3541, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3542
 *     out_view_strides = out.strides
 *     if a_part_outshape == ():
 *         out_view_shape += (1,)             # <<<<<<<<<<<<<<
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():
 */
    __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_v_out_view_shape, __pyx_tuple__188); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3542, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF_SET(__pyx_v_out_view_shape, __pyx_t_12);
    __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":3543
 *     if a_part_outshape == ():
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)             # <<<<<<<<<<<<<<
 *     if b_part_outshape == ():
 *         out_view_shape += (1,)
 */
    __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_v_out_view_strides, __pyx_tuple__189); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF_SET(__pyx_v_out_view_strides, __pyx_t_12);
    __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":3541
 *     out_view_shape = out.shape
 *     out_view_strides = out.strides
 *     if a_part_outshape == ():             # <<<<<<<<<<<<<<
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 */
  }

  /* "cupy/core/core.pyx":3544
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():             # <<<<<<<<<<<<<<
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 */
  __pyx_t_12 = PyObject_RichCompare(__pyx_v_b_part_outshape, __pyx_empty_tuple, Py_EQ); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3544, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3544, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3545
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():
 *         out_view_shape += (1,)             # <<<<<<<<<<<<<<
 *         out_view_strides += (0,)
 * 
 */
    __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_v_out_view_shape, __pyx_tuple__190); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3545, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF_SET(__pyx_v_out_view_shape, __pyx_t_12);
    __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":3546
 *     if b_part_outshape == ():
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)             # <<<<<<<<<<<<<<
 * 
 *     out_view._set_shape_and_strides(out_view_shape, out_view_strides)
 */
    __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_v_out_view_strides, __pyx_tuple__191); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3546, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF_SET(__pyx_v_out_view_strides, __pyx_t_12);
    __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":3544
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():             # <<<<<<<<<<<<<<
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 */
  }

  /* "cupy/core/core.pyx":3548
 *         out_view_strides += (0,)
 * 
 *     out_view._set_shape_and_strides(out_view_shape, out_view_strides)             # <<<<<<<<<<<<<<
 * 
 *     # (A B)^T = B^T A^T
 */
  __pyx_t_10 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_out_view_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3548, __pyx_L1_error)
  __pyx_t_11 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_out_view_strides); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3548, __pyx_L1_error)
  __pyx_t_12 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_out_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_out_view, __pyx_t_10, __pyx_t_11, 0, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3548, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":3551
 * 
 *     # (A B)^T = B^T A^T
 *     a, b = b, a             # <<<<<<<<<<<<<<
 * 
 *     lda = a.shape[-1]
 */
  __pyx_t_16 = ((PyObject *)__pyx_v_b);
  __pyx_t_17 = ((PyObject *)__pyx_v_a);
  __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_16);
  __pyx_t_16 = 0;
  __pyx_v_b = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_17);
  __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":3553
 *     a, b = b, a
 * 
 *     lda = a.shape[-1]             # <<<<<<<<<<<<<<
 *     ldb = b.shape[-1]
 * 
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3553, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_12, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3553, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_v_lda = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3554
 * 
 *     lda = a.shape[-1]
 *     ldb = b.shape[-1]             # <<<<<<<<<<<<<<
 * 
 *     *la, ka, n = a.shape
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3554, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_12 = __Pyx_GetItemInt(__pyx_t_6, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3554, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_ldb = __pyx_t_12;
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":3556
 *     ldb = b.shape[-1]
 * 
 *     *la, ka, n = a.shape             # <<<<<<<<<<<<<<
 *     *lb, m, kb = b.shape
 * 
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_6 = PySequence_List(__pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_4 = PyList_GET_SIZE(__pyx_t_6);
  if (unlikely(__pyx_t_4 < 2)) {
    __Pyx_RaiseNeedMoreValuesError(0+__pyx_t_4); __PYX_ERR(0, 3556, __pyx_L1_error)
  }
  #if CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_4-1); 
  ((PyVarObject*)__pyx_t_6)->ob_size--;
  #else
  __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_4-1); 
  #endif
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3556, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_9 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_4-2); 
  ((PyVarObject*)__pyx_t_6)->ob_size--;
  #else
  __pyx_t_9 = PySequence_ITEM(__pyx_t_6, __pyx_t_4-2); 
  #endif
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_18 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_18 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3556, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  #if !CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_5 = PySequence_GetSlice(__pyx_t_6, 0, __pyx_t_4-2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6);
  __pyx_t_6 = __pyx_t_5; __pyx_t_5 = NULL;
  #else

  #endif
  __pyx_v_la = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_v_ka = __pyx_t_18;
  __pyx_v_n = __pyx_t_14;

  /* "cupy/core/core.pyx":3557
 * 
 *     *la, ka, n = a.shape
 *     *lb, m, kb = b.shape             # <<<<<<<<<<<<<<
 * 
 *     if ka != kb:
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_3 = PySequence_List(__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_14 = PyList_GET_SIZE(__pyx_t_3);
  if (unlikely(__pyx_t_14 < 2)) {
    __Pyx_RaiseNeedMoreValuesError(0+__pyx_t_14); __PYX_ERR(0, 3557, __pyx_L1_error)
  }
  #if CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_14-1); 
  ((PyVarObject*)__pyx_t_3)->ob_size--;
  #else
  __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_14-1); 
  #endif
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_18 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_18 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3557, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_14-2); 
  ((PyVarObject*)__pyx_t_3)->ob_size--;
  #else
  __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_14-2); 
  #endif
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3557, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  #if !CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_5 = PySequence_GetSlice(__pyx_t_3, 0, __pyx_t_14-2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3);
  __pyx_t_3 = __pyx_t_5; __pyx_t_5 = NULL;
  #else

  #endif
  __pyx_v_lb = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_m = __pyx_t_4;
  __pyx_v_kb = __pyx_t_18;

  /* "cupy/core/core.pyx":3559
 *     *lb, m, kb = b.shape
 * 
 *     if ka != kb:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'shapes ({}) and ({}) not aligned'.format(
 */
  __pyx_t_2 = ((__pyx_v_ka != __pyx_v_kb) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3561
 *     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_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_shapes_and_not_aligned, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3561, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);

    /* "cupy/core/core.pyx":3562
 *         raise ValueError(
 *             'shapes ({}) and ({}) not aligned'.format(
 *                 ','.join([str(_) for _ in orig_a_shape]),             # <<<<<<<<<<<<<<
 *                 ','.join([str(_) for _ in orig_b_shape])))
 *     for la_, lb_ in zip(la, lb):
 */
    __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3562, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (likely(PyList_CheckExact(__pyx_v_orig_a_shape)) || PyTuple_CheckExact(__pyx_v_orig_a_shape)) {
      __pyx_t_3 = __pyx_v_orig_a_shape; __Pyx_INCREF(__pyx_t_3); __pyx_t_18 = 0;
      __pyx_t_19 = NULL;
    } else {
      __pyx_t_18 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_orig_a_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3562, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_19 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 3562, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_19)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_18 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_18); __Pyx_INCREF(__pyx_t_5); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 3562, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3562, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        } else {
          if (__pyx_t_18 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_18); __Pyx_INCREF(__pyx_t_5); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 3562, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3562, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        }
      } else {
        __pyx_t_5 = __pyx_t_19(__pyx_t_3);
        if (unlikely(!__pyx_t_5)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 3562, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3562, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v__);
      __Pyx_GIVEREF(__pyx_v__);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v__);
      __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3562, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 3562, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyString_Join(__pyx_kp_s__72, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3562, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":3563
 *             'shapes ({}) and ({}) not aligned'.format(
 *                 ','.join([str(_) for _ in orig_a_shape]),
 *                 ','.join([str(_) for _ in orig_b_shape])))             # <<<<<<<<<<<<<<
 *     for la_, lb_ in zip(la, lb):
 *         if not (la_ == lb_ or la_ == 1 or lb_ == 1):
 */
    __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (likely(PyList_CheckExact(__pyx_v_orig_b_shape)) || PyTuple_CheckExact(__pyx_v_orig_b_shape)) {
      __pyx_t_8 = __pyx_v_orig_b_shape; __Pyx_INCREF(__pyx_t_8); __pyx_t_18 = 0;
      __pyx_t_19 = NULL;
    } else {
      __pyx_t_18 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_orig_b_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3563, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_19 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 3563, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_19)) {
        if (likely(PyList_CheckExact(__pyx_t_8))) {
          if (__pyx_t_18 >= PyList_GET_SIZE(__pyx_t_8)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_18); __Pyx_INCREF(__pyx_t_5); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 3563, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_8, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3563, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        } else {
          if (__pyx_t_18 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_18); __Pyx_INCREF(__pyx_t_5); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 3563, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_8, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3563, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        }
      } else {
        __pyx_t_5 = __pyx_t_19(__pyx_t_8);
        if (unlikely(!__pyx_t_5)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 3563, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3563, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v__);
      __Pyx_GIVEREF(__pyx_v__);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v__);
      __pyx_t_20 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3563, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_20);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_20))) __PYX_ERR(0, 3563, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyString_Join(__pyx_kp_s__72, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_8};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3561, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_8};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3561, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_20 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3561, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_20);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_20, 0+__pyx_t_7, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_20, 1+__pyx_t_7, __pyx_t_8);
      __pyx_t_3 = 0;
      __pyx_t_8 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_20, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3561, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "cupy/core/core.pyx":3560
 * 
 *     if ka != kb:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             'shapes ({}) and ({}) not aligned'.format(
 *                 ','.join([str(_) for _ in orig_a_shape]),
 */
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3560, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3560, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_Raise(__pyx_t_12, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __PYX_ERR(0, 3560, __pyx_L1_error)

    /* "cupy/core/core.pyx":3559
 *     *lb, m, kb = b.shape
 * 
 *     if ka != kb:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'shapes ({}) and ({}) not aligned'.format(
 */
  }

  /* "cupy/core/core.pyx":3564
 *                 ','.join([str(_) for _ in orig_a_shape]),
 *                 ','.join([str(_) for _ in orig_b_shape])))
 *     for la_, lb_ in zip(la, lb):             # <<<<<<<<<<<<<<
 *         if not (la_ == lb_ or la_ == 1 or lb_ == 1):
 *             raise ValueError(
 */
  __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_INCREF(__pyx_v_la);
  __Pyx_GIVEREF(__pyx_v_la);
  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_la);
  __Pyx_INCREF(__pyx_v_lb);
  __Pyx_GIVEREF(__pyx_v_lb);
  PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_v_lb);
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_12, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (likely(PyList_CheckExact(__pyx_t_9)) || PyTuple_CheckExact(__pyx_t_9)) {
    __pyx_t_12 = __pyx_t_9; __Pyx_INCREF(__pyx_t_12); __pyx_t_18 = 0;
    __pyx_t_19 = NULL;
  } else {
    __pyx_t_18 = -1; __pyx_t_12 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_19 = Py_TYPE(__pyx_t_12)->tp_iternext; if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 3564, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  for (;;) {
    if (likely(!__pyx_t_19)) {
      if (likely(PyList_CheckExact(__pyx_t_12))) {
        if (__pyx_t_18 >= PyList_GET_SIZE(__pyx_t_12)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_9 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_18); __Pyx_INCREF(__pyx_t_9); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 3564, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_12, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3564, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      } else {
        if (__pyx_t_18 >= PyTuple_GET_SIZE(__pyx_t_12)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_12, __pyx_t_18); __Pyx_INCREF(__pyx_t_9); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 3564, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_12, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3564, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      }
    } else {
      __pyx_t_9 = __pyx_t_19(__pyx_t_12);
      if (unlikely(!__pyx_t_9)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3564, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_9);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) {
      PyObject* sequence = __pyx_t_9;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 3564, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_20 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_20 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_20);
      __Pyx_INCREF(__pyx_t_8);
      #else
      __pyx_t_20 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3564, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_20);
      __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3564, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      #endif
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_3 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3564, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_21 = Py_TYPE(__pyx_t_3)->tp_iternext;
      index = 0; __pyx_t_20 = __pyx_t_21(__pyx_t_3); if (unlikely(!__pyx_t_20)) goto __pyx_L29_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_20);
      index = 1; __pyx_t_8 = __pyx_t_21(__pyx_t_3); if (unlikely(!__pyx_t_8)) goto __pyx_L29_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_8);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_21(__pyx_t_3), 2) < 0) __PYX_ERR(0, 3564, __pyx_L1_error)
      __pyx_t_21 = NULL;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L30_unpacking_done;
      __pyx_L29_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_21 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 3564, __pyx_L1_error)
      __pyx_L30_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_la_, __pyx_t_20);
    __pyx_t_20 = 0;
    __Pyx_XDECREF_SET(__pyx_v_lb_, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":3565
 *                 ','.join([str(_) for _ in orig_b_shape])))
 *     for la_, lb_ in zip(la, lb):
 *         if not (la_ == lb_ or la_ == 1 or lb_ == 1):             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'operands could not be broadcast together with '
 */
    __pyx_t_9 = PyObject_RichCompare(__pyx_v_la_, __pyx_v_lb_, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3565, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3565, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (!__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L32_bool_binop_done;
    }
    __pyx_t_9 = __Pyx_PyInt_EqObjC(__pyx_v_la_, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3565, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (!__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L32_bool_binop_done;
    }
    __pyx_t_9 = __Pyx_PyInt_EqObjC(__pyx_v_lb_, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3565, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_2 = __pyx_t_1;
    __pyx_L32_bool_binop_done:;
    __pyx_t_1 = ((!__pyx_t_2) != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":3566
 *     for la_, lb_ in zip(la, lb):
 *         if not (la_ == lb_ or la_ == 1 or lb_ == 1):
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'operands could not be broadcast together with '
 *                 'remapped shapes')
 */
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__192, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3566, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 3566, __pyx_L1_error)

      /* "cupy/core/core.pyx":3565
 *                 ','.join([str(_) for _ in orig_b_shape])))
 *     for la_, lb_ in zip(la, lb):
 *         if not (la_ == lb_ or la_ == 1 or lb_ == 1):             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'operands could not be broadcast together with '
 */
    }

    /* "cupy/core/core.pyx":3564
 *                 ','.join([str(_) for _ in orig_a_shape]),
 *                 ','.join([str(_) for _ in orig_b_shape])))
 *     for la_, lb_ in zip(la, lb):             # <<<<<<<<<<<<<<
 *         if not (la_ == lb_ or la_ == 1 or lb_ == 1):
 *             raise ValueError(
 */
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":3570
 *                 'remapped shapes')
 * 
 *     batchCount = 1  # batchCount = numpy.prod(la)             # <<<<<<<<<<<<<<
 *     for i in la:
 *         batchCount *= i
 */
  __pyx_v_batchCount = 1;

  /* "cupy/core/core.pyx":3571
 * 
 *     batchCount = 1  # batchCount = numpy.prod(la)
 *     for i in la:             # <<<<<<<<<<<<<<
 *         batchCount *= i
 * 
 */
  if (likely(PyList_CheckExact(__pyx_v_la)) || PyTuple_CheckExact(__pyx_v_la)) {
    __pyx_t_12 = __pyx_v_la; __Pyx_INCREF(__pyx_t_12); __pyx_t_18 = 0;
    __pyx_t_19 = NULL;
  } else {
    __pyx_t_18 = -1; __pyx_t_12 = PyObject_GetIter(__pyx_v_la); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3571, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_19 = Py_TYPE(__pyx_t_12)->tp_iternext; if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 3571, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_19)) {
      if (likely(PyList_CheckExact(__pyx_t_12))) {
        if (__pyx_t_18 >= PyList_GET_SIZE(__pyx_t_12)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_9 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_18); __Pyx_INCREF(__pyx_t_9); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 3571, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_12, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3571, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      } else {
        if (__pyx_t_18 >= PyTuple_GET_SIZE(__pyx_t_12)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_12, __pyx_t_18); __Pyx_INCREF(__pyx_t_9); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 3571, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_12, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3571, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      }
    } else {
      __pyx_t_9 = __pyx_t_19(__pyx_t_12);
      if (unlikely(!__pyx_t_9)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3571, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_9);
    }
    __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3571, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_v_i = __pyx_t_4;

    /* "cupy/core/core.pyx":3572
 *     batchCount = 1  # batchCount = numpy.prod(la)
 *     for i in la:
 *         batchCount *= i             # <<<<<<<<<<<<<<
 * 
 *     ap = _mat_ptrs(a)
 */
    __pyx_v_batchCount = (__pyx_v_batchCount * __pyx_v_i);

    /* "cupy/core/core.pyx":3571
 * 
 *     batchCount = 1  # batchCount = numpy.prod(la)
 *     for i in la:             # <<<<<<<<<<<<<<
 *         batchCount *= i
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":3574
 *         batchCount *= i
 * 
 *     ap = _mat_ptrs(a)             # <<<<<<<<<<<<<<
 *     bp = _mat_ptrs(b)
 *     outp = _mat_ptrs(out_view)
 */
  __pyx_t_12 = ((PyObject *)__pyx_f_4cupy_4core_4core__mat_ptrs(__pyx_v_a)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3574, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_v_ap = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":3575
 * 
 *     ap = _mat_ptrs(a)
 *     bp = _mat_ptrs(b)             # <<<<<<<<<<<<<<
 *     outp = _mat_ptrs(out_view)
 * 
 */
  __pyx_t_12 = ((PyObject *)__pyx_f_4cupy_4core_4core__mat_ptrs(__pyx_v_b)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3575, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_v_bp = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":3576
 *     ap = _mat_ptrs(a)
 *     bp = _mat_ptrs(b)
 *     outp = _mat_ptrs(out_view)             # <<<<<<<<<<<<<<
 * 
 *     if dtype == numpy.float32:
 */
  __pyx_t_12 = ((PyObject *)__pyx_f_4cupy_4core_4core__mat_ptrs(__pyx_v_out_view)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3576, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_v_outp = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":3578
 *     outp = _mat_ptrs(out_view)
 * 
 *     if dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *         cuda.cublas.sgemmBatched(
 *             cuda.Device().cublas_handle,
 */
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3578, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_float32); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3578, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_9, Py_EQ); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3578, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3578, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3579
 * 
 *     if dtype == numpy.float32:
 *         cuda.cublas.sgemmBatched(             # <<<<<<<<<<<<<<
 *             cuda.Device().cublas_handle,
 *             0,  # transa
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3579, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_cublas); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3579, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_sgemmBatched); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3579, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":3580
 *     if dtype == numpy.float32:
 *         cuda.cublas.sgemmBatched(
 *             cuda.Device().cublas_handle,             # <<<<<<<<<<<<<<
 *             0,  # transa
 *             0,  # transb
 */
    __pyx_t_20 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_20);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_n_s_Device); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
    __pyx_t_20 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_20)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_20);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_20) {
      __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_20); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3580, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
    } else {
      __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3580, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_cublas_handle); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":3583
 *             0,  # transa
 *             0,  # transb
 *             n, m, ka, 1.0,             # <<<<<<<<<<<<<<
 *             ap.data.ptr, lda,
 *             bp.data.ptr, ldb,
 */
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3583, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_20 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3583, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_20);
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_ka); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3583, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);

    /* "cupy/core/core.pyx":3584
 *             0,  # transb
 *             n, m, ka, 1.0,
 *             ap.data.ptr, lda,             # <<<<<<<<<<<<<<
 *             bp.data.ptr, ldb,
 *             0.0, outp.data.ptr, ldout, batchCount)
 */
    __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_ap->data->ptr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3584, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);

    /* "cupy/core/core.pyx":3585
 *             n, m, ka, 1.0,
 *             ap.data.ptr, lda,
 *             bp.data.ptr, ldb,             # <<<<<<<<<<<<<<
 *             0.0, outp.data.ptr, ldout, batchCount)
 *     elif dtype == numpy.float64:
 */
    __pyx_t_22 = __Pyx_PyInt_FromSize_t(__pyx_v_bp->data->ptr); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3585, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);

    /* "cupy/core/core.pyx":3586
 *             ap.data.ptr, lda,
 *             bp.data.ptr, ldb,
 *             0.0, outp.data.ptr, ldout, batchCount)             # <<<<<<<<<<<<<<
 *     elif dtype == numpy.float64:
 *         cuda.cublas.dgemmBatched(
 */
    __pyx_t_23 = __Pyx_PyInt_FromSize_t(__pyx_v_outp->data->ptr); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 3586, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    __pyx_t_24 = PyInt_FromSsize_t(__pyx_v_batchCount); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3586, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_24);
    __pyx_t_25 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_25)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_25);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[16] = {__pyx_t_25, __pyx_t_3, __pyx_int_0, __pyx_int_0, __pyx_t_8, __pyx_t_20, __pyx_t_6, __pyx_float_1_0, __pyx_t_5, __pyx_v_lda, __pyx_t_22, __pyx_v_ldb, __pyx_float_0_0, __pyx_t_23, __pyx_v_ldout, __pyx_t_24};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 15+__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3579, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[16] = {__pyx_t_25, __pyx_t_3, __pyx_int_0, __pyx_int_0, __pyx_t_8, __pyx_t_20, __pyx_t_6, __pyx_float_1_0, __pyx_t_5, __pyx_v_lda, __pyx_t_22, __pyx_v_ldb, __pyx_float_0_0, __pyx_t_23, __pyx_v_ldout, __pyx_t_24};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 15+__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3579, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
    } else
    #endif
    {
      __pyx_t_26 = PyTuple_New(15+__pyx_t_7); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3579, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_26);
      if (__pyx_t_25) {
        __Pyx_GIVEREF(__pyx_t_25); PyTuple_SET_ITEM(__pyx_t_26, 0, __pyx_t_25); __pyx_t_25 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_26, 0+__pyx_t_7, __pyx_t_3);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_26, 1+__pyx_t_7, __pyx_int_0);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_26, 2+__pyx_t_7, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_26, 3+__pyx_t_7, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_20);
      PyTuple_SET_ITEM(__pyx_t_26, 4+__pyx_t_7, __pyx_t_20);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_26, 5+__pyx_t_7, __pyx_t_6);
      __Pyx_INCREF(__pyx_float_1_0);
      __Pyx_GIVEREF(__pyx_float_1_0);
      PyTuple_SET_ITEM(__pyx_t_26, 6+__pyx_t_7, __pyx_float_1_0);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_26, 7+__pyx_t_7, __pyx_t_5);
      __Pyx_INCREF(__pyx_v_lda);
      __Pyx_GIVEREF(__pyx_v_lda);
      PyTuple_SET_ITEM(__pyx_t_26, 8+__pyx_t_7, __pyx_v_lda);
      __Pyx_GIVEREF(__pyx_t_22);
      PyTuple_SET_ITEM(__pyx_t_26, 9+__pyx_t_7, __pyx_t_22);
      __Pyx_INCREF(__pyx_v_ldb);
      __Pyx_GIVEREF(__pyx_v_ldb);
      PyTuple_SET_ITEM(__pyx_t_26, 10+__pyx_t_7, __pyx_v_ldb);
      __Pyx_INCREF(__pyx_float_0_0);
      __Pyx_GIVEREF(__pyx_float_0_0);
      PyTuple_SET_ITEM(__pyx_t_26, 11+__pyx_t_7, __pyx_float_0_0);
      __Pyx_GIVEREF(__pyx_t_23);
      PyTuple_SET_ITEM(__pyx_t_26, 12+__pyx_t_7, __pyx_t_23);
      __Pyx_INCREF(__pyx_v_ldout);
      __Pyx_GIVEREF(__pyx_v_ldout);
      PyTuple_SET_ITEM(__pyx_t_26, 13+__pyx_t_7, __pyx_v_ldout);
      __Pyx_GIVEREF(__pyx_t_24);
      PyTuple_SET_ITEM(__pyx_t_26, 14+__pyx_t_7, __pyx_t_24);
      __pyx_t_3 = 0;
      __pyx_t_8 = 0;
      __pyx_t_20 = 0;
      __pyx_t_6 = 0;
      __pyx_t_5 = 0;
      __pyx_t_22 = 0;
      __pyx_t_23 = 0;
      __pyx_t_24 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_26, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3579, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":3578
 *     outp = _mat_ptrs(out_view)
 * 
 *     if dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *         cuda.cublas.sgemmBatched(
 *             cuda.Device().cublas_handle,
 */
    goto __pyx_L37;
  }

  /* "cupy/core/core.pyx":3587
 *             bp.data.ptr, ldb,
 *             0.0, outp.data.ptr, ldout, batchCount)
 *     elif dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *         cuda.cublas.dgemmBatched(
 *             cuda.Device().cublas_handle,
 */
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3587, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_float64); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3587, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_9, Py_EQ); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3587, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3587, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3588
 *             0.0, outp.data.ptr, ldout, batchCount)
 *     elif dtype == numpy.float64:
 *         cuda.cublas.dgemmBatched(             # <<<<<<<<<<<<<<
 *             cuda.Device().cublas_handle,
 *             0,  # transa
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3588, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_cublas); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3588, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_26);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_n_s_dgemmBatched); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3588, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;

    /* "cupy/core/core.pyx":3589
 *     elif dtype == numpy.float64:
 *         cuda.cublas.dgemmBatched(
 *             cuda.Device().cublas_handle,             # <<<<<<<<<<<<<<
 *             0,  # transa
 *             0,  # transb
 */
    __pyx_t_24 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3589, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_24);
    __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_n_s_Device); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 3589, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
    __pyx_t_24 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_23))) {
      __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_23);
      if (likely(__pyx_t_24)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_23);
        __Pyx_INCREF(__pyx_t_24);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_23, function);
      }
    }
    if (__pyx_t_24) {
      __pyx_t_26 = __Pyx_PyObject_CallOneArg(__pyx_t_23, __pyx_t_24); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3589, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
    } else {
      __pyx_t_26 = __Pyx_PyObject_CallNoArg(__pyx_t_23); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3589, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_26);
    __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
    __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_n_s_cublas_handle); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 3589, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;

    /* "cupy/core/core.pyx":3592
 *             0,  # transa
 *             0,  # transb
 *             n, m, ka, 1.0,             # <<<<<<<<<<<<<<
 *             ap.data.ptr, lda,
 *             bp.data.ptr, ldb,
 */
    __pyx_t_26 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3592, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_26);
    __pyx_t_24 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3592, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_24);
    __pyx_t_22 = PyInt_FromSsize_t(__pyx_v_ka); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3592, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);

    /* "cupy/core/core.pyx":3593
 *             0,  # transb
 *             n, m, ka, 1.0,
 *             ap.data.ptr, lda,             # <<<<<<<<<<<<<<
 *             bp.data.ptr, ldb,
 *             0.0, outp.data.ptr, ldout, batchCount)
 */
    __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_ap->data->ptr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3593, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);

    /* "cupy/core/core.pyx":3594
 *             n, m, ka, 1.0,
 *             ap.data.ptr, lda,
 *             bp.data.ptr, ldb,             # <<<<<<<<<<<<<<
 *             0.0, outp.data.ptr, ldout, batchCount)
 *     # elif dtype == numpy.complex64:
 */
    __pyx_t_6 = __Pyx_PyInt_FromSize_t(__pyx_v_bp->data->ptr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3594, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);

    /* "cupy/core/core.pyx":3595
 *             ap.data.ptr, lda,
 *             bp.data.ptr, ldb,
 *             0.0, outp.data.ptr, ldout, batchCount)             # <<<<<<<<<<<<<<
 *     # elif dtype == numpy.complex64:
 *     #     cuda.cublas.cgemmBatched(
 */
    __pyx_t_20 = __Pyx_PyInt_FromSize_t(__pyx_v_outp->data->ptr); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3595, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_20);
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_batchCount); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3595, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = NULL;
    __pyx_t_7 = 0;
    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);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[16] = {__pyx_t_3, __pyx_t_23, __pyx_int_0, __pyx_int_0, __pyx_t_26, __pyx_t_24, __pyx_t_22, __pyx_float_1_0, __pyx_t_5, __pyx_v_lda, __pyx_t_6, __pyx_v_ldb, __pyx_float_0_0, __pyx_t_20, __pyx_v_ldout, __pyx_t_8};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 15+__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3588, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[16] = {__pyx_t_3, __pyx_t_23, __pyx_int_0, __pyx_int_0, __pyx_t_26, __pyx_t_24, __pyx_t_22, __pyx_float_1_0, __pyx_t_5, __pyx_v_lda, __pyx_t_6, __pyx_v_ldb, __pyx_float_0_0, __pyx_t_20, __pyx_v_ldout, __pyx_t_8};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 15+__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3588, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_25 = PyTuple_New(15+__pyx_t_7); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3588, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_25);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_25, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_23);
      PyTuple_SET_ITEM(__pyx_t_25, 0+__pyx_t_7, __pyx_t_23);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_25, 1+__pyx_t_7, __pyx_int_0);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_25, 2+__pyx_t_7, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_t_26);
      PyTuple_SET_ITEM(__pyx_t_25, 3+__pyx_t_7, __pyx_t_26);
      __Pyx_GIVEREF(__pyx_t_24);
      PyTuple_SET_ITEM(__pyx_t_25, 4+__pyx_t_7, __pyx_t_24);
      __Pyx_GIVEREF(__pyx_t_22);
      PyTuple_SET_ITEM(__pyx_t_25, 5+__pyx_t_7, __pyx_t_22);
      __Pyx_INCREF(__pyx_float_1_0);
      __Pyx_GIVEREF(__pyx_float_1_0);
      PyTuple_SET_ITEM(__pyx_t_25, 6+__pyx_t_7, __pyx_float_1_0);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_25, 7+__pyx_t_7, __pyx_t_5);
      __Pyx_INCREF(__pyx_v_lda);
      __Pyx_GIVEREF(__pyx_v_lda);
      PyTuple_SET_ITEM(__pyx_t_25, 8+__pyx_t_7, __pyx_v_lda);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_25, 9+__pyx_t_7, __pyx_t_6);
      __Pyx_INCREF(__pyx_v_ldb);
      __Pyx_GIVEREF(__pyx_v_ldb);
      PyTuple_SET_ITEM(__pyx_t_25, 10+__pyx_t_7, __pyx_v_ldb);
      __Pyx_INCREF(__pyx_float_0_0);
      __Pyx_GIVEREF(__pyx_float_0_0);
      PyTuple_SET_ITEM(__pyx_t_25, 11+__pyx_t_7, __pyx_float_0_0);
      __Pyx_GIVEREF(__pyx_t_20);
      PyTuple_SET_ITEM(__pyx_t_25, 12+__pyx_t_7, __pyx_t_20);
      __Pyx_INCREF(__pyx_v_ldout);
      __Pyx_GIVEREF(__pyx_v_ldout);
      PyTuple_SET_ITEM(__pyx_t_25, 13+__pyx_t_7, __pyx_v_ldout);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_25, 14+__pyx_t_7, __pyx_t_8);
      __pyx_t_23 = 0;
      __pyx_t_26 = 0;
      __pyx_t_24 = 0;
      __pyx_t_22 = 0;
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_20 = 0;
      __pyx_t_8 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_25, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3588, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":3587
 *             bp.data.ptr, ldb,
 *             0.0, outp.data.ptr, ldout, batchCount)
 *     elif dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *         cuda.cublas.dgemmBatched(
 *             cuda.Device().cublas_handle,
 */
    goto __pyx_L37;
  }

  /* "cupy/core/core.pyx":3615
 *     #         0, outp.data.ptr, ldout, batchCount)
 *     else:
 *         raise TypeError(dtype, a.dtype, b.dtype)             # <<<<<<<<<<<<<<
 * 
 *     if dtype == ret_dtype:
 */
  /*else*/ {
    __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3615, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_dtype);
    __Pyx_INCREF(__pyx_v_a->dtype);
    __Pyx_GIVEREF(__pyx_v_a->dtype);
    PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_v_a->dtype);
    __Pyx_INCREF(__pyx_v_b->dtype);
    __Pyx_GIVEREF(__pyx_v_b->dtype);
    PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_v_b->dtype);
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_12, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3615, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 3615, __pyx_L1_error)
  }
  __pyx_L37:;

  /* "cupy/core/core.pyx":3617
 *         raise TypeError(dtype, a.dtype, b.dtype)
 * 
 *     if dtype == ret_dtype:             # <<<<<<<<<<<<<<
 *         return out
 *     else:
 */
  __pyx_t_9 = PyObject_RichCompare(__pyx_v_dtype, __pyx_v_ret_dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3617, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3617, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3618
 * 
 *     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":3617
 *         raise TypeError(dtype, a.dtype, b.dtype)
 * 
 *     if dtype == ret_dtype:             # <<<<<<<<<<<<<<
 *         return out
 *     else:
 */
  }

  /* "cupy/core/core.pyx":3620
 *         return out
 *     else:
 *         ret = ndarray(out_shape, ret_dtype)             # <<<<<<<<<<<<<<
 *         elementwise_copy(out, ret)
 *         return ret
 */
  /*else*/ {
    __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3620, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_v_out_shape);
    __Pyx_GIVEREF(__pyx_v_out_shape);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_out_shape);
    __Pyx_INCREF(__pyx_v_ret_dtype);
    __Pyx_GIVEREF(__pyx_v_ret_dtype);
    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_ret_dtype);
    __pyx_t_12 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_9, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3620, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_12);
    __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":3621
 *     else:
 *         ret = ndarray(out_shape, ret_dtype)
 *         elementwise_copy(out, ret)             # <<<<<<<<<<<<<<
 *         return ret
 * 
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3621, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_25 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_25)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_25);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[3] = {__pyx_t_25, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3621, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
      __Pyx_GOTREF(__pyx_t_12);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[3] = {__pyx_t_25, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3621, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
      __Pyx_GOTREF(__pyx_t_12);
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3621, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_25) {
        __Pyx_GIVEREF(__pyx_t_25); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_25); __pyx_t_25 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_out));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, ((PyObject *)__pyx_v_out));
      __Pyx_INCREF(((PyObject *)__pyx_v_ret));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_ret));
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, ((PyObject *)__pyx_v_ret));
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3621, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":3622
 *         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":3430
 * 
 * 
 * cpdef ndarray matmul(ndarray a, ndarray b, ndarray out=None):             # <<<<<<<<<<<<<<
 *     """ Returns the matrix product of two arrays and is the implementation of
 *     the `@` operator introduced in Python 3.5 following PEP465.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_24);
  __Pyx_XDECREF(__pyx_t_25);
  __Pyx_XDECREF(__pyx_t_26);
  __Pyx_AddTraceback("cupy.core.core.matmul", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ap);
  __Pyx_XDECREF((PyObject *)__pyx_v_bp);
  __Pyx_XDECREF((PyObject *)__pyx_v_outp);
  __Pyx_XDECREF(__pyx_v_orig_a_shape);
  __Pyx_XDECREF(__pyx_v_orig_b_shape);
  __Pyx_XDECREF(__pyx_v_ret_dtype);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_a_part_outshape);
  __Pyx_XDECREF(__pyx_v_b_part_outshape);
  __Pyx_XDECREF(__pyx_v_ldout);
  __Pyx_XDECREF((PyObject *)__pyx_v_view);
  __Pyx_XDECREF(__pyx_v_broatcast_pre_shape);
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XDECREF(__pyx_v_a_strides);
  __Pyx_XDECREF(__pyx_v_a_shape);
  __Pyx_XDECREF(__pyx_v_b_strides);
  __Pyx_XDECREF(__pyx_v_b_shape);
  __Pyx_XDECREF((PyObject *)__pyx_v_out_view);
  __Pyx_XDECREF(__pyx_v_out_view_shape);
  __Pyx_XDECREF(__pyx_v_out_view_strides);
  __Pyx_XDECREF(__pyx_v_lda);
  __Pyx_XDECREF(__pyx_v_ldb);
  __Pyx_XDECREF(__pyx_v_la);
  __Pyx_XDECREF(__pyx_v_lb);
  __Pyx_XDECREF(__pyx_v_la_);
  __Pyx_XDECREF(__pyx_v_lb_);
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF((PyObject *)__pyx_v_b);
  __Pyx_XDECREF((PyObject *)__pyx_v_out);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_101matmul(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_100matmul[] = "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        Differences to numpy or missing features:\n\n        Currently the output must be real (float16, float32, uint8, ...),\n        complex64 and complex128 follow later. This means, that\n        numpy.result_type(a.dtype, b.dtype) have to be real.\n\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_101matmul(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] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_b)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("matmul", 0, 2, 3, 1); __PYX_ERR(0, 3430, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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, 3430, __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, 3430, __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, 3430, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) __PYX_ERR(0, 3430, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(0, 3430, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_100matmul(__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_100matmul(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, 3430, __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":3632
 * 
 * 
 * cpdef ndarray tensordot_core(             # <<<<<<<<<<<<<<
 *         ndarray a, ndarray b, ndarray out, Py_ssize_t n, Py_ssize_t m,
 *         Py_ssize_t k, vector.vector[Py_ssize_t] ret_shape):
 */

static PyObject *__pyx_pw_4cupy_4core_4core_103tensordot_core(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_tensordot_core(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out, Py_ssize_t __pyx_v_n, Py_ssize_t __pyx_v_m, Py_ssize_t __pyx_v_k, std::vector<Py_ssize_t>  __pyx_v_ret_shape, CYTHON_UNUSED int __pyx_skip_dispatch) {
  std::vector<Py_ssize_t>  __pyx_v_shape;
  Py_ssize_t __pyx_v_transa;
  Py_ssize_t __pyx_v_transb;
  Py_ssize_t __pyx_v_lda;
  Py_ssize_t __pyx_v_ldb;
  Py_ssize_t __pyx_v_handle;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_ret_dtype = 0;
  int __pyx_v_use_sgemmEx;
  float __pyx_v_one_fp32;
  float __pyx_v_zero_fp32;
  PyObject *__pyx_v_use_tensor_core = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_c = NULL;
  int __pyx_v_Ctype;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  size_t __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  Py_ssize_t __pyx_t_14;
  int __pyx_t_15;
  __Pyx_RefNannySetupContext("tensordot_core", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF((PyObject *)__pyx_v_b);
  __Pyx_INCREF((PyObject *)__pyx_v_out);

  /* "cupy/core/core.pyx":3641
 *     cdef bint use_sgemmEx
 *     cdef float one_fp32, zero_fp32
 *     ret_dtype = a.dtype.char             # <<<<<<<<<<<<<<
 *     if ret_dtype != b.dtype.char:
 *         ret_dtype = numpy.find_common_type((ret_dtype, b.dtype), ()).char
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a->dtype, __pyx_n_s_char); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3641, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 3641, __pyx_L1_error)
  __pyx_v_ret_dtype = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3642
 *     cdef float one_fp32, zero_fp32
 *     ret_dtype = a.dtype.char
 *     if ret_dtype != b.dtype.char:             # <<<<<<<<<<<<<<
 *         ret_dtype = numpy.find_common_type((ret_dtype, b.dtype), ()).char
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_b->dtype, __pyx_n_s_char); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3642, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_ret_dtype, __pyx_t_1, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3642, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3643
 *     ret_dtype = a.dtype.char
 *     if ret_dtype != b.dtype.char:
 *         ret_dtype = numpy.find_common_type((ret_dtype, b.dtype), ()).char             # <<<<<<<<<<<<<<
 * 
 *     if not a.size or not b.size:
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_find_common_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_ret_dtype);
    __Pyx_GIVEREF(__pyx_v_ret_dtype);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_ret_dtype);
    __Pyx_INCREF(__pyx_v_b->dtype);
    __Pyx_GIVEREF(__pyx_v_b->dtype);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_b->dtype);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_empty_tuple};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3643, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_empty_tuple};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3643, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3643, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
      __Pyx_INCREF(__pyx_empty_tuple);
      __Pyx_GIVEREF(__pyx_empty_tuple);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_empty_tuple);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3643, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_char); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(PyString_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 3643, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_ret_dtype, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3642
 *     cdef float one_fp32, zero_fp32
 *     ret_dtype = a.dtype.char
 *     if ret_dtype != b.dtype.char:             # <<<<<<<<<<<<<<
 *         ret_dtype = numpy.find_common_type((ret_dtype, b.dtype), ()).char
 * 
 */
  }

  /* "cupy/core/core.pyx":3645
 *         ret_dtype = numpy.find_common_type((ret_dtype, b.dtype), ()).char
 * 
 *     if not a.size or not b.size:             # <<<<<<<<<<<<<<
 *         if out is None:
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 */
  __pyx_t_8 = ((!(__pyx_v_a->size != 0)) != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_8 = ((!(__pyx_v_b->size != 0)) != 0);
  __pyx_t_2 = __pyx_t_8;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3646
 * 
 *     if not a.size or not b.size:
 *         if out is None:             # <<<<<<<<<<<<<<
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 *         out.fill(0)
 */
    __pyx_t_2 = (((PyObject *)__pyx_v_out) == Py_None);
    __pyx_t_8 = (__pyx_t_2 != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":3647
 *     if not a.size or not b.size:
 *         if out is None:
 *             out = ndarray(ret_shape, dtype=ret_dtype)             # <<<<<<<<<<<<<<
 *         out.fill(0)
 *         return out
 */
      __pyx_t_4 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_ret_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3647, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3647, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3647, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_v_ret_dtype) < 0) __PYX_ERR(0, 3647, __pyx_L1_error)
      __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3647, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7));
      __pyx_t_7 = 0;

      /* "cupy/core/core.pyx":3646
 * 
 *     if not a.size or not b.size:
 *         if out is None:             # <<<<<<<<<<<<<<
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 *         out.fill(0)
 */
    }

    /* "cupy/core/core.pyx":3648
 *         if out is None:
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 *         out.fill(0)             # <<<<<<<<<<<<<<
 *         return out
 * 
 */
    __pyx_t_7 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_out->__pyx_vtab)->fill(__pyx_v_out, __pyx_int_0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3648, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":3649
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 *         out.fill(0)
 *         return out             # <<<<<<<<<<<<<<
 * 
 *     global _cuda_runtime_version
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __pyx_r = __pyx_v_out;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3645
 *         ret_dtype = numpy.find_common_type((ret_dtype, b.dtype), ()).char
 * 
 *     if not a.size or not b.size:             # <<<<<<<<<<<<<<
 *         if out is None:
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 */
  }

  /* "cupy/core/core.pyx":3652
 * 
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  __pyx_t_8 = (__pyx_v_4cupy_4core_4core__cuda_runtime_version == Py_None);
  __pyx_t_2 = (__pyx_t_8 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3653
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:
 *         _cuda_runtime_version = runtime.runtimeGetVersion()             # <<<<<<<<<<<<<<
 * 
 *     use_sgemmEx = (_cuda_runtime_version >= 7500 and
 */
    __pyx_t_6 = __pyx_f_4cupy_4cuda_7runtime_runtimeGetVersion(0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3653, __pyx_L1_error)
    __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3653, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cuda_runtime_version);
    __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cuda_runtime_version, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":3652
 * 
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  }

  /* "cupy/core/core.pyx":3655
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 *     use_sgemmEx = (_cuda_runtime_version >= 7500 and             # <<<<<<<<<<<<<<
 *                    a.dtype == 'e' and b.dtype == 'e' and
 *                    (ret_dtype == 'e' or ret_dtype == 'f'))
 */
  __pyx_t_7 = PyObject_RichCompare(__pyx_v_4cupy_4core_4core__cuda_runtime_version, __pyx_int_7500, Py_GE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3655, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 3655, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L9_bool_binop_done;
  }

  /* "cupy/core/core.pyx":3656
 * 
 *     use_sgemmEx = (_cuda_runtime_version >= 7500 and
 *                    a.dtype == 'e' and b.dtype == 'e' and             # <<<<<<<<<<<<<<
 *                    (ret_dtype == 'e' or ret_dtype == 'f'))
 *     use_tensor_core = (use_sgemmEx and
 */
  __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_a->dtype, __pyx_n_s_e, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 3656, __pyx_L1_error)
  if (__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_b->dtype, __pyx_n_s_e, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 3656, __pyx_L1_error)
  if (__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L9_bool_binop_done;
  }

  /* "cupy/core/core.pyx":3657
 *     use_sgemmEx = (_cuda_runtime_version >= 7500 and
 *                    a.dtype == 'e' and b.dtype == 'e' and
 *                    (ret_dtype == 'e' or ret_dtype == 'f'))             # <<<<<<<<<<<<<<
 *     use_tensor_core = (use_sgemmEx and
 *                        _cuda_runtime_version >= 9000 and
 */
  __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_ret_dtype, __pyx_n_s_e, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 3657, __pyx_L1_error)
  __pyx_t_9 = (__pyx_t_8 != 0);
  if (!__pyx_t_9) {
  } else {
    __pyx_t_2 = __pyx_t_9;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_ret_dtype, __pyx_n_s_f, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3657, __pyx_L1_error)
  __pyx_t_8 = (__pyx_t_9 != 0);
  __pyx_t_2 = __pyx_t_8;
  __pyx_L9_bool_binop_done:;
  __pyx_v_use_sgemmEx = __pyx_t_2;

  /* "cupy/core/core.pyx":3658
 *                    a.dtype == 'e' and b.dtype == 'e' and
 *                    (ret_dtype == 'e' or ret_dtype == 'f'))
 *     use_tensor_core = (use_sgemmEx and             # <<<<<<<<<<<<<<
 *                        _cuda_runtime_version >= 9000 and
 *                        int(device.get_compute_capability()) == 70)
 */
  if (__pyx_v_use_sgemmEx) {
  } else {
    __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_use_sgemmEx); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3658, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L14_bool_binop_done;
  }

  /* "cupy/core/core.pyx":3659
 *                    (ret_dtype == 'e' or ret_dtype == 'f'))
 *     use_tensor_core = (use_sgemmEx and
 *                        _cuda_runtime_version >= 9000 and             # <<<<<<<<<<<<<<
 *                        int(device.get_compute_capability()) == 70)
 * 
 */
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_4cupy_4core_4core__cuda_runtime_version, __pyx_int_9000, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3659, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3659, __pyx_L1_error)
  if (__pyx_t_2) {
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_7 = __pyx_t_4;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L14_bool_binop_done;
  }

  /* "cupy/core/core.pyx":3660
 *     use_tensor_core = (use_sgemmEx and
 *                        _cuda_runtime_version >= 9000 and
 *                        int(device.get_compute_capability()) == 70)             # <<<<<<<<<<<<<<
 * 
 *     if use_sgemmEx or ret_dtype in 'fdFD':
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_6device_get_compute_capability(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3660, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3660, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_70, 70, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3660, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_7 = __pyx_t_4;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_L14_bool_binop_done:;
  __pyx_v_use_tensor_core = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":3662
 *                        int(device.get_compute_capability()) == 70)
 * 
 *     if use_sgemmEx or ret_dtype in 'fdFD':             # <<<<<<<<<<<<<<
 *         dtype = ret_dtype
 *     else:
 */
  __pyx_t_8 = (__pyx_v_use_sgemmEx != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L18_bool_binop_done;
  }
  __pyx_t_8 = (__Pyx_PySequence_ContainsTF(__pyx_v_ret_dtype, __pyx_n_s_fdFD, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 3662, __pyx_L1_error)
  __pyx_t_9 = (__pyx_t_8 != 0);
  __pyx_t_2 = __pyx_t_9;
  __pyx_L18_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3663
 * 
 *     if use_sgemmEx or ret_dtype in 'fdFD':
 *         dtype = ret_dtype             # <<<<<<<<<<<<<<
 *     else:
 *         dtype = numpy.find_common_type((ret_dtype, 'f'), ()).char
 */
    __Pyx_INCREF(__pyx_v_ret_dtype);
    __pyx_v_dtype = __pyx_v_ret_dtype;

    /* "cupy/core/core.pyx":3662
 *                        int(device.get_compute_capability()) == 70)
 * 
 *     if use_sgemmEx or ret_dtype in 'fdFD':             # <<<<<<<<<<<<<<
 *         dtype = ret_dtype
 *     else:
 */
    goto __pyx_L17;
  }

  /* "cupy/core/core.pyx":3665
 *         dtype = ret_dtype
 *     else:
 *         dtype = numpy.find_common_type((ret_dtype, 'f'), ()).char             # <<<<<<<<<<<<<<
 * 
 *     if out is None:
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3665, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_find_common_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3665, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3665, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_ret_dtype);
    __Pyx_GIVEREF(__pyx_v_ret_dtype);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_ret_dtype);
    __Pyx_INCREF(__pyx_n_s_f);
    __Pyx_GIVEREF(__pyx_n_s_f);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_f);
    __pyx_t_3 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, __pyx_empty_tuple};
      __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3665, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, __pyx_empty_tuple};
      __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3665, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3665, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_t_4);
      __Pyx_INCREF(__pyx_empty_tuple);
      __Pyx_GIVEREF(__pyx_empty_tuple);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_empty_tuple);
      __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3665, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_char); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3665, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 3665, __pyx_L1_error)
    __pyx_v_dtype = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
  }
  __pyx_L17:;

  /* "cupy/core/core.pyx":3667
 *         dtype = numpy.find_common_type((ret_dtype, 'f'), ()).char
 * 
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_out) == Py_None);
  __pyx_t_9 = (__pyx_t_2 != 0);
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3668
 * 
 *     if out is None:
 *         out = ndarray(ret_shape, dtype)             # <<<<<<<<<<<<<<
 *         if dtype == ret_dtype:
 *             ret = out
 */
    __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_ret_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3668, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3668, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_dtype);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3668, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3669
 *     if out is None:
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:             # <<<<<<<<<<<<<<
 *             ret = out
 *         else:
 */
    __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_v_ret_dtype, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3669, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_9 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":3670
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:
 *             ret = out             # <<<<<<<<<<<<<<
 *         else:
 *             ret = ndarray(ret_shape, ret_dtype)
 */
      __Pyx_INCREF(((PyObject *)__pyx_v_out));
      __pyx_v_ret = __pyx_v_out;

      /* "cupy/core/core.pyx":3669
 *     if out is None:
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:             # <<<<<<<<<<<<<<
 *             ret = out
 *         else:
 */
      goto __pyx_L21;
    }

    /* "cupy/core/core.pyx":3672
 *             ret = out
 *         else:
 *             ret = ndarray(ret_shape, ret_dtype)             # <<<<<<<<<<<<<<
 *     else:
 *         ret = out
 */
    /*else*/ {
      __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_ret_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3672, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3672, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
      __Pyx_INCREF(__pyx_v_ret_dtype);
      __Pyx_GIVEREF(__pyx_v_ret_dtype);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_ret_dtype);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3672, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
      __pyx_t_1 = 0;
    }
    __pyx_L21:;

    /* "cupy/core/core.pyx":3667
 *         dtype = numpy.find_common_type((ret_dtype, 'f'), ()).char
 * 
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:
 */
    goto __pyx_L20;
  }

  /* "cupy/core/core.pyx":3674
 *             ret = ndarray(ret_shape, ret_dtype)
 *     else:
 *         ret = out             # <<<<<<<<<<<<<<
 *         if out.dtype != dtype:
 *             out = ndarray(ret_shape, dtype)
 */
  /*else*/ {
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __pyx_v_ret = __pyx_v_out;

    /* "cupy/core/core.pyx":3675
 *     else:
 *         ret = out
 *         if out.dtype != dtype:             # <<<<<<<<<<<<<<
 *             out = ndarray(ret_shape, dtype)
 * 
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_out->dtype, __pyx_v_dtype, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3675, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":3676
 *         ret = out
 *         if out.dtype != dtype:
 *             out = ndarray(ret_shape, dtype)             # <<<<<<<<<<<<<<
 * 
 *     if m == 1 and n == 1:
 */
      __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_ret_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3676, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3676, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_dtype);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3676, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":3675
 *     else:
 *         ret = out
 *         if out.dtype != dtype:             # <<<<<<<<<<<<<<
 *             out = ndarray(ret_shape, dtype)
 * 
 */
    }
  }
  __pyx_L20:;

  /* "cupy/core/core.pyx":3678
 *             out = ndarray(ret_shape, dtype)
 * 
 *     if m == 1 and n == 1:             # <<<<<<<<<<<<<<
 *         _tensordot_core_mul_sum(a.ravel(), b.ravel(), out.reshape(()))
 *         if out is not ret:
 */
  __pyx_t_9 = ((__pyx_v_m == 1) != 0);
  if (__pyx_t_9) {
  } else {
    __pyx_t_2 = __pyx_t_9;
    goto __pyx_L24_bool_binop_done;
  }
  __pyx_t_9 = ((__pyx_v_n == 1) != 0);
  __pyx_t_2 = __pyx_t_9;
  __pyx_L24_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3679
 * 
 *     if m == 1 and n == 1:
 *         _tensordot_core_mul_sum(a.ravel(), b.ravel(), out.reshape(()))             # <<<<<<<<<<<<<<
 *         if out is not ret:
 *             elementwise_copy(out, ret)
 */
    __pyx_t_7 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->ravel(__pyx_v_a, 0)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3679, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_b->__pyx_vtab)->ravel(__pyx_v_b, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3679, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3679, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__193, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3679, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__tensordot_core_mul_sum);
    __pyx_t_4 = __pyx_v_4cupy_4core_4core__tensordot_core_mul_sum; __pyx_t_10 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_t_7, __pyx_t_5, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3679, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_t_7, __pyx_t_5, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3679, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3679, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_6, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_6, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_6, __pyx_t_3);
      __pyx_t_7 = 0;
      __pyx_t_5 = 0;
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3679, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3680
 *     if m == 1 and n == 1:
 *         _tensordot_core_mul_sum(a.ravel(), b.ravel(), out.reshape(()))
 *         if out is not ret:             # <<<<<<<<<<<<<<
 *             elementwise_copy(out, ret)
 *         return ret
 */
    __pyx_t_2 = (__pyx_v_out != __pyx_v_ret);
    __pyx_t_9 = (__pyx_t_2 != 0);
    if (__pyx_t_9) {

      /* "cupy/core/core.pyx":3681
 *         _tensordot_core_mul_sum(a.ravel(), b.ravel(), out.reshape(()))
 *         if out is not ret:
 *             elementwise_copy(out, ret)             # <<<<<<<<<<<<<<
 *         return ret
 * 
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3681, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_11 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3681, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3681, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3681, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (__pyx_t_11) {
          __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_11); __pyx_t_11 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_out));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
        PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_6, ((PyObject *)__pyx_v_out));
        __Pyx_INCREF(((PyObject *)__pyx_v_ret));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_ret));
        PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_6, ((PyObject *)__pyx_v_ret));
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3681, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":3680
 *     if m == 1 and n == 1:
 *         _tensordot_core_mul_sum(a.ravel(), b.ravel(), out.reshape(()))
 *         if out is not ret:             # <<<<<<<<<<<<<<
 *             elementwise_copy(out, ret)
 *         return ret
 */
    }

    /* "cupy/core/core.pyx":3682
 *         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":3678
 *             out = ndarray(ret_shape, dtype)
 * 
 *     if m == 1 and n == 1:             # <<<<<<<<<<<<<<
 *         _tensordot_core_mul_sum(a.ravel(), b.ravel(), out.reshape(()))
 *         if out is not ret:
 */
  }

  /* "cupy/core/core.pyx":3685
 * 
 *     # It copies the operands if needed
 *     if a._shape.size() != 2 or a._shape[0] != k or a._shape[1] != n:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(k)
 */
  __pyx_t_2 = ((__pyx_v_a->_shape.size() != 2) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_9 = __pyx_t_2;
    goto __pyx_L28_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_a->_shape[0]) != __pyx_v_k) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_9 = __pyx_t_2;
    goto __pyx_L28_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_a->_shape[1]) != __pyx_v_n) != 0);
  __pyx_t_9 = __pyx_t_2;
  __pyx_L28_bool_binop_done:;
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3686
 *     # 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":3687
 *     if a._shape.size() != 2 or a._shape[0] != k or a._shape[1] != n:
 *         shape.clear()
 *         shape.push_back(k)             # <<<<<<<<<<<<<<
 *         shape.push_back(n)
 *         a = a._reshape(shape)
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_k);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3687, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3688
 *         shape.clear()
 *         shape.push_back(k)
 *         shape.push_back(n)             # <<<<<<<<<<<<<<
 *         a = a._reshape(shape)
 *     if b._shape.size() != 2 or b._shape[0] != k or b._shape[1] != m:
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_n);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3688, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3689
 *         shape.push_back(k)
 *         shape.push_back(n)
 *         a = a._reshape(shape)             # <<<<<<<<<<<<<<
 *     if b._shape.size() != 2 or b._shape[0] != k or b._shape[1] != m:
 *         shape.clear()
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->_reshape(__pyx_v_a, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3689, __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":3685
 * 
 *     # 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":3690
 *         shape.push_back(n)
 *         a = a._reshape(shape)
 *     if b._shape.size() != 2 or b._shape[0] != k or b._shape[1] != m:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(k)
 */
  __pyx_t_2 = ((__pyx_v_b->_shape.size() != 2) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_9 = __pyx_t_2;
    goto __pyx_L32_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_b->_shape[0]) != __pyx_v_k) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_9 = __pyx_t_2;
    goto __pyx_L32_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_b->_shape[1]) != __pyx_v_m) != 0);
  __pyx_t_9 = __pyx_t_2;
  __pyx_L32_bool_binop_done:;
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3691
 *         a = a._reshape(shape)
 *     if b._shape.size() != 2 or b._shape[0] != k or b._shape[1] != m:
 *         shape.clear()             # <<<<<<<<<<<<<<
 *         shape.push_back(k)
 *         shape.push_back(m)
 */
    __pyx_v_shape.clear();

    /* "cupy/core/core.pyx":3692
 *     if b._shape.size() != 2 or b._shape[0] != k or b._shape[1] != m:
 *         shape.clear()
 *         shape.push_back(k)             # <<<<<<<<<<<<<<
 *         shape.push_back(m)
 *         b = b._reshape(shape)
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_k);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3692, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3693
 *         shape.clear()
 *         shape.push_back(k)
 *         shape.push_back(m)             # <<<<<<<<<<<<<<
 *         b = b._reshape(shape)
 *     c = out
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_m);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3693, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3694
 *         shape.push_back(k)
 *         shape.push_back(m)
 *         b = b._reshape(shape)             # <<<<<<<<<<<<<<
 *     c = out
 *     if c._shape.size() != 2 or c._shape[0] != n or c._shape[1] != m:
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_b->__pyx_vtab)->_reshape(__pyx_v_b, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3694, __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":3690
 *         shape.push_back(n)
 *         a = a._reshape(shape)
 *     if b._shape.size() != 2 or b._shape[0] != k or b._shape[1] != m:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(k)
 */
  }

  /* "cupy/core/core.pyx":3695
 *         shape.push_back(m)
 *         b = b._reshape(shape)
 *     c = out             # <<<<<<<<<<<<<<
 *     if c._shape.size() != 2 or c._shape[0] != n or c._shape[1] != m:
 *         c = c.view()
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_out));
  __pyx_v_c = __pyx_v_out;

  /* "cupy/core/core.pyx":3696
 *         b = b._reshape(shape)
 *     c = out
 *     if c._shape.size() != 2 or c._shape[0] != n or c._shape[1] != m:             # <<<<<<<<<<<<<<
 *         c = c.view()
 *         c.shape = (n, m)
 */
  __pyx_t_2 = ((__pyx_v_c->_shape.size() != 2) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_9 = __pyx_t_2;
    goto __pyx_L36_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_c->_shape[0]) != __pyx_v_n) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_9 = __pyx_t_2;
    goto __pyx_L36_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_c->_shape[1]) != __pyx_v_m) != 0);
  __pyx_t_9 = __pyx_t_2;
  __pyx_L36_bool_binop_done:;
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3697
 *     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, 3697, __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":3698
 *     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, 3698, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3698, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3698, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
    __pyx_t_1 = 0;
    __pyx_t_4 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_c), __pyx_n_s_shape, __pyx_t_3) < 0) __PYX_ERR(0, 3698, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3696
 *         b = b._reshape(shape)
 *     c = out
 *     if c._shape.size() != 2 or c._shape[0] != n or c._shape[1] != m:             # <<<<<<<<<<<<<<
 *         c = c.view()
 *         c.shape = (n, m)
 */
  }

  /* "cupy/core/core.pyx":3700
 *         c.shape = (n, m)
 * 
 *     if not use_sgemmEx:             # <<<<<<<<<<<<<<
 *         a = a.astype(dtype, copy=False)
 *         b = b.astype(dtype, copy=False)
 */
  __pyx_t_9 = ((!(__pyx_v_use_sgemmEx != 0)) != 0);
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3701
 * 
 *     if not use_sgemmEx:
 *         a = a.astype(dtype, copy=False)             # <<<<<<<<<<<<<<
 *         b = b.astype(dtype, copy=False)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_astype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3701, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3701, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_dtype);
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3701, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 3701, __pyx_L1_error)
    __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3701, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3701, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_11));
    __pyx_t_11 = 0;

    /* "cupy/core/core.pyx":3702
 *     if not use_sgemmEx:
 *         a = a.astype(dtype, copy=False)
 *         b = b.astype(dtype, copy=False)             # <<<<<<<<<<<<<<
 * 
 *     # Be careful that cuBLAS uses the FORTRAN-order matrix representation.
 */
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_astype); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3702, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3702, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_dtype);
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3702, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 3702, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3702, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3702, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3700
 *         c.shape = (n, m)
 * 
 *     if not use_sgemmEx:             # <<<<<<<<<<<<<<
 *         a = a.astype(dtype, copy=False)
 *         b = b.astype(dtype, copy=False)
 */
  }

  /* "cupy/core/core.pyx":3705
 * 
 *     # Be careful that cuBLAS uses the FORTRAN-order matrix representation.
 *     handle = device.get_cublas_handle()             # <<<<<<<<<<<<<<
 *     # Matrix-Matrix product A^T * B
 *     # c is C-contiguous while cuBLAS assumes F-contiguous inputs, so we
 */
  __pyx_t_12 = __pyx_f_4cupy_4cuda_6device_get_cublas_handle(0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3705, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_12;

  /* "cupy/core/core.pyx":3709
 *     # c is C-contiguous while cuBLAS assumes F-contiguous inputs, so we
 *     # compute C^T = B^T * A here.
 *     a, transa, lda = _mat_to_cublas_contiguous(a, 0)             # <<<<<<<<<<<<<<
 *     b, transb, ldb = _mat_to_cublas_contiguous(b, 1)
 *     if use_sgemmEx:
 */
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__mat_to_cublas_contiguous(__pyx_v_a, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3709, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (likely(__pyx_t_3 != Py_None)) {
    PyObject* sequence = __pyx_t_3;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 3709, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    __pyx_t_11 = PyTuple_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_11);
    #else
    __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3709, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3709, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_11 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3709, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 3709, __pyx_L1_error)
  }
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3709, __pyx_L1_error)
  __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3709, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_t_11); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3709, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
  __pyx_t_4 = 0;
  __pyx_v_transa = __pyx_t_13;
  __pyx_v_lda = __pyx_t_14;

  /* "cupy/core/core.pyx":3710
 *     # compute C^T = B^T * A here.
 *     a, transa, lda = _mat_to_cublas_contiguous(a, 0)
 *     b, transb, ldb = _mat_to_cublas_contiguous(b, 1)             # <<<<<<<<<<<<<<
 *     if use_sgemmEx:
 *         Ctype = runtime.CUDA_R_16F if c.dtype == 'e' else runtime.CUDA_R_32F
 */
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__mat_to_cublas_contiguous(__pyx_v_b, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3710, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (likely(__pyx_t_3 != Py_None)) {
    PyObject* sequence = __pyx_t_3;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 3710, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_11 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 3710, __pyx_L1_error)
  }
  if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3710, __pyx_L1_error)
  __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3710, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3710, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_11));
  __pyx_t_11 = 0;
  __pyx_v_transb = __pyx_t_14;
  __pyx_v_ldb = __pyx_t_13;

  /* "cupy/core/core.pyx":3711
 *     a, transa, lda = _mat_to_cublas_contiguous(a, 0)
 *     b, transb, ldb = _mat_to_cublas_contiguous(b, 1)
 *     if use_sgemmEx:             # <<<<<<<<<<<<<<
 *         Ctype = runtime.CUDA_R_16F if c.dtype == 'e' else runtime.CUDA_R_32F
 *         if use_tensor_core:
 */
  __pyx_t_9 = (__pyx_v_use_sgemmEx != 0);
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3712
 *     b, transb, ldb = _mat_to_cublas_contiguous(b, 1)
 *     if use_sgemmEx:
 *         Ctype = runtime.CUDA_R_16F if c.dtype == 'e' else runtime.CUDA_R_32F             # <<<<<<<<<<<<<<
 *         if use_tensor_core:
 *             one_fp32 = 1
 */
    __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_c->dtype, __pyx_n_s_e, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3712, __pyx_L1_error)
    if (__pyx_t_9) {
      __pyx_t_15 = __pyx_e_4cupy_4cuda_7runtime_CUDA_R_16F;
    } else {
      __pyx_t_15 = __pyx_e_4cupy_4cuda_7runtime_CUDA_R_32F;
    }
    __pyx_v_Ctype = __pyx_t_15;

    /* "cupy/core/core.pyx":3713
 *     if use_sgemmEx:
 *         Ctype = runtime.CUDA_R_16F if c.dtype == 'e' else runtime.CUDA_R_32F
 *         if use_tensor_core:             # <<<<<<<<<<<<<<
 *             one_fp32 = 1
 *             zero_fp32 = 0
 */
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_use_tensor_core); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3713, __pyx_L1_error)
    if (__pyx_t_9) {

      /* "cupy/core/core.pyx":3714
 *         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":3715
 *         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":3716
 *             one_fp32 = 1
 *             zero_fp32 = 0
 *             cublas.setMathMode(handle, cublas.CUBLAS_TENSOR_OP_MATH)             # <<<<<<<<<<<<<<
 *             cublas.gemmEx(
 *                 handle, <int>transb, <int> transa, <int>m, <int>n, <int>k,
 */
      __pyx_t_3 = __pyx_f_4cupy_4cuda_6cublas_setMathMode(__pyx_v_handle, __pyx_e_4cupy_4cuda_6cublas_CUBLAS_TENSOR_OP_MATH, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3716, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":3717
 *             zero_fp32 = 0
 *             cublas.setMathMode(handle, cublas.CUBLAS_TENSOR_OP_MATH)
 *             cublas.gemmEx(             # <<<<<<<<<<<<<<
 *                 handle, <int>transb, <int> transa, <int>m, <int>n, <int>k,
 *                 <size_t>&one_fp32,
 */
      __pyx_t_3 = __pyx_f_4cupy_4cuda_6cublas_gemmEx(__pyx_v_handle, ((int)__pyx_v_transb), ((int)__pyx_v_transa), ((int)__pyx_v_m), ((int)__pyx_v_n), ((int)__pyx_v_k), ((size_t)(&__pyx_v_one_fp32)), __pyx_v_b->data->ptr, __pyx_e_4cupy_4cuda_7runtime_CUDA_R_16F, ((int)__pyx_v_ldb), __pyx_v_a->data->ptr, __pyx_e_4cupy_4cuda_7runtime_CUDA_R_16F, ((int)__pyx_v_lda), ((size_t)(&__pyx_v_zero_fp32)), __pyx_v_c->data->ptr, __pyx_v_Ctype, ((int)__pyx_v_m), __pyx_e_4cupy_4cuda_7runtime_CUDA_R_32F, __pyx_e_4cupy_4cuda_6cublas_CUBLAS_GEMM_DFALT_TENSOR_OP, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":3725
 *                 c.data.ptr, Ctype, <int>m,
 *                 runtime.CUDA_R_32F, cublas.CUBLAS_GEMM_DFALT_TENSOR_OP)
 *             cublas.setMathMode(handle, cublas.CUBLAS_DEFAULT_MATH)             # <<<<<<<<<<<<<<
 *         else:
 *             cublas.sgemmEx(
 */
      __pyx_t_3 = __pyx_f_4cupy_4cuda_6cublas_setMathMode(__pyx_v_handle, __pyx_e_4cupy_4cuda_6cublas_CUBLAS_DEFAULT_MATH, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3725, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":3713
 *     if use_sgemmEx:
 *         Ctype = runtime.CUDA_R_16F if c.dtype == 'e' else runtime.CUDA_R_32F
 *         if use_tensor_core:             # <<<<<<<<<<<<<<
 *             one_fp32 = 1
 *             zero_fp32 = 0
 */
      goto __pyx_L41;
    }

    /* "cupy/core/core.pyx":3727
 *             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":3730
 *                 handle, <int>transb, <int> transa, <int>m, <int>n, <int>k, 1,
 *                 b.data.ptr, runtime.CUDA_R_16F, <int>ldb, a.data.ptr,
 *                 runtime.CUDA_R_16F, <int>lda, 0, c.data.ptr, Ctype, <int>m)             # <<<<<<<<<<<<<<
 *     elif dtype == 'f':
 *         cublas.sgemm(
 */
      __pyx_t_3 = __pyx_f_4cupy_4cuda_6cublas_sgemmEx(__pyx_v_handle, ((int)__pyx_v_transb), ((int)__pyx_v_transa), ((int)__pyx_v_m), ((int)__pyx_v_n), ((int)__pyx_v_k), 1.0, __pyx_v_b->data->ptr, __pyx_e_4cupy_4cuda_7runtime_CUDA_R_16F, ((int)__pyx_v_ldb), __pyx_v_a->data->ptr, __pyx_e_4cupy_4cuda_7runtime_CUDA_R_16F, ((int)__pyx_v_lda), 0.0, __pyx_v_c->data->ptr, __pyx_v_Ctype, ((int)__pyx_v_m), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3727, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __pyx_L41:;

    /* "cupy/core/core.pyx":3711
 *     a, transa, lda = _mat_to_cublas_contiguous(a, 0)
 *     b, transb, ldb = _mat_to_cublas_contiguous(b, 1)
 *     if use_sgemmEx:             # <<<<<<<<<<<<<<
 *         Ctype = runtime.CUDA_R_16F if c.dtype == 'e' else runtime.CUDA_R_32F
 *         if use_tensor_core:
 */
    goto __pyx_L40;
  }

  /* "cupy/core/core.pyx":3731
 *                 b.data.ptr, runtime.CUDA_R_16F, <int>ldb, a.data.ptr,
 *                 runtime.CUDA_R_16F, <int>lda, 0, c.data.ptr, Ctype, <int>m)
 *     elif dtype == 'f':             # <<<<<<<<<<<<<<
 *         cublas.sgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int> n, <int> k, 1,
 */
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_f, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3731, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_9 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3732
 *                 runtime.CUDA_R_16F, <int>lda, 0, c.data.ptr, Ctype, <int>m)
 *     elif dtype == 'f':
 *         cublas.sgemm(             # <<<<<<<<<<<<<<
 *             handle, <int>transb, <int>transa, <int>m, <int> n, <int> k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 */
    __pyx_t_3 = __pyx_f_4cupy_4cuda_6cublas_sgemm(__pyx_v_handle, ((int)__pyx_v_transb), ((int)__pyx_v_transa), ((int)__pyx_v_m), ((int)__pyx_v_n), ((int)__pyx_v_k), 1.0, __pyx_v_b->data->ptr, ((int)__pyx_v_ldb), __pyx_v_a->data->ptr, ((int)__pyx_v_lda), 0.0, __pyx_v_c->data->ptr, ((int)__pyx_v_m), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3732, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3731
 *                 b.data.ptr, runtime.CUDA_R_16F, <int>ldb, a.data.ptr,
 *                 runtime.CUDA_R_16F, <int>lda, 0, c.data.ptr, Ctype, <int>m)
 *     elif dtype == 'f':             # <<<<<<<<<<<<<<
 *         cublas.sgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int> n, <int> k, 1,
 */
    goto __pyx_L40;
  }

  /* "cupy/core/core.pyx":3735
 *             handle, <int>transb, <int>transa, <int>m, <int> n, <int> k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'd':             # <<<<<<<<<<<<<<
 *         cublas.dgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 */
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_d, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3735, __pyx_L1_error)
  __pyx_t_9 = (__pyx_t_2 != 0);
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3736
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'd':
 *         cublas.dgemm(             # <<<<<<<<<<<<<<
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 */
    __pyx_t_3 = __pyx_f_4cupy_4cuda_6cublas_dgemm(__pyx_v_handle, ((int)__pyx_v_transb), ((int)__pyx_v_transa), ((int)__pyx_v_m), ((int)__pyx_v_n), ((int)__pyx_v_k), 1.0, __pyx_v_b->data->ptr, ((int)__pyx_v_ldb), __pyx_v_a->data->ptr, ((int)__pyx_v_lda), 0.0, __pyx_v_c->data->ptr, ((int)__pyx_v_m), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3736, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3735
 *             handle, <int>transb, <int>transa, <int>m, <int> n, <int> k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'd':             # <<<<<<<<<<<<<<
 *         cublas.dgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 */
    goto __pyx_L40;
  }

  /* "cupy/core/core.pyx":3739
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'F':             # <<<<<<<<<<<<<<
 *         cublas.cgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 */
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_F, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3739, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_9 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3740
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'F':
 *         cublas.cgemm(             # <<<<<<<<<<<<<<
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 */
    __pyx_t_3 = __pyx_f_4cupy_4cuda_6cublas_cgemm(__pyx_v_handle, ((int)__pyx_v_transb), ((int)__pyx_v_transa), ((int)__pyx_v_m), ((int)__pyx_v_n), ((int)__pyx_v_k), __pyx_t_float_complex_from_parts(1, 0), __pyx_v_b->data->ptr, ((int)__pyx_v_ldb), __pyx_v_a->data->ptr, ((int)__pyx_v_lda), __pyx_t_float_complex_from_parts(0, 0), __pyx_v_c->data->ptr, ((int)__pyx_v_m), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3740, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3739
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'F':             # <<<<<<<<<<<<<<
 *         cublas.cgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 */
    goto __pyx_L40;
  }

  /* "cupy/core/core.pyx":3743
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'D':             # <<<<<<<<<<<<<<
 *         cublas.zgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 */
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_D, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3743, __pyx_L1_error)
  __pyx_t_9 = (__pyx_t_2 != 0);
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3744
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'D':
 *         cublas.zgemm(             # <<<<<<<<<<<<<<
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 */
    __pyx_t_3 = __pyx_f_4cupy_4cuda_6cublas_zgemm(__pyx_v_handle, ((int)__pyx_v_transb), ((int)__pyx_v_transa), ((int)__pyx_v_m), ((int)__pyx_v_n), ((int)__pyx_v_k), __pyx_t_double_complex_from_parts(1, 0), __pyx_v_b->data->ptr, ((int)__pyx_v_ldb), __pyx_v_a->data->ptr, ((int)__pyx_v_lda), __pyx_t_double_complex_from_parts(0, 0), __pyx_v_c->data->ptr, ((int)__pyx_v_m), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3744, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3743
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'D':             # <<<<<<<<<<<<<<
 *         cublas.zgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 */
    goto __pyx_L40;
  }

  /* "cupy/core/core.pyx":3748
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     else:
 *         raise ValueError('Invalid dtype: %s' % str(dtype))             # <<<<<<<<<<<<<<
 * 
 *     if out is not ret:
 */
  /*else*/ {
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3748, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_dtype);
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3748, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_dtype_s, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3748, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3748, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3748, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 3748, __pyx_L1_error)
  }
  __pyx_L40:;

  /* "cupy/core/core.pyx":3750
 *         raise ValueError('Invalid dtype: %s' % str(dtype))
 * 
 *     if out is not ret:             # <<<<<<<<<<<<<<
 *         elementwise_copy(out, ret)
 *     return ret
 */
  __pyx_t_9 = (__pyx_v_out != __pyx_v_ret);
  __pyx_t_2 = (__pyx_t_9 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3751
 * 
 *     if out is not ret:
 *         elementwise_copy(out, ret)             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3751, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3751, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3751, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_out));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_6, ((PyObject *)__pyx_v_out));
      __Pyx_INCREF(((PyObject *)__pyx_v_ret));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_ret));
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_6, ((PyObject *)__pyx_v_ret));
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3751, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3750
 *         raise ValueError('Invalid dtype: %s' % str(dtype))
 * 
 *     if out is not ret:             # <<<<<<<<<<<<<<
 *         elementwise_copy(out, ret)
 *     return ret
 */
  }

  /* "cupy/core/core.pyx":3752
 *     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":3632
 * 
 * 
 * cpdef ndarray tensordot_core(             # <<<<<<<<<<<<<<
 *         ndarray a, ndarray b, ndarray out, Py_ssize_t n, Py_ssize_t m,
 *         Py_ssize_t k, vector.vector[Py_ssize_t] ret_shape):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core.tensordot_core", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_ret_dtype);
  __Pyx_XDECREF(__pyx_v_use_tensor_core);
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XDECREF((PyObject *)__pyx_v_c);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF((PyObject *)__pyx_v_b);
  __Pyx_XDECREF((PyObject *)__pyx_v_out);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_103tensordot_core(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_102tensordot_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_103tensordot_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] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_b)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tensordot_core", 1, 7, 7, 1); __PYX_ERR(0, 3632, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tensordot_core", 1, 7, 7, 2); __PYX_ERR(0, 3632, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tensordot_core", 1, 7, 7, 3); __PYX_ERR(0, 3632, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tensordot_core", 1, 7, 7, 4); __PYX_ERR(0, 3632, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tensordot_core", 1, 7, 7, 5); __PYX_ERR(0, 3632, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ret_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tensordot_core", 1, 7, 7, 6); __PYX_ERR(0, 3632, __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, 3632, __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, 3633, __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, 3633, __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, 3634, __pyx_L3_error)
    __pyx_v_ret_shape = __pyx_convert_vector_from_py_Py_ssize_t(values[6]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3634, __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, 3632, __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, 3633, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) __PYX_ERR(0, 3633, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(0, 3633, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_102tensordot_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_102tensordot_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, 3632, __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":3756
 * 
 * @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_105_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":3757
 * @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, 3757, __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, 3757, __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, 3757, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 3757, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/core/core.pyx":3758
 * 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":3760
 *     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, 3760, __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, 3760, __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, 3760, __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":3761
 *         # 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, 3761, __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, 3761, __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, 3761, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":3762
 *         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, 3762, __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":3761
 *         # 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":3763
 *         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, 3763, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3763, __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":3758
 * 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":3764
 *             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":3765
 *         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, 3765, __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":3764
 *             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":3766
 *     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, 3766, __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, 3766, __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, 3766, __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, 3766, __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, 3766, __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":3756
 * 
 * @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_105_mat_to_cublas_contiguous(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_104_mat_to_cublas_contiguous[] = "_mat_to_cublas_contiguous(ndarray a, Py_ssize_t trans) -> tuple";
static PyObject *__pyx_pw_4cupy_4core_4core_105_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] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_trans)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_mat_to_cublas_contiguous", 1, 2, 2, 1); __PYX_ERR(0, 3756, __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, 3756, __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, 3756, __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, 3756, __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, 3756, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_104_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_104_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, 3756, __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":3770
 * 
 * @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_107_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":3771
 * @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":3772
 * 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, 3772, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3772, __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":3771
 * @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":3774
 *         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, 3774, __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, 3774, __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, 3774, __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, 3774, __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":3770
 * 
 * @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_107_to_cublas_vector(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_106_to_cublas_vector[] = "_to_cublas_vector(ndarray a, Py_ssize_t rundim) -> tuple";
static PyObject *__pyx_pw_4cupy_4core_4core_107_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] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_rundim)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_to_cublas_vector", 1, 2, 2, 1); __PYX_ERR(0, 3770, __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, 3770, __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, 3770, __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, 3770, __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, 3770, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_106_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_106_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, 3770, __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":3780
 * # -----------------------------------------------------------------------------
 * 
 * cpdef create_comparison(name, op, doc='', require_sortable_dtype=True):             # <<<<<<<<<<<<<<
 * 
 *     if require_sortable_dtype:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_109create_comparison(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_create_comparison(PyObject *__pyx_v_name, PyObject *__pyx_v_op, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_create_comparison *__pyx_optional_args) {
  PyObject *__pyx_v_doc = ((PyObject *)__pyx_kp_s__5);
  PyObject *__pyx_v_require_sortable_dtype = ((PyObject *)Py_True);
  PyObject *__pyx_v_ops = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("create_comparison", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_doc = __pyx_optional_args->doc;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_require_sortable_dtype = __pyx_optional_args->require_sortable_dtype;
      }
    }
  }

  /* "cupy/core/core.pyx":3782
 * cpdef create_comparison(name, op, doc='', require_sortable_dtype=True):
 * 
 *     if require_sortable_dtype:             # <<<<<<<<<<<<<<
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_require_sortable_dtype); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3782, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3783
 * 
 *     if require_sortable_dtype:
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',             # <<<<<<<<<<<<<<
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 *     else:
 */
    __Pyx_INCREF(__pyx_tuple__194);
    __pyx_v_ops = __pyx_tuple__194;

    /* "cupy/core/core.pyx":3782
 * cpdef create_comparison(name, op, doc='', require_sortable_dtype=True):
 * 
 *     if require_sortable_dtype:             # <<<<<<<<<<<<<<
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":3786
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 *     else:
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',             # <<<<<<<<<<<<<<
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'FF->?',
 *                'dd->?', 'DD->?')
 */
  /*else*/ {
    __Pyx_INCREF(__pyx_tuple__195);
    __pyx_v_ops = __pyx_tuple__195;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":3789
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'FF->?',
 *                'dd->?', 'DD->?')
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         ops,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3789, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/core.pyx":3790
 *                'dd->?', 'DD->?')
 *     return create_ufunc(
 *         'cupy_' + name,             # <<<<<<<<<<<<<<
 *         ops,
 *         'out0 = in0 %s in1' % op,
 */
  __pyx_t_3 = PyNumber_Add(__pyx_n_s_cupy_2, __pyx_v_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/core.pyx":3792
 *         'cupy_' + name,
 *         ops,
 *         'out0 = in0 %s in1' % op,             # <<<<<<<<<<<<<<
 *         doc=doc)
 * 
 */
  __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_out0_in0_s_in1, __pyx_v_op); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3792, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":3789
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'FF->?',
 *                'dd->?', 'DD->?')
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         ops,
 */
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3789, __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":3793
 *         ops,
 *         'out0 = in0 %s in1' % op,
 *         doc=doc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3793, __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, 3793, __pyx_L1_error)

  /* "cupy/core/core.pyx":3789
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'FF->?',
 *                'dd->?', 'DD->?')
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         ops,
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3789, __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":3780
 * # -----------------------------------------------------------------------------
 * 
 * cpdef create_comparison(name, op, doc='', require_sortable_dtype=True):             # <<<<<<<<<<<<<<
 * 
 *     if require_sortable_dtype:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.create_comparison", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ops);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_109create_comparison(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_108create_comparison[] = "create_comparison(name, op, doc='', require_sortable_dtype=True)";
static PyObject *__pyx_pw_4cupy_4core_4core_109create_comparison(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_v_doc = 0;
  PyObject *__pyx_v_require_sortable_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_comparison (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,&__pyx_n_s_op,&__pyx_n_s_doc,&__pyx_n_s_require_sortable_dtype,0};
    PyObject* values[4] = {0,0,0,0};
    values[2] = ((PyObject *)__pyx_kp_s__5);
    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] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_op)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_comparison", 0, 2, 4, 1); __PYX_ERR(0, 3780, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_doc);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_require_sortable_dtype);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_comparison") < 0)) __PYX_ERR(0, 3780, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_name = values[0];
    __pyx_v_op = values[1];
    __pyx_v_doc = values[2];
    __pyx_v_require_sortable_dtype = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_comparison", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3780, __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_108create_comparison(__pyx_self, __pyx_v_name, __pyx_v_op, __pyx_v_doc, __pyx_v_require_sortable_dtype);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_108create_comparison(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_op, PyObject *__pyx_v_doc, PyObject *__pyx_v_require_sortable_dtype) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_create_comparison __pyx_t_2;
  __Pyx_RefNannySetupContext("create_comparison", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.doc = __pyx_v_doc;
  __pyx_t_2.require_sortable_dtype = __pyx_v_require_sortable_dtype;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_v_name, __pyx_v_op, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3780, __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":3888
 * 
 * 
 * cdef create_arithmetic(name, op, boolop, doc):             # <<<<<<<<<<<<<<
 *     return create_ufunc(
 *         'cupy_' + name,
 */

static PyObject *__pyx_f_4cupy_4core_4core_create_arithmetic(PyObject *__pyx_v_name, PyObject *__pyx_v_op, PyObject *__pyx_v_boolop, PyObject *__pyx_v_doc) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("create_arithmetic", 0);

  /* "cupy/core/core.pyx":3889
 * 
 * cdef create_arithmetic(name, op, boolop, doc):
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         (('??->?', 'out0 = in0 %s in1' % boolop),
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3889, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":3890
 * cdef create_arithmetic(name, op, boolop, doc):
 *     return create_ufunc(
 *         'cupy_' + name,             # <<<<<<<<<<<<<<
 *         (('??->?', 'out0 = in0 %s in1' % boolop),
 *          'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
 */
  __pyx_t_2 = PyNumber_Add(__pyx_n_s_cupy_2, __pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/core.pyx":3891
 *     return create_ufunc(
 *         'cupy_' + name,
 *         (('??->?', 'out0 = in0 %s in1' % boolop),             # <<<<<<<<<<<<<<
 *          'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
 *          'LL->L', 'qq->q', 'QQ->Q', 'ee->e', 'ff->f', 'dd->d', 'FF->F',
 */
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_out0_in0_s_in1, __pyx_v_boolop); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_kp_s__128);
  __Pyx_GIVEREF(__pyx_kp_s__128);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_s__128);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __Pyx_INCREF(__pyx_kp_s_bb_b);
  __Pyx_GIVEREF(__pyx_kp_s_bb_b);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_kp_s_bb_b);
  __Pyx_INCREF(__pyx_kp_s_BB_B);
  __Pyx_GIVEREF(__pyx_kp_s_BB_B);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_s_BB_B);
  __Pyx_INCREF(__pyx_kp_s_hh_h);
  __Pyx_GIVEREF(__pyx_kp_s_hh_h);
  PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_kp_s_hh_h);
  __Pyx_INCREF(__pyx_kp_s_HH_H);
  __Pyx_GIVEREF(__pyx_kp_s_HH_H);
  PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_kp_s_HH_H);
  __Pyx_INCREF(__pyx_kp_s_ii_i);
  __Pyx_GIVEREF(__pyx_kp_s_ii_i);
  PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_kp_s_ii_i);
  __Pyx_INCREF(__pyx_kp_s_II_I);
  __Pyx_GIVEREF(__pyx_kp_s_II_I);
  PyTuple_SET_ITEM(__pyx_t_3, 6, __pyx_kp_s_II_I);
  __Pyx_INCREF(__pyx_kp_s_ll_l);
  __Pyx_GIVEREF(__pyx_kp_s_ll_l);
  PyTuple_SET_ITEM(__pyx_t_3, 7, __pyx_kp_s_ll_l);
  __Pyx_INCREF(__pyx_kp_s_LL_L);
  __Pyx_GIVEREF(__pyx_kp_s_LL_L);
  PyTuple_SET_ITEM(__pyx_t_3, 8, __pyx_kp_s_LL_L);
  __Pyx_INCREF(__pyx_kp_s_qq_q);
  __Pyx_GIVEREF(__pyx_kp_s_qq_q);
  PyTuple_SET_ITEM(__pyx_t_3, 9, __pyx_kp_s_qq_q);
  __Pyx_INCREF(__pyx_kp_s_QQ_Q);
  __Pyx_GIVEREF(__pyx_kp_s_QQ_Q);
  PyTuple_SET_ITEM(__pyx_t_3, 10, __pyx_kp_s_QQ_Q);
  __Pyx_INCREF(__pyx_kp_s_ee_e);
  __Pyx_GIVEREF(__pyx_kp_s_ee_e);
  PyTuple_SET_ITEM(__pyx_t_3, 11, __pyx_kp_s_ee_e);
  __Pyx_INCREF(__pyx_kp_s_ff_f);
  __Pyx_GIVEREF(__pyx_kp_s_ff_f);
  PyTuple_SET_ITEM(__pyx_t_3, 12, __pyx_kp_s_ff_f);
  __Pyx_INCREF(__pyx_kp_s_dd_d);
  __Pyx_GIVEREF(__pyx_kp_s_dd_d);
  PyTuple_SET_ITEM(__pyx_t_3, 13, __pyx_kp_s_dd_d);
  __Pyx_INCREF(__pyx_kp_s_FF_F);
  __Pyx_GIVEREF(__pyx_kp_s_FF_F);
  PyTuple_SET_ITEM(__pyx_t_3, 14, __pyx_kp_s_FF_F);
  __Pyx_INCREF(__pyx_kp_s_DD_D);
  __Pyx_GIVEREF(__pyx_kp_s_DD_D);
  PyTuple_SET_ITEM(__pyx_t_3, 15, __pyx_kp_s_DD_D);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":3895
 *          'LL->L', 'qq->q', 'QQ->Q', 'ee->e', 'ff->f', 'dd->d', 'FF->F',
 *          'DD->D'),
 *         'out0 = in0 %s in1' % op,             # <<<<<<<<<<<<<<
 *         doc=doc)
 * 
 */
  __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_out0_in0_s_in1, __pyx_v_op); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3895, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":3889
 * 
 * cdef create_arithmetic(name, op, boolop, doc):
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         (('??->?', 'out0 = in0 %s in1' % boolop),
 */
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3889, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":3896
 *          'DD->D'),
 *         'out0 = in0 %s in1' % op,
 *         doc=doc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3896, __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, 3896, __pyx_L1_error)

  /* "cupy/core/core.pyx":3889
 * 
 * cdef create_arithmetic(name, op, boolop, doc):
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         (('??->?', 'out0 = in0 %s in1' % boolop),
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3889, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3888
 * 
 * 
 * cdef create_arithmetic(name, op, boolop, doc):             # <<<<<<<<<<<<<<
 *     return create_ufunc(
 *         'cupy_' + name,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.create_arithmetic", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":4123
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                    keepdims=False):
 *     assert a.dtype.kind != 'c', 'Variance for complex numbers is not ' \
 */

static PyObject *__pyx_pw_4cupy_4core_4core_111_var(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__var(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__var *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_ddof = ((PyObject *)__pyx_int_0);

  /* "cupy/core/core.pyx":4124
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,
 *                    keepdims=False):             # <<<<<<<<<<<<<<
 *     assert a.dtype.kind != 'c', 'Variance for complex numbers is not ' \
 *                                 'implemented. Current implemention does not ' \
 */
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_items = NULL;
  PyObject *__pyx_v_ax = NULL;
  PyObject *__pyx_v_alpha = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arrmean = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  long __pyx_t_10;
  __Pyx_RefNannySetupContext("_var", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_dtype = __pyx_optional_args->dtype;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_ddof = __pyx_optional_args->ddof;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_keepdims = __pyx_optional_args->keepdims;
            }
          }
        }
      }
    }
  }
  __Pyx_INCREF(__pyx_v_axis);
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/core.pyx":4125
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,
 *                    keepdims=False):
 *     assert a.dtype.kind != 'c', 'Variance for complex numbers is not ' \             # <<<<<<<<<<<<<<
 *                                 'implemented. Current implemention does not ' \
 *                                 'convert the dtype'
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4125, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_c, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 4125, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_2)) {
      PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Variance_for_complex_numbers_is);
      __PYX_ERR(0, 4125, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/core/core.pyx":4128
 *                                 'implemented. Current implemention does not ' \
 *                                 'convert the dtype'
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         axis = tuple(range(a.ndim))
 *     if not isinstance(axis, tuple):
 */
  __pyx_t_2 = (__pyx_v_axis == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":4129
 *                                 'convert the dtype'
 *     if axis is None:
 *         axis = tuple(range(a.ndim))             # <<<<<<<<<<<<<<
 *     if not isinstance(axis, tuple):
 *         axis = (axis,)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4129, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4129, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4129, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4129, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":4128
 *                                 'implemented. Current implemention does not ' \
 *                                 'convert the dtype'
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         axis = tuple(range(a.ndim))
 *     if not isinstance(axis, tuple):
 */
  }

  /* "cupy/core/core.pyx":4130
 *     if axis is None:
 *         axis = tuple(range(a.ndim))
 *     if not isinstance(axis, tuple):             # <<<<<<<<<<<<<<
 *         axis = (axis,)
 * 
 */
  __pyx_t_3 = PyTuple_Check(__pyx_v_axis); 
  __pyx_t_2 = ((!(__pyx_t_3 != 0)) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":4131
 *         axis = tuple(range(a.ndim))
 *     if not isinstance(axis, tuple):
 *         axis = (axis,)             # <<<<<<<<<<<<<<
 * 
 *     if dtype is None and issubclass(a.dtype.type,
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4131, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_axis);
    __Pyx_GIVEREF(__pyx_v_axis);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_axis);
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":4130
 *     if axis is None:
 *         axis = tuple(range(a.ndim))
 *     if not isinstance(axis, tuple):             # <<<<<<<<<<<<<<
 *         axis = (axis,)
 * 
 */
  }

  /* "cupy/core/core.pyx":4133
 *         axis = (axis,)
 * 
 *     if dtype is None and issubclass(a.dtype.type,             # <<<<<<<<<<<<<<
 *                                     (numpy.integer, numpy.bool_)):
 *         dtype = 'd'
 */
  __pyx_t_3 = (__pyx_v_dtype == Py_None);
  __pyx_t_5 = (__pyx_t_3 != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_2 = __pyx_t_5;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":4134
 * 
 *     if dtype is None and issubclass(a.dtype.type,
 *                                     (numpy.integer, numpy.bool_)):             # <<<<<<<<<<<<<<
 *         dtype = 'd'
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_integer); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_bool); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_7);
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4133
 *         axis = (axis,)
 * 
 *     if dtype is None and issubclass(a.dtype.type,             # <<<<<<<<<<<<<<
 *                                     (numpy.integer, numpy.bool_)):
 *         dtype = 'd'
 */
  __pyx_t_5 = PyObject_IsSubclass(__pyx_t_4, __pyx_t_1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 4133, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_5 != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":4135
 *     if dtype is None and issubclass(a.dtype.type,
 *                                     (numpy.integer, numpy.bool_)):
 *         dtype = 'd'             # <<<<<<<<<<<<<<
 * 
 *     shape = a.shape
 */
    __Pyx_INCREF(__pyx_n_s_d);
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_n_s_d);

    /* "cupy/core/core.pyx":4133
 *         axis = (axis,)
 * 
 *     if dtype is None and issubclass(a.dtype.type,             # <<<<<<<<<<<<<<
 *                                     (numpy.integer, numpy.bool_)):
 *         dtype = 'd'
 */
  }

  /* "cupy/core/core.pyx":4137
 *         dtype = 'd'
 * 
 *     shape = a.shape             # <<<<<<<<<<<<<<
 *     items = 1
 *     for ax in axis:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4137, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_shape = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4138
 * 
 *     shape = a.shape
 *     items = 1             # <<<<<<<<<<<<<<
 *     for ax in axis:
 *         items *= shape[ax]
 */
  __Pyx_INCREF(__pyx_int_1);
  __pyx_v_items = __pyx_int_1;

  /* "cupy/core/core.pyx":4139
 *     shape = a.shape
 *     items = 1
 *     for ax in axis:             # <<<<<<<<<<<<<<
 *         items *= shape[ax]
 *     alpha = 1. / max(items - ddof, 0)
 */
  if (likely(PyList_CheckExact(__pyx_v_axis)) || PyTuple_CheckExact(__pyx_v_axis)) {
    __pyx_t_1 = __pyx_v_axis; __Pyx_INCREF(__pyx_t_1); __pyx_t_8 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_axis); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4139, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4139, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_9)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_8 >= 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_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 4139, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4139, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_8 >= 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_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 4139, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4139, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_9(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 4139, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_ax, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":4140
 *     items = 1
 *     for ax in axis:
 *         items *= shape[ax]             # <<<<<<<<<<<<<<
 *     alpha = 1. / max(items - ddof, 0)
 *     arrmean = a.mean(axis=axis, dtype=dtype, keepdims=True)
 */
    __pyx_t_4 = PyObject_GetItem(__pyx_v_shape, __pyx_v_ax); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4140, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = PyNumber_InPlaceMultiply(__pyx_v_items, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4140, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_items, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":4139
 *     shape = a.shape
 *     items = 1
 *     for ax in axis:             # <<<<<<<<<<<<<<
 *         items *= shape[ax]
 *     alpha = 1. / max(items - ddof, 0)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4141
 *     for ax in axis:
 *         items *= shape[ax]
 *     alpha = 1. / max(items - ddof, 0)             # <<<<<<<<<<<<<<
 *     arrmean = a.mean(axis=axis, dtype=dtype, keepdims=True)
 *     if out is None:
 */
  __pyx_t_10 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_v_items, __pyx_v_ddof); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyObject_RichCompare(__pyx_t_4, __pyx_t_1, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4141, __pyx_L1_error)
  __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, 4141, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_2) {
    __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4141, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __pyx_t_6;
    __pyx_t_6 = 0;
  } else {
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_7 = __pyx_t_1;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyFloat_TrueDivideCObj(__pyx_float_1_, __pyx_t_7, 1., 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_alpha = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4142
 *         items *= shape[ax]
 *     alpha = 1. / max(items - ddof, 0)
 *     arrmean = a.mean(axis=axis, dtype=dtype, keepdims=True)             # <<<<<<<<<<<<<<
 *     if out is None:
 *         return _var_core(a, arrmean, alpha, axis=axis, keepdims=keepdims)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_mean); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 4142, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 4142, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_keepdims, Py_True) < 0) __PYX_ERR(0, 4142, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 4142, __pyx_L1_error)
  __pyx_v_arrmean = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":4143
 *     alpha = 1. / max(items - ddof, 0)
 *     arrmean = a.mean(axis=axis, dtype=dtype, keepdims=True)
 *     if out is None:             # <<<<<<<<<<<<<<
 *         return _var_core(a, arrmean, alpha, axis=axis, keepdims=keepdims)
 *     else:
 */
  __pyx_t_2 = (__pyx_v_out == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":4144
 *     arrmean = a.mean(axis=axis, dtype=dtype, keepdims=True)
 *     if out is None:
 *         return _var_core(a, arrmean, alpha, axis=axis, keepdims=keepdims)             # <<<<<<<<<<<<<<
 *     else:
 *         return _var_core_out(
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4144, __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_arrmean));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_arrmean));
    PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_arrmean));
    __Pyx_INCREF(__pyx_v_alpha);
    __Pyx_GIVEREF(__pyx_v_alpha);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_alpha);
    __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4144, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 4144, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 4144, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__var_core, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4144, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 4144, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":4143
 *     alpha = 1. / max(items - ddof, 0)
 *     arrmean = a.mean(axis=axis, dtype=dtype, keepdims=True)
 *     if out is None:             # <<<<<<<<<<<<<<
 *         return _var_core(a, arrmean, alpha, axis=axis, keepdims=keepdims)
 *     else:
 */
  }

  /* "cupy/core/core.pyx":4146
 *         return _var_core(a, arrmean, alpha, axis=axis, keepdims=keepdims)
 *     else:
 *         return _var_core_out(             # <<<<<<<<<<<<<<
 *             a, arrmean, alpha, out, axis=axis, keepdims=keepdims)
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));

    /* "cupy/core/core.pyx":4147
 *     else:
 *         return _var_core_out(
 *             a, arrmean, alpha, out, axis=axis, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_a));
    __Pyx_INCREF(((PyObject *)__pyx_v_arrmean));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_arrmean));
    PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_arrmean));
    __Pyx_INCREF(__pyx_v_alpha);
    __Pyx_GIVEREF(__pyx_v_alpha);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_alpha);
    __Pyx_INCREF(__pyx_v_out);
    __Pyx_GIVEREF(__pyx_v_out);
    PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_out);
    __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 4147, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 4147, __pyx_L1_error)

    /* "cupy/core/core.pyx":4146
 *         return _var_core(a, arrmean, alpha, axis=axis, keepdims=keepdims)
 *     else:
 *         return _var_core_out(             # <<<<<<<<<<<<<<
 *             a, arrmean, alpha, out, axis=axis, keepdims=keepdims)
 * 
 */
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__var_core_out, __pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 4146, __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":4123
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                    keepdims=False):
 *     assert a.dtype.kind != 'c', 'Variance for complex numbers is not ' \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core._var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_ax);
  __Pyx_XDECREF(__pyx_v_alpha);
  __Pyx_XDECREF((PyObject *)__pyx_v_arrmean);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_111_var(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_110_var[] = "_var(ndarray a, axis=None, dtype=None, out=None, ddof=0, keepdims=False) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_111_var(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_ddof = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_var (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_axis,&__pyx_n_s_dtype,&__pyx_n_s_out,&__pyx_n_s_ddof,&__pyx_n_s_keepdims,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)__pyx_int_0);

    /* "cupy/core/core.pyx":4124
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,
 *                    keepdims=False):             # <<<<<<<<<<<<<<
 *     assert a.dtype.kind != 'c', 'Variance for complex numbers is not ' \
 *                                 'implemented. Current implemention does not ' \
 */
    values[5] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__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 = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ddof);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_var") < 0)) __PYX_ERR(0, 4123, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_axis = values[1];
    __pyx_v_dtype = values[2];
    __pyx_v_out = values[3];
    __pyx_v_ddof = values[4];
    __pyx_v_keepdims = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_var", 0, 1, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4123, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 4123, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_110_var(__pyx_self, __pyx_v_a, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_ddof, __pyx_v_keepdims);

  /* "cupy/core/core.pyx":4123
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                    keepdims=False):
 *     assert a.dtype.kind != 'c', 'Variance for complex numbers is not ' \
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_110_var(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_ddof, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__var __pyx_t_2;
  __Pyx_RefNannySetupContext("_var", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 5;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.ddof = __pyx_v_ddof;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__var(__pyx_v_a, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":4150
 * 
 * 
 * cpdef _std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False):             # <<<<<<<<<<<<<<
 *     ret = _var(a, axis=axis, dtype=dtype, ddof=ddof, keepdims=keepdims)
 *     return sqrt(ret, dtype=dtype, out=out)
 */

static PyObject *__pyx_pw_4cupy_4core_4core_113_std(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__std(PyObject *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__std *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_ddof = ((PyObject *)__pyx_int_0);
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("_std", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_dtype = __pyx_optional_args->dtype;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_ddof = __pyx_optional_args->ddof;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_keepdims = __pyx_optional_args->keepdims;
            }
          }
        }
      }
    }
  }

  /* "cupy/core/core.pyx":4151
 * 
 * cpdef _std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False):
 *     ret = _var(a, axis=axis, dtype=dtype, ddof=ddof, keepdims=keepdims)             # <<<<<<<<<<<<<<
 *     return sqrt(ret, dtype=dtype, out=out)
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_var_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_a);
  __Pyx_GIVEREF(__pyx_v_a);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_a);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 4151, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 4151, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_ddof, __pyx_v_ddof) < 0) __PYX_ERR(0, 4151, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 4151, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 4151, __pyx_L1_error)
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":4152
 * cpdef _std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False):
 *     ret = _var(a, axis=axis, dtype=dtype, ddof=ddof, keepdims=keepdims)
 *     return sqrt(ret, dtype=dtype, out=out)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_sqrt); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_ret));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_ret));
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 4152, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 4152, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":4150
 * 
 * 
 * cpdef _std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False):             # <<<<<<<<<<<<<<
 *     ret = _var(a, axis=axis, dtype=dtype, ddof=ddof, keepdims=keepdims)
 *     return sqrt(ret, dtype=dtype, out=out)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core._std", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_113_std(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_112_std[] = "_std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False)";
static PyObject *__pyx_pw_4cupy_4core_4core_113_std(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_ddof = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_std (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_axis,&__pyx_n_s_dtype,&__pyx_n_s_out,&__pyx_n_s_ddof,&__pyx_n_s_keepdims,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)__pyx_int_0);
    values[5] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__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 = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ddof);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_std") < 0)) __PYX_ERR(0, 4150, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = values[0];
    __pyx_v_axis = values[1];
    __pyx_v_dtype = values[2];
    __pyx_v_out = values[3];
    __pyx_v_ddof = values[4];
    __pyx_v_keepdims = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_std", 0, 1, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4150, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._std", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_112_std(__pyx_self, __pyx_v_a, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_ddof, __pyx_v_keepdims);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_112_std(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_ddof, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__std __pyx_t_2;
  __Pyx_RefNannySetupContext("_std", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 5;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.ddof = __pyx_v_ddof;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__std(__pyx_v_a, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._std", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":4181
 * 
 * @util.memoize(for_each_device=True)
 * def _inclusive_scan_kernel(dtype, block_size):             # <<<<<<<<<<<<<<
 *     """return Prefix Sum(Scan) cuda kernel
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_115_inclusive_scan_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_114_inclusive_scan_kernel[] = "_inclusive_scan_kernel(dtype, block_size)\nreturn Prefix Sum(Scan) cuda kernel\n\n    e.g\n    if blocksize * 2 >= len(src)\n    src [1, 2, 3, 4]\n    dst [1, 3, 6, 10]\n\n    if blocksize * 2 < len(src)\n    block_size: 2\n    src [1, 2, 3, 4, 5, 6]\n    dst [1, 3, 6, 10, 5, 11]\n\n    Args:\n        dtype: src, dst array type\n        block_size: block_size\n\n    Returns:\n         cupy.cuda.Function: cuda function\n    ";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_115_inclusive_scan_kernel = {"_inclusive_scan_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_115_inclusive_scan_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_114_inclusive_scan_kernel};
static PyObject *__pyx_pw_4cupy_4core_4core_115_inclusive_scan_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_block_size = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_inclusive_scan_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dtype,&__pyx_n_s_block_size,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_block_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_inclusive_scan_kernel", 1, 2, 2, 1); __PYX_ERR(0, 4181, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_inclusive_scan_kernel") < 0)) __PYX_ERR(0, 4181, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_dtype = values[0];
    __pyx_v_block_size = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_inclusive_scan_kernel", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4181, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._inclusive_scan_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_114_inclusive_scan_kernel(__pyx_self, __pyx_v_dtype, __pyx_v_block_size);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_114_inclusive_scan_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype, PyObject *__pyx_v_block_size) {
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_source = NULL;
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_v_module = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_inclusive_scan_kernel", 0);
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/core.pyx":4202
 *     """
 * 
 *     name = "inclusive_scan_kernel"             # <<<<<<<<<<<<<<
 *     dtype = _get_typename(dtype)
 *     source = string.Template("""
 */
  __Pyx_INCREF(__pyx_n_s_inclusive_scan_kernel);
  __pyx_v_name = __pyx_n_s_inclusive_scan_kernel;

  /* "cupy/core/core.pyx":4203
 * 
 *     name = "inclusive_scan_kernel"
 *     dtype = _get_typename(dtype)             # <<<<<<<<<<<<<<
 *     source = string.Template("""
 *     extern "C" __global__ void ${name}(const CArray<${dtype}, 1> src,
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4203, __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":4204
 *     name = "inclusive_scan_kernel"
 *     dtype = _get_typename(dtype)
 *     source = string.Template("""             # <<<<<<<<<<<<<<
 *     extern "C" __global__ void ${name}(const CArray<${dtype}, 1> src,
 *         CArray<${dtype}, 1> dst){
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Template); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__196, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":4242
 *         }
 *     }
 *     """).substitute(name=name, dtype=dtype, block_size=block_size)             # <<<<<<<<<<<<<<
 *     module = compile_with_cache(source)
 *     return module.get_function(name)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_substitute); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(0, 4242, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 4242, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_block_size, __pyx_v_block_size) < 0) __PYX_ERR(0, 4242, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_source = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4243
 *     }
 *     """).substitute(name=name, dtype=dtype, block_size=block_size)
 *     module = compile_with_cache(source)             # <<<<<<<<<<<<<<
 *     return module.get_function(name)
 * 
 */
  if (!(likely(PyString_CheckExact(__pyx_v_source))||((__pyx_v_source) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_source)->tp_name), 0))) __PYX_ERR(0, 4243, __pyx_L1_error)
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_compile_with_cache(((PyObject*)__pyx_v_source), 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4243, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_module = ((struct __pyx_obj_4cupy_4cuda_8function_Module *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4244
 *     """).substitute(name=name, dtype=dtype, block_size=block_size)
 *     module = compile_with_cache(source)
 *     return module.get_function(name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyString_CheckExact(__pyx_v_name))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(0, 4244, __pyx_L1_error)
  __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Module *)__pyx_v_module->__pyx_vtab)->get_function(__pyx_v_module, ((PyObject*)__pyx_v_name), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":4181
 * 
 * @util.memoize(for_each_device=True)
 * def _inclusive_scan_kernel(dtype, block_size):             # <<<<<<<<<<<<<<
 *     """return Prefix Sum(Scan) cuda kernel
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core._inclusive_scan_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_source);
  __Pyx_XDECREF((PyObject *)__pyx_v_module);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":4248
 * 
 * @util.memoize(for_each_device=True)
 * def _add_scan_blocked_sum_kernel(dtype):             # <<<<<<<<<<<<<<
 *     name = "add_scan_blocked_sum_kernel"
 *     dtype = _get_typename(dtype)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_117_add_scan_blocked_sum_kernel(PyObject *__pyx_self, PyObject *__pyx_v_dtype); /*proto*/
static char __pyx_doc_4cupy_4core_4core_116_add_scan_blocked_sum_kernel[] = "_add_scan_blocked_sum_kernel(dtype)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_117_add_scan_blocked_sum_kernel = {"_add_scan_blocked_sum_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_117_add_scan_blocked_sum_kernel, METH_O, __pyx_doc_4cupy_4core_4core_116_add_scan_blocked_sum_kernel};
static PyObject *__pyx_pw_4cupy_4core_4core_117_add_scan_blocked_sum_kernel(PyObject *__pyx_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_add_scan_blocked_sum_kernel (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_116_add_scan_blocked_sum_kernel(__pyx_self, ((PyObject *)__pyx_v_dtype));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_116_add_scan_blocked_sum_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_source = NULL;
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_v_module = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_add_scan_blocked_sum_kernel", 0);
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/core.pyx":4249
 * @util.memoize(for_each_device=True)
 * def _add_scan_blocked_sum_kernel(dtype):
 *     name = "add_scan_blocked_sum_kernel"             # <<<<<<<<<<<<<<
 *     dtype = _get_typename(dtype)
 *     source = string.Template("""
 */
  __Pyx_INCREF(__pyx_n_s_add_scan_blocked_sum_kernel);
  __pyx_v_name = __pyx_n_s_add_scan_blocked_sum_kernel;

  /* "cupy/core/core.pyx":4250
 * def _add_scan_blocked_sum_kernel(dtype):
 *     name = "add_scan_blocked_sum_kernel"
 *     dtype = _get_typename(dtype)             # <<<<<<<<<<<<<<
 *     source = string.Template("""
 *     extern "C" __global__ void ${name}(CArray<${dtype}, 1> src_dst){
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4250, __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":4251
 *     name = "add_scan_blocked_sum_kernel"
 *     dtype = _get_typename(dtype)
 *     source = string.Template("""             # <<<<<<<<<<<<<<
 *     extern "C" __global__ void ${name}(CArray<${dtype}, 1> src_dst){
 *         long long n = src_dst.size();
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Template); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__197, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":4262
 *         }
 *     }
 *     """).substitute(name=name, dtype=dtype)             # <<<<<<<<<<<<<<
 *     module = compile_with_cache(source)
 *     return module.get_function(name)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_substitute); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4262, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4262, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(0, 4262, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 4262, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4262, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_source = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4263
 *     }
 *     """).substitute(name=name, dtype=dtype)
 *     module = compile_with_cache(source)             # <<<<<<<<<<<<<<
 *     return module.get_function(name)
 * 
 */
  if (!(likely(PyString_CheckExact(__pyx_v_source))||((__pyx_v_source) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_source)->tp_name), 0))) __PYX_ERR(0, 4263, __pyx_L1_error)
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_compile_with_cache(((PyObject*)__pyx_v_source), 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_module = ((struct __pyx_obj_4cupy_4cuda_8function_Module *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4264
 *     """).substitute(name=name, dtype=dtype)
 *     module = compile_with_cache(source)
 *     return module.get_function(name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyString_CheckExact(__pyx_v_name))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(0, 4264, __pyx_L1_error)
  __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Module *)__pyx_v_module->__pyx_vtab)->get_function(__pyx_v_module, ((PyObject*)__pyx_v_name), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":4248
 * 
 * @util.memoize(for_each_device=True)
 * def _add_scan_blocked_sum_kernel(dtype):             # <<<<<<<<<<<<<<
 *     name = "add_scan_blocked_sum_kernel"
 *     dtype = _get_typename(dtype)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core._add_scan_blocked_sum_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_source);
  __Pyx_XDECREF((PyObject *)__pyx_v_module);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":4268
 * 
 * @util.memoize(for_each_device=True)
 * def _nonzero_1d_kernel(src_dtype, index_dtype):             # <<<<<<<<<<<<<<
 *     name = "nonzero_1d_kernel"
 *     src_dtype = _get_typename(src_dtype)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_119_nonzero_1d_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_118_nonzero_1d_kernel[] = "_nonzero_1d_kernel(src_dtype, index_dtype)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_119_nonzero_1d_kernel = {"_nonzero_1d_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_119_nonzero_1d_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_118_nonzero_1d_kernel};
static PyObject *__pyx_pw_4cupy_4core_4core_119_nonzero_1d_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_src_dtype = 0;
  PyObject *__pyx_v_index_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_nonzero_1d_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_src_dtype,&__pyx_n_s_index_dtype,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_src_dtype)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_index_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_nonzero_1d_kernel", 1, 2, 2, 1); __PYX_ERR(0, 4268, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_nonzero_1d_kernel") < 0)) __PYX_ERR(0, 4268, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_src_dtype = values[0];
    __pyx_v_index_dtype = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_nonzero_1d_kernel", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4268, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._nonzero_1d_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_118_nonzero_1d_kernel(__pyx_self, __pyx_v_src_dtype, __pyx_v_index_dtype);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_118_nonzero_1d_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_src_dtype, PyObject *__pyx_v_index_dtype) {
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_source = NULL;
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_v_module = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_nonzero_1d_kernel", 0);
  __Pyx_INCREF(__pyx_v_src_dtype);
  __Pyx_INCREF(__pyx_v_index_dtype);

  /* "cupy/core/core.pyx":4269
 * @util.memoize(for_each_device=True)
 * def _nonzero_1d_kernel(src_dtype, index_dtype):
 *     name = "nonzero_1d_kernel"             # <<<<<<<<<<<<<<
 *     src_dtype = _get_typename(src_dtype)
 *     index_dtype = _get_typename(index_dtype)
 */
  __Pyx_INCREF(__pyx_n_s_nonzero_1d_kernel_2);
  __pyx_v_name = __pyx_n_s_nonzero_1d_kernel_2;

  /* "cupy/core/core.pyx":4270
 * def _nonzero_1d_kernel(src_dtype, index_dtype):
 *     name = "nonzero_1d_kernel"
 *     src_dtype = _get_typename(src_dtype)             # <<<<<<<<<<<<<<
 *     index_dtype = _get_typename(index_dtype)
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_src_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_src_dtype, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4271
 *     name = "nonzero_1d_kernel"
 *     src_dtype = _get_typename(src_dtype)
 *     index_dtype = _get_typename(index_dtype)             # <<<<<<<<<<<<<<
 * 
 *     source = string.Template("""
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_index_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_index_dtype, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4273
 *     index_dtype = _get_typename(index_dtype)
 * 
 *     source = string.Template("""             # <<<<<<<<<<<<<<
 *     extern "C" __global__ void ${name}(const CArray<${src_dtype}, 1> src,
 *         const CArray<${index_dtype}, 1> scaned_index,
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Template); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__198, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":4285
 *         }
 *     }
 *     """).substitute(name=name, src_dtype=src_dtype, index_dtype=index_dtype)             # <<<<<<<<<<<<<<
 *     module = compile_with_cache(source)
 *     return module.get_function(name)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_substitute); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(0, 4285, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_src_dtype, __pyx_v_src_dtype) < 0) __PYX_ERR(0, 4285, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_index_dtype, __pyx_v_index_dtype) < 0) __PYX_ERR(0, 4285, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_source = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4286
 *     }
 *     """).substitute(name=name, src_dtype=src_dtype, index_dtype=index_dtype)
 *     module = compile_with_cache(source)             # <<<<<<<<<<<<<<
 *     return module.get_function(name)
 * 
 */
  if (!(likely(PyString_CheckExact(__pyx_v_source))||((__pyx_v_source) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_source)->tp_name), 0))) __PYX_ERR(0, 4286, __pyx_L1_error)
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_compile_with_cache(((PyObject*)__pyx_v_source), 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_module = ((struct __pyx_obj_4cupy_4cuda_8function_Module *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4287
 *     """).substitute(name=name, src_dtype=src_dtype, index_dtype=index_dtype)
 *     module = compile_with_cache(source)
 *     return module.get_function(name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyString_CheckExact(__pyx_v_name))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(0, 4287, __pyx_L1_error)
  __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Module *)__pyx_v_module->__pyx_vtab)->get_function(__pyx_v_module, ((PyObject*)__pyx_v_name), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":4268
 * 
 * @util.memoize(for_each_device=True)
 * def _nonzero_1d_kernel(src_dtype, index_dtype):             # <<<<<<<<<<<<<<
 *     name = "nonzero_1d_kernel"
 *     src_dtype = _get_typename(src_dtype)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core._nonzero_1d_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_source);
  __Pyx_XDECREF((PyObject *)__pyx_v_module);
  __Pyx_XDECREF(__pyx_v_src_dtype);
  __Pyx_XDECREF(__pyx_v_index_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":4291
 * 
 * @util.memoize(for_each_device=True)
 * def _nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype):             # <<<<<<<<<<<<<<
 *     name = "nonzero_kernel"
 *     src_dtype = _get_typename(src_dtype)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_121_nonzero_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_120_nonzero_kernel[] = "_nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_121_nonzero_kernel = {"_nonzero_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_121_nonzero_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_120_nonzero_kernel};
static PyObject *__pyx_pw_4cupy_4core_4core_121_nonzero_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_src_dtype = 0;
  PyObject *__pyx_v_src_ndim = 0;
  PyObject *__pyx_v_index_dtype = 0;
  PyObject *__pyx_v_dst_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_nonzero_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_src_dtype,&__pyx_n_s_src_ndim,&__pyx_n_s_index_dtype,&__pyx_n_s_dst_dtype,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_src_dtype)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_src_ndim)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_nonzero_kernel", 1, 4, 4, 1); __PYX_ERR(0, 4291, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_index_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_nonzero_kernel", 1, 4, 4, 2); __PYX_ERR(0, 4291, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dst_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_nonzero_kernel", 1, 4, 4, 3); __PYX_ERR(0, 4291, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_nonzero_kernel") < 0)) __PYX_ERR(0, 4291, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_src_dtype = values[0];
    __pyx_v_src_ndim = values[1];
    __pyx_v_index_dtype = values[2];
    __pyx_v_dst_dtype = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_nonzero_kernel", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4291, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._nonzero_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_120_nonzero_kernel(__pyx_self, __pyx_v_src_dtype, __pyx_v_src_ndim, __pyx_v_index_dtype, __pyx_v_dst_dtype);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_120_nonzero_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_src_dtype, PyObject *__pyx_v_src_ndim, PyObject *__pyx_v_index_dtype, PyObject *__pyx_v_dst_dtype) {
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_source = NULL;
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_v_module = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_nonzero_kernel", 0);
  __Pyx_INCREF(__pyx_v_src_dtype);
  __Pyx_INCREF(__pyx_v_index_dtype);
  __Pyx_INCREF(__pyx_v_dst_dtype);

  /* "cupy/core/core.pyx":4292
 * @util.memoize(for_each_device=True)
 * def _nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype):
 *     name = "nonzero_kernel"             # <<<<<<<<<<<<<<
 *     src_dtype = _get_typename(src_dtype)
 *     index_dtype = _get_typename(index_dtype)
 */
  __Pyx_INCREF(__pyx_n_s_nonzero_kernel_2);
  __pyx_v_name = __pyx_n_s_nonzero_kernel_2;

  /* "cupy/core/core.pyx":4293
 * def _nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype):
 *     name = "nonzero_kernel"
 *     src_dtype = _get_typename(src_dtype)             # <<<<<<<<<<<<<<
 *     index_dtype = _get_typename(index_dtype)
 *     dst_dtype = _get_typename(dst_dtype)
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_src_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_src_dtype, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4294
 *     name = "nonzero_kernel"
 *     src_dtype = _get_typename(src_dtype)
 *     index_dtype = _get_typename(index_dtype)             # <<<<<<<<<<<<<<
 *     dst_dtype = _get_typename(dst_dtype)
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_index_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_index_dtype, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4295
 *     src_dtype = _get_typename(src_dtype)
 *     index_dtype = _get_typename(index_dtype)
 *     dst_dtype = _get_typename(dst_dtype)             # <<<<<<<<<<<<<<
 * 
 *     source = string.Template("""
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_dst_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_dst_dtype, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4297
 *     dst_dtype = _get_typename(dst_dtype)
 * 
 *     source = string.Template("""             # <<<<<<<<<<<<<<
 *         extern "C" __global__ void ${name}(const CArray<${src_dtype}, 1> src,
 *             CIndexer<${src_ndim}> shape,
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Template); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__199, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":4318
 *             }
 *         }
 *         """).substitute(name=name, src_dtype=src_dtype,             # <<<<<<<<<<<<<<
 *                         src_ndim=src_ndim, index_dtype=index_dtype,
 *                         dst_dtype=dst_dtype)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_substitute); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(0, 4318, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_src_dtype, __pyx_v_src_dtype) < 0) __PYX_ERR(0, 4318, __pyx_L1_error)

  /* "cupy/core/core.pyx":4319
 *         }
 *         """).substitute(name=name, src_dtype=src_dtype,
 *                         src_ndim=src_ndim, index_dtype=index_dtype,             # <<<<<<<<<<<<<<
 *                         dst_dtype=dst_dtype)
 *     module = compile_with_cache(source)
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_src_ndim, __pyx_v_src_ndim) < 0) __PYX_ERR(0, 4318, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_index_dtype, __pyx_v_index_dtype) < 0) __PYX_ERR(0, 4318, __pyx_L1_error)

  /* "cupy/core/core.pyx":4320
 *         """).substitute(name=name, src_dtype=src_dtype,
 *                         src_ndim=src_ndim, index_dtype=index_dtype,
 *                         dst_dtype=dst_dtype)             # <<<<<<<<<<<<<<
 *     module = compile_with_cache(source)
 *     return module.get_function(name)
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dst_dtype, __pyx_v_dst_dtype) < 0) __PYX_ERR(0, 4318, __pyx_L1_error)

  /* "cupy/core/core.pyx":4318
 *             }
 *         }
 *         """).substitute(name=name, src_dtype=src_dtype,             # <<<<<<<<<<<<<<
 *                         src_ndim=src_ndim, index_dtype=index_dtype,
 *                         dst_dtype=dst_dtype)
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_source = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4321
 *                         src_ndim=src_ndim, index_dtype=index_dtype,
 *                         dst_dtype=dst_dtype)
 *     module = compile_with_cache(source)             # <<<<<<<<<<<<<<
 *     return module.get_function(name)
 * 
 */
  if (!(likely(PyString_CheckExact(__pyx_v_source))||((__pyx_v_source) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_source)->tp_name), 0))) __PYX_ERR(0, 4321, __pyx_L1_error)
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_compile_with_cache(((PyObject*)__pyx_v_source), 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4321, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_module = ((struct __pyx_obj_4cupy_4cuda_8function_Module *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4322
 *                         dst_dtype=dst_dtype)
 *     module = compile_with_cache(source)
 *     return module.get_function(name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyString_CheckExact(__pyx_v_name))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(0, 4322, __pyx_L1_error)
  __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Module *)__pyx_v_module->__pyx_vtab)->get_function(__pyx_v_module, ((PyObject*)__pyx_v_name), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4322, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":4291
 * 
 * @util.memoize(for_each_device=True)
 * def _nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype):             # <<<<<<<<<<<<<<
 *     name = "nonzero_kernel"
 *     src_dtype = _get_typename(src_dtype)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core._nonzero_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_source);
  __Pyx_XDECREF((PyObject *)__pyx_v_module);
  __Pyx_XDECREF(__pyx_v_src_dtype);
  __Pyx_XDECREF(__pyx_v_index_dtype);
  __Pyx_XDECREF(__pyx_v_dst_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":4325
 * 
 * 
 * cpdef ndarray scan(ndarray a, ndarray out=None):             # <<<<<<<<<<<<<<
 *     """Return the prefix sum(scan) of the elements.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_123scan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_scan(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_scan *__pyx_optional_args) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);
  PyObject *__pyx_v_block_size = NULL;
  PyObject *__pyx_v_kern_scan = NULL;
  PyObject *__pyx_v_blocked_sum = NULL;
  PyObject *__pyx_v_kern_add = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_scan __pyx_t_8;
  __Pyx_RefNannySetupContext("scan", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_out = __pyx_optional_args->out;
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_out);

  /* "cupy/core/core.pyx":4337
 * 
 *     """
 *     if a.ndim != 1:             # <<<<<<<<<<<<<<
 *         raise TypeError("Input array should be 1D array.")
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_1, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4337, __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, 4337, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":4338
 *     """
 *     if a.ndim != 1:
 *         raise TypeError("Input array should be 1D array.")             # <<<<<<<<<<<<<<
 * 
 *     block_size = 256
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__200, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4338, __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, 4338, __pyx_L1_error)

    /* "cupy/core/core.pyx":4337
 * 
 *     """
 *     if a.ndim != 1:             # <<<<<<<<<<<<<<
 *         raise TypeError("Input array should be 1D array.")
 * 
 */
  }

  /* "cupy/core/core.pyx":4340
 *         raise TypeError("Input array should be 1D array.")
 * 
 *     block_size = 256             # <<<<<<<<<<<<<<
 * 
 *     if out is None:
 */
  __Pyx_INCREF(__pyx_int_256);
  __pyx_v_block_size = __pyx_int_256;

  /* "cupy/core/core.pyx":4342
 *     block_size = 256
 * 
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(a.shape, dtype=a.dtype)
 *     else:
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_out) == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":4343
 * 
 *     if out is None:
 *         out = ndarray(a.shape, dtype=a.dtype)             # <<<<<<<<<<<<<<
 *     else:
 *         if a.size != out.size:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4343, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4343, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4343, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) __PYX_ERR(0, 4343, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4343, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":4342
 *     block_size = 256
 * 
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(a.shape, dtype=a.dtype)
 *     else:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":4345
 *         out = ndarray(a.shape, dtype=a.dtype)
 *     else:
 *         if a.size != out.size:             # <<<<<<<<<<<<<<
 *             raise ValueError("Provided out is the wrong size")
 * 
 */
  /*else*/ {
    __pyx_t_4 = ((__pyx_v_a->size != __pyx_v_out->size) != 0);
    if (__pyx_t_4) {

      /* "cupy/core/core.pyx":4346
 *     else:
 *         if a.size != out.size:
 *             raise ValueError("Provided out is the wrong size")             # <<<<<<<<<<<<<<
 * 
 *     kern_scan = _inclusive_scan_kernel(a.dtype, block_size)
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__201, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4346, __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, 4346, __pyx_L1_error)

      /* "cupy/core/core.pyx":4345
 *         out = ndarray(a.shape, dtype=a.dtype)
 *     else:
 *         if a.size != out.size:             # <<<<<<<<<<<<<<
 *             raise ValueError("Provided out is the wrong size")
 * 
 */
    }
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":4348
 *             raise ValueError("Provided out is the wrong size")
 * 
 *     kern_scan = _inclusive_scan_kernel(a.dtype, block_size)             # <<<<<<<<<<<<<<
 *     kern_scan(grid=((a.size - 1) // (2 * block_size) + 1,),
 *               block=(block_size,),
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_inclusive_scan_kernel_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_a->dtype, __pyx_v_block_size};
    __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4348, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_a->dtype, __pyx_v_block_size};
    __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4348, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4348, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_INCREF(__pyx_v_a->dtype);
    __Pyx_GIVEREF(__pyx_v_a->dtype);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_a->dtype);
    __Pyx_INCREF(__pyx_v_block_size);
    __Pyx_GIVEREF(__pyx_v_block_size);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_block_size);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4348, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_kern_scan = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":4349
 * 
 *     kern_scan = _inclusive_scan_kernel(a.dtype, block_size)
 *     kern_scan(grid=((a.size - 1) // (2 * block_size) + 1,),             # <<<<<<<<<<<<<<
 *               block=(block_size,),
 *               args=(a, out),
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = PyInt_FromSsize_t((__pyx_v_a->size - 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = PyNumber_Multiply(__pyx_int_2, __pyx_v_block_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = PyNumber_FloorDivide(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
  __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_grid, __pyx_t_1) < 0) __PYX_ERR(0, 4349, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4350
 *     kern_scan = _inclusive_scan_kernel(a.dtype, block_size)
 *     kern_scan(grid=((a.size - 1) // (2 * block_size) + 1,),
 *               block=(block_size,),             # <<<<<<<<<<<<<<
 *               args=(a, out),
 *               shared_mem=a.itemsize * block_size * 2)
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_block_size);
  __Pyx_GIVEREF(__pyx_v_block_size);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_block_size);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_block, __pyx_t_1) < 0) __PYX_ERR(0, 4349, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4351
 *     kern_scan(grid=((a.size - 1) // (2 * block_size) + 1,),
 *               block=(block_size,),
 *               args=(a, out),             # <<<<<<<<<<<<<<
 *               shared_mem=a.itemsize * block_size * 2)
 * 
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_a));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_a));
  __Pyx_INCREF(((PyObject *)__pyx_v_out));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_out));
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_args, __pyx_t_1) < 0) __PYX_ERR(0, 4349, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4352
 *               block=(block_size,),
 *               args=(a, out),
 *               shared_mem=a.itemsize * block_size * 2)             # <<<<<<<<<<<<<<
 * 
 *     if (a.size - 1) // (block_size * 2) > 0:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyNumber_Multiply(__pyx_t_1, __pyx_v_block_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Multiply(__pyx_t_7, __pyx_int_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_shared_mem, __pyx_t_1) < 0) __PYX_ERR(0, 4349, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4349
 * 
 *     kern_scan = _inclusive_scan_kernel(a.dtype, block_size)
 *     kern_scan(grid=((a.size - 1) // (2 * block_size) + 1,),             # <<<<<<<<<<<<<<
 *               block=(block_size,),
 *               args=(a, out),
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_kern_scan, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4349, __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":4354
 *               shared_mem=a.itemsize * block_size * 2)
 * 
 *     if (a.size - 1) // (block_size * 2) > 0:             # <<<<<<<<<<<<<<
 *         blocked_sum = out[block_size * 2 - 1:None:block_size * 2]
 *         scan(blocked_sum, blocked_sum)
 */
  __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_a->size - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyNumber_Multiply(__pyx_v_block_size, __pyx_int_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = PyNumber_FloorDivide(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_7, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4354, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 4354, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":4355
 * 
 *     if (a.size - 1) // (block_size * 2) > 0:
 *         blocked_sum = out[block_size * 2 - 1:None:block_size * 2]             # <<<<<<<<<<<<<<
 *         scan(blocked_sum, blocked_sum)
 *         kern_add = _add_scan_blocked_sum_kernel(out.dtype)
 */
    __pyx_t_5 = PyNumber_Multiply(__pyx_v_block_size, __pyx_int_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __Pyx_PyInt_SubtractObjC(__pyx_t_5, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Multiply(__pyx_v_block_size, __pyx_int_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PySlice_New(__pyx_t_7, Py_None, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_out), __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_blocked_sum = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":4356
 *     if (a.size - 1) // (block_size * 2) > 0:
 *         blocked_sum = out[block_size * 2 - 1:None:block_size * 2]
 *         scan(blocked_sum, blocked_sum)             # <<<<<<<<<<<<<<
 *         kern_add = _add_scan_blocked_sum_kernel(out.dtype)
 *         kern_add(grid=((a.size - 1) // (2 * block_size),),
 */
    if (!(likely(((__pyx_v_blocked_sum) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_blocked_sum, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 4356, __pyx_L1_error)
    if (!(likely(((__pyx_v_blocked_sum) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_blocked_sum, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 4356, __pyx_L1_error)
    __pyx_t_8.__pyx_n = 1;
    __pyx_t_8.out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_blocked_sum);
    __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_scan(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_blocked_sum), 0, &__pyx_t_8)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":4357
 *         blocked_sum = out[block_size * 2 - 1:None:block_size * 2]
 *         scan(blocked_sum, blocked_sum)
 *         kern_add = _add_scan_blocked_sum_kernel(out.dtype)             # <<<<<<<<<<<<<<
 *         kern_add(grid=((a.size - 1) // (2 * block_size),),
 *                  block=(2 * block_size - 1,),
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_add_scan_blocked_sum_kernel_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4357, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_out->dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4357, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_out->dtype};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4357, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_5);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_out->dtype};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4357, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_5);
      } else
      #endif
      {
        __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4357, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_INCREF(__pyx_v_out->dtype);
        __Pyx_GIVEREF(__pyx_v_out->dtype);
        PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_out->dtype);
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4357, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_kern_add = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":4358
 *         scan(blocked_sum, blocked_sum)
 *         kern_add = _add_scan_blocked_sum_kernel(out.dtype)
 *         kern_add(grid=((a.size - 1) // (2 * block_size),),             # <<<<<<<<<<<<<<
 *                  block=(2 * block_size - 1,),
 *                  args=(out,))
 */
    __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4358, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_a->size - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4358, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyNumber_Multiply(__pyx_int_2, __pyx_v_block_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4358, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = PyNumber_FloorDivide(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4358, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4358, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7);
    __pyx_t_7 = 0;
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_grid, __pyx_t_2) < 0) __PYX_ERR(0, 4358, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":4359
 *         kern_add = _add_scan_blocked_sum_kernel(out.dtype)
 *         kern_add(grid=((a.size - 1) // (2 * block_size),),
 *                  block=(2 * block_size - 1,),             # <<<<<<<<<<<<<<
 *                  args=(out,))
 *     return out
 */
    __pyx_t_2 = PyNumber_Multiply(__pyx_int_2, __pyx_v_block_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4359, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_PyInt_SubtractObjC(__pyx_t_2, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4359, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4359, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7);
    __pyx_t_7 = 0;
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_block, __pyx_t_2) < 0) __PYX_ERR(0, 4358, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":4360
 *         kern_add(grid=((a.size - 1) // (2 * block_size),),
 *                  block=(2 * block_size - 1,),
 *                  args=(out,))             # <<<<<<<<<<<<<<
 *     return out
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_out));
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_args, __pyx_t_2) < 0) __PYX_ERR(0, 4358, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":4358
 *         scan(blocked_sum, blocked_sum)
 *         kern_add = _add_scan_blocked_sum_kernel(out.dtype)
 *         kern_add(grid=((a.size - 1) // (2 * block_size),),             # <<<<<<<<<<<<<<
 *                  block=(2 * block_size - 1,),
 *                  args=(out,))
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_kern_add, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4358, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":4354
 *               shared_mem=a.itemsize * block_size * 2)
 * 
 *     if (a.size - 1) // (block_size * 2) > 0:             # <<<<<<<<<<<<<<
 *         blocked_sum = out[block_size * 2 - 1:None:block_size * 2]
 *         scan(blocked_sum, blocked_sum)
 */
  }

  /* "cupy/core/core.pyx":4361
 *                  block=(2 * block_size - 1,),
 *                  args=(out,))
 *     return out             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_out));
  __pyx_r = __pyx_v_out;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":4325
 * 
 * 
 * cpdef ndarray scan(ndarray a, ndarray out=None):             # <<<<<<<<<<<<<<
 *     """Return the prefix sum(scan) of the elements.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core.scan", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_block_size);
  __Pyx_XDECREF(__pyx_v_kern_scan);
  __Pyx_XDECREF(__pyx_v_blocked_sum);
  __Pyx_XDECREF(__pyx_v_kern_add);
  __Pyx_XDECREF((PyObject *)__pyx_v_out);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_123scan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_122scan[] = "scan(ndarray a, ndarray out=None) -> ndarray\nReturn the prefix sum(scan) of the elements.\n\n    Args:\n        a (cupy.ndarray): input array.\n        out (cupy.ndarray): Alternative output array in which to place\n         the result. The same size and same type as the input array(a).\n\n    Returns:\n        cupy.ndarray: A new array holding the result is returned.\n\n    ";
static PyObject *__pyx_pw_4cupy_4core_4core_123scan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("scan (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_out,0};
    PyObject* values[2] = {0,0};
    values[1] = (PyObject *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__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 = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scan") < 0)) __PYX_ERR(0, 4325, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("scan", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4325, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.scan", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 4325, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(0, 4325, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_122scan(__pyx_self, __pyx_v_a, __pyx_v_out);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_122scan(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_scan __pyx_t_2;
  __Pyx_RefNannySetupContext("scan", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_scan(__pyx_v_a, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.scan", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Indexer(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x6d47339:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_125__pyx_unpickle_Indexer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_124__pyx_unpickle_Indexer[] = "__pyx_unpickle_Indexer(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_125__pyx_unpickle_Indexer = {"__pyx_unpickle_Indexer", (PyCFunction)__pyx_pw_4cupy_4core_4core_125__pyx_unpickle_Indexer, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_124__pyx_unpickle_Indexer};
static PyObject *__pyx_pw_4cupy_4core_4core_125__pyx_unpickle_Indexer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Indexer (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Indexer", 1, 3, 3, 1); __PYX_ERR(4, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Indexer", 1, 3, 3, 2); __PYX_ERR(4, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Indexer") < 0)) __PYX_ERR(4, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(4, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Indexer", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_Indexer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_124__pyx_unpickle_Indexer(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_124__pyx_unpickle_Indexer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Indexer", 0);

  /* "(tree fragment)":2
 * def __pyx_unpickle_Indexer(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x6d47339:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6d47339 = (shape, size))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x6d47339) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_Indexer(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x6d47339:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6d47339 = (shape, size))" % __pyx_checksum)
 *     __pyx_result = Indexer.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0x6d47339:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6d47339 = (shape, size))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Indexer.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x6d, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_Indexer(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x6d47339:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6d47339 = (shape, size))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6d47339 = (shape, size))" % __pyx_checksum)
 *     __pyx_result = Indexer.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Indexer__set_state(<Indexer> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6d47339 = (shape, size))" % __pyx_checksum)
 *     __pyx_result = Indexer.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Indexer__set_state(<Indexer> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = Indexer.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Indexer__set_state(<Indexer> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Indexer__set_state(Indexer __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(4, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4cupy_4core_4core___pyx_unpickle_Indexer__set_state(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6d47339 = (shape, size))" % __pyx_checksum)
 *     __pyx_result = Indexer.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Indexer__set_state(<Indexer> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Indexer__set_state(<Indexer> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Indexer__set_state(Indexer __pyx_result, tuple __pyx_state):
 *     __pyx_result.shape = __pyx_state[0]; __pyx_result.size = __pyx_state[1]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Indexer(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x6d47339:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_Indexer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_Indexer__set_state(<Indexer> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Indexer__set_state(Indexer __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.shape = __pyx_state[0]; __pyx_result.size = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4cupy_4core_4core___pyx_unpickle_Indexer__set_state(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Indexer__set_state", 0);

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_Indexer__set_state(Indexer __pyx_result, tuple __pyx_state):
 *     __pyx_result.shape = __pyx_state[0]; __pyx_result.size = __pyx_state[1]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->shape);
  __Pyx_DECREF(__pyx_v___pyx_result->shape);
  __pyx_v___pyx_result->shape = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->size = __pyx_t_2;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_Indexer__set_state(Indexer __pyx_result, tuple __pyx_state):
 *     __pyx_result.shape = __pyx_state[0]; __pyx_result.size = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(4, 11, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(4, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_2 > 2) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(4, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_3 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":12
 *     __pyx_result.shape = __pyx_state[0]; __pyx_result.size = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(4, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_Indexer__set_state(Indexer __pyx_result, tuple __pyx_state):
 *     __pyx_result.shape = __pyx_state[0]; __pyx_result.size = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_Indexer__set_state(<Indexer> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Indexer__set_state(Indexer __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.shape = __pyx_state[0]; __pyx_result.size = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_Indexer__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_ParameterInfo(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x73694c8:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_127__pyx_unpickle_ParameterInfo(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_126__pyx_unpickle_ParameterInfo[] = "__pyx_unpickle_ParameterInfo(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_127__pyx_unpickle_ParameterInfo = {"__pyx_unpickle_ParameterInfo", (PyCFunction)__pyx_pw_4cupy_4core_4core_127__pyx_unpickle_ParameterInfo, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_126__pyx_unpickle_ParameterInfo};
static PyObject *__pyx_pw_4cupy_4core_4core_127__pyx_unpickle_ParameterInfo(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_ParameterInfo (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ParameterInfo", 1, 3, 3, 1); __PYX_ERR(4, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ParameterInfo", 1, 3, 3, 2); __PYX_ERR(4, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_ParameterInfo") < 0)) __PYX_ERR(4, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(4, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ParameterInfo", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_ParameterInfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_126__pyx_unpickle_ParameterInfo(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_126__pyx_unpickle_ParameterInfo(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ParameterInfo", 0);

  /* "(tree fragment)":2
 * def __pyx_unpickle_ParameterInfo(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x73694c8:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x73694c8 = (ctype, dtype, is_const, name, raw))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x73694c8) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_ParameterInfo(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x73694c8:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x73694c8 = (ctype, dtype, is_const, name, raw))" % __pyx_checksum)
 *     __pyx_result = ParameterInfo.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0x73694c8:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x73694c8 = (ctype, dtype, is_const, name, raw))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = ParameterInfo.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x73, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_ParameterInfo(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x73694c8:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x73694c8 = (ctype, dtype, is_const, name, raw))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x73694c8 = (ctype, dtype, is_const, name, raw))" % __pyx_checksum)
 *     __pyx_result = ParameterInfo.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ParameterInfo__set_state(<ParameterInfo> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4cupy_4core_4core_ParameterInfo), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x73694c8 = (ctype, dtype, is_const, name, raw))" % __pyx_checksum)
 *     __pyx_result = ParameterInfo.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ParameterInfo__set_state(<ParameterInfo> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = ParameterInfo.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ParameterInfo__set_state(<ParameterInfo> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_ParameterInfo__set_state(ParameterInfo __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(4, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4cupy_4core_4core___pyx_unpickle_ParameterInfo__set_state(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x73694c8 = (ctype, dtype, is_const, name, raw))" % __pyx_checksum)
 *     __pyx_result = ParameterInfo.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ParameterInfo__set_state(<ParameterInfo> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ParameterInfo__set_state(<ParameterInfo> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_ParameterInfo__set_state(ParameterInfo __pyx_result, tuple __pyx_state):
 *     __pyx_result.ctype = __pyx_state[0]; __pyx_result.dtype = __pyx_state[1]; __pyx_result.is_const = __pyx_state[2]; __pyx_result.name = __pyx_state[3]; __pyx_result.raw = __pyx_state[4]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ParameterInfo(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x73694c8:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_ParameterInfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_ParameterInfo__set_state(<ParameterInfo> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ParameterInfo__set_state(ParameterInfo __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.ctype = __pyx_state[0]; __pyx_result.dtype = __pyx_state[1]; __pyx_result.is_const = __pyx_state[2]; __pyx_result.name = __pyx_state[3]; __pyx_result.raw = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4cupy_4core_4core___pyx_unpickle_ParameterInfo__set_state(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ParameterInfo__set_state", 0);

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_ParameterInfo__set_state(ParameterInfo __pyx_result, tuple __pyx_state):
 *     __pyx_result.ctype = __pyx_state[0]; __pyx_result.dtype = __pyx_state[1]; __pyx_result.is_const = __pyx_state[2]; __pyx_result.name = __pyx_state[3]; __pyx_result.raw = __pyx_state[4]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[5])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->ctype);
  __Pyx_DECREF(__pyx_v___pyx_result->ctype);
  __pyx_v___pyx_result->ctype = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->dtype);
  __Pyx_DECREF(__pyx_v___pyx_result->dtype);
  __pyx_v___pyx_result->dtype = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->is_const = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->name);
  __Pyx_DECREF(__pyx_v___pyx_result->name);
  __pyx_v___pyx_result->name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->raw = __pyx_t_2;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_ParameterInfo__set_state(ParameterInfo __pyx_result, tuple __pyx_state):
 *     __pyx_result.ctype = __pyx_state[0]; __pyx_result.dtype = __pyx_state[1]; __pyx_result.is_const = __pyx_state[2]; __pyx_result.name = __pyx_state[3]; __pyx_result.raw = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[5])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(4, 11, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(4, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 5) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(4, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":12
 *     __pyx_result.ctype = __pyx_state[0]; __pyx_result.dtype = __pyx_state[1]; __pyx_result.is_const = __pyx_state[2]; __pyx_result.name = __pyx_state[3]; __pyx_result.raw = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[5])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(4, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_ParameterInfo__set_state(ParameterInfo __pyx_result, tuple __pyx_state):
 *     __pyx_result.ctype = __pyx_state[0]; __pyx_result.dtype = __pyx_state[1]; __pyx_result.is_const = __pyx_state[2]; __pyx_result.name = __pyx_state[3]; __pyx_result.raw = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[5])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_ParameterInfo__set_state(<ParameterInfo> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ParameterInfo__set_state(ParameterInfo __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.ctype = __pyx_state[0]; __pyx_result.dtype = __pyx_state[1]; __pyx_result.is_const = __pyx_state[2]; __pyx_result.name = __pyx_state[3]; __pyx_result.raw = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_ParameterInfo__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_ElementwiseKernel(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x7d8b293:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_129__pyx_unpickle_ElementwiseKernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_128__pyx_unpickle_ElementwiseKernel[] = "__pyx_unpickle_ElementwiseKernel(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_129__pyx_unpickle_ElementwiseKernel = {"__pyx_unpickle_ElementwiseKernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_129__pyx_unpickle_ElementwiseKernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_128__pyx_unpickle_ElementwiseKernel};
static PyObject *__pyx_pw_4cupy_4core_4core_129__pyx_unpickle_ElementwiseKernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_ElementwiseKernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ElementwiseKernel", 1, 3, 3, 1); __PYX_ERR(4, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ElementwiseKernel", 1, 3, 3, 2); __PYX_ERR(4, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_ElementwiseKernel") < 0)) __PYX_ERR(4, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(4, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ElementwiseKernel", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_ElementwiseKernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_128__pyx_unpickle_ElementwiseKernel(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_128__pyx_unpickle_ElementwiseKernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ElementwiseKernel", 0);

  /* "(tree fragment)":2
 * def __pyx_unpickle_ElementwiseKernel(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x7d8b293:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7d8b293 = (in_params, kwargs, name, nargs, nin, nout, operation, out_params, params, preamble, reduce_dims))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x7d8b293) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_ElementwiseKernel(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x7d8b293:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7d8b293 = (in_params, kwargs, name, nargs, nin, nout, operation, out_params, params, preamble, reduce_dims))" % __pyx_checksum)
 *     __pyx_result = ElementwiseKernel.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0x7d8b293:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7d8b293 = (in_params, kwargs, name, nargs, nin, nout, operation, out_params, params, preamble, reduce_dims))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = ElementwiseKernel.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x7d, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_ElementwiseKernel(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x7d8b293:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7d8b293 = (in_params, kwargs, name, nargs, nin, nout, operation, out_params, params, preamble, reduce_dims))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7d8b293 = (in_params, kwargs, name, nargs, nin, nout, operation, out_params, params, preamble, reduce_dims))" % __pyx_checksum)
 *     __pyx_result = ElementwiseKernel.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ElementwiseKernel__set_state(<ElementwiseKernel> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7d8b293 = (in_params, kwargs, name, nargs, nin, nout, operation, out_params, params, preamble, reduce_dims))" % __pyx_checksum)
 *     __pyx_result = ElementwiseKernel.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ElementwiseKernel__set_state(<ElementwiseKernel> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = ElementwiseKernel.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ElementwiseKernel__set_state(<ElementwiseKernel> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_ElementwiseKernel__set_state(ElementwiseKernel __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(4, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4cupy_4core_4core___pyx_unpickle_ElementwiseKernel__set_state(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7d8b293 = (in_params, kwargs, name, nargs, nin, nout, operation, out_params, params, preamble, reduce_dims))" % __pyx_checksum)
 *     __pyx_result = ElementwiseKernel.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ElementwiseKernel__set_state(<ElementwiseKernel> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ElementwiseKernel__set_state(<ElementwiseKernel> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_ElementwiseKernel__set_state(ElementwiseKernel __pyx_result, tuple __pyx_state):
 *     __pyx_result.in_params = __pyx_state[0]; __pyx_result.kwargs = __pyx_state[1]; __pyx_result.name = __pyx_state[2]; __pyx_result.nargs = __pyx_state[3]; __pyx_result.nin = __pyx_state[4]; __pyx_result.nout = __pyx_state[5]; __pyx_result.operation = __pyx_state[6]; __pyx_result.out_params = __pyx_state[7]; __pyx_result.params = __pyx_state[8]; __pyx_result.preamble = __pyx_state[9]; __pyx_result.reduce_dims = __pyx_state[10]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ElementwiseKernel(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x7d8b293:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_ElementwiseKernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_ElementwiseKernel__set_state(<ElementwiseKernel> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ElementwiseKernel__set_state(ElementwiseKernel __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.in_params = __pyx_state[0]; __pyx_result.kwargs = __pyx_state[1]; __pyx_result.name = __pyx_state[2]; __pyx_result.nargs = __pyx_state[3]; __pyx_result.nin = __pyx_state[4]; __pyx_result.nout = __pyx_state[5]; __pyx_result.operation = __pyx_state[6]; __pyx_result.out_params = __pyx_state[7]; __pyx_result.params = __pyx_state[8]; __pyx_result.preamble = __pyx_state[9]; __pyx_result.reduce_dims = __pyx_state[10]
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4cupy_4core_4core___pyx_unpickle_ElementwiseKernel__set_state(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ElementwiseKernel__set_state", 0);

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_ElementwiseKernel__set_state(ElementwiseKernel __pyx_result, tuple __pyx_state):
 *     __pyx_result.in_params = __pyx_state[0]; __pyx_result.kwargs = __pyx_state[1]; __pyx_result.name = __pyx_state[2]; __pyx_result.nargs = __pyx_state[3]; __pyx_result.nin = __pyx_state[4]; __pyx_result.nout = __pyx_state[5]; __pyx_result.operation = __pyx_state[6]; __pyx_result.out_params = __pyx_state[7]; __pyx_result.params = __pyx_state[8]; __pyx_result.preamble = __pyx_state[9]; __pyx_result.reduce_dims = __pyx_state[10]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[11])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->in_params);
  __Pyx_DECREF(__pyx_v___pyx_result->in_params);
  __pyx_v___pyx_result->in_params = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->kwargs);
  __Pyx_DECREF(__pyx_v___pyx_result->kwargs);
  __pyx_v___pyx_result->kwargs = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->name);
  __Pyx_DECREF(__pyx_v___pyx_result->name);
  __pyx_v___pyx_result->name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->nargs = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->nin = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->nout = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->operation);
  __Pyx_DECREF(__pyx_v___pyx_result->operation);
  __pyx_v___pyx_result->operation = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->out_params);
  __Pyx_DECREF(__pyx_v___pyx_result->out_params);
  __pyx_v___pyx_result->out_params = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->params);
  __Pyx_DECREF(__pyx_v___pyx_result->params);
  __pyx_v___pyx_result->params = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 9, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->preamble);
  __Pyx_DECREF(__pyx_v___pyx_result->preamble);
  __pyx_v___pyx_result->preamble = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 10, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->reduce_dims = __pyx_t_3;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_ElementwiseKernel__set_state(ElementwiseKernel __pyx_result, tuple __pyx_state):
 *     __pyx_result.in_params = __pyx_state[0]; __pyx_result.kwargs = __pyx_state[1]; __pyx_result.name = __pyx_state[2]; __pyx_result.nargs = __pyx_state[3]; __pyx_result.nin = __pyx_state[4]; __pyx_result.nout = __pyx_state[5]; __pyx_result.operation = __pyx_state[6]; __pyx_result.out_params = __pyx_state[7]; __pyx_result.params = __pyx_state[8]; __pyx_result.preamble = __pyx_state[9]; __pyx_result.reduce_dims = __pyx_state[10]
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[11])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(4, 11, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(4, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_2 > 11) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(4, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_3 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":12
 *     __pyx_result.in_params = __pyx_state[0]; __pyx_result.kwargs = __pyx_state[1]; __pyx_result.name = __pyx_state[2]; __pyx_result.nargs = __pyx_state[3]; __pyx_result.nin = __pyx_state[4]; __pyx_result.nout = __pyx_state[5]; __pyx_result.operation = __pyx_state[6]; __pyx_result.out_params = __pyx_state[7]; __pyx_result.params = __pyx_state[8]; __pyx_result.preamble = __pyx_state[9]; __pyx_result.reduce_dims = __pyx_state[10]
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[11])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(4, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 11, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_ElementwiseKernel__set_state(ElementwiseKernel __pyx_result, tuple __pyx_state):
 *     __pyx_result.in_params = __pyx_state[0]; __pyx_result.kwargs = __pyx_state[1]; __pyx_result.name = __pyx_state[2]; __pyx_result.nargs = __pyx_state[3]; __pyx_result.nin = __pyx_state[4]; __pyx_result.nout = __pyx_state[5]; __pyx_result.operation = __pyx_state[6]; __pyx_result.out_params = __pyx_state[7]; __pyx_result.params = __pyx_state[8]; __pyx_result.preamble = __pyx_state[9]; __pyx_result.reduce_dims = __pyx_state[10]
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[11])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_ElementwiseKernel__set_state(<ElementwiseKernel> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ElementwiseKernel__set_state(ElementwiseKernel __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.in_params = __pyx_state[0]; __pyx_result.kwargs = __pyx_state[1]; __pyx_result.name = __pyx_state[2]; __pyx_result.nargs = __pyx_state[3]; __pyx_result.nin = __pyx_state[4]; __pyx_result.nout = __pyx_state[5]; __pyx_result.operation = __pyx_state[6]; __pyx_result.out_params = __pyx_state[7]; __pyx_result.params = __pyx_state[8]; __pyx_result.preamble = __pyx_state[9]; __pyx_result.reduce_dims = __pyx_state[10]
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_ElementwiseKernel__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_broadcast(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x0537f67:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_131__pyx_unpickle_broadcast(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_130__pyx_unpickle_broadcast[] = "__pyx_unpickle_broadcast(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_131__pyx_unpickle_broadcast = {"__pyx_unpickle_broadcast", (PyCFunction)__pyx_pw_4cupy_4core_4core_131__pyx_unpickle_broadcast, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_130__pyx_unpickle_broadcast};
static PyObject *__pyx_pw_4cupy_4core_4core_131__pyx_unpickle_broadcast(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_broadcast (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_broadcast", 1, 3, 3, 1); __PYX_ERR(4, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_broadcast", 1, 3, 3, 2); __PYX_ERR(4, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_broadcast") < 0)) __PYX_ERR(4, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(4, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_broadcast", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_broadcast", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_130__pyx_unpickle_broadcast(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_130__pyx_unpickle_broadcast(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__pyx_unpickle_broadcast", 0);

  /* "(tree fragment)":2
 * def __pyx_unpickle_broadcast(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x0537f67:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x0537f67 = (nd, shape, size, values))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x0537f67) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_broadcast(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x0537f67:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x0537f67 = (nd, shape, size, values))" % __pyx_checksum)
 *     __pyx_result = broadcast.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0x0537f67:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x0537f67 = (nd, shape, size, values))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = broadcast.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x05, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_broadcast(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x0537f67:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x0537f67 = (nd, shape, size, values))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x0537f67 = (nd, shape, size, values))" % __pyx_checksum)
 *     __pyx_result = broadcast.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_broadcast__set_state(<broadcast> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4cupy_4core_4core_broadcast), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x0537f67 = (nd, shape, size, values))" % __pyx_checksum)
 *     __pyx_result = broadcast.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_broadcast__set_state(<broadcast> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = broadcast.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_broadcast__set_state(<broadcast> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_broadcast__set_state(broadcast __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(4, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4cupy_4core_4core___pyx_unpickle_broadcast__set_state(((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x0537f67 = (nd, shape, size, values))" % __pyx_checksum)
 *     __pyx_result = broadcast.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_broadcast__set_state(<broadcast> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_broadcast__set_state(<broadcast> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_broadcast__set_state(broadcast __pyx_result, tuple __pyx_state):
 *     __pyx_result.nd = __pyx_state[0]; __pyx_result.shape = __pyx_state[1]; __pyx_result.size = __pyx_state[2]; __pyx_result.values = __pyx_state[3]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_broadcast(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x0537f67:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_broadcast", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_broadcast__set_state(<broadcast> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_broadcast__set_state(broadcast __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.nd = __pyx_state[0]; __pyx_result.shape = __pyx_state[1]; __pyx_result.size = __pyx_state[2]; __pyx_result.values = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4cupy_4core_4core___pyx_unpickle_broadcast__set_state(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_broadcast__set_state", 0);

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_broadcast__set_state(broadcast __pyx_result, tuple __pyx_state):
 *     __pyx_result.nd = __pyx_state[0]; __pyx_result.shape = __pyx_state[1]; __pyx_result.size = __pyx_state[2]; __pyx_result.values = __pyx_state[3]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->nd = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->shape);
  __Pyx_DECREF(__pyx_v___pyx_result->shape);
  __pyx_v___pyx_result->shape = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->size = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->values);
  __Pyx_DECREF(__pyx_v___pyx_result->values);
  __pyx_v___pyx_result->values = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_broadcast__set_state(broadcast __pyx_result, tuple __pyx_state):
 *     __pyx_result.nd = __pyx_state[0]; __pyx_result.shape = __pyx_state[1]; __pyx_result.size = __pyx_state[2]; __pyx_result.values = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(4, 11, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(4, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_2 > 4) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(4, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_3 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":12
 *     __pyx_result.nd = __pyx_state[0]; __pyx_result.shape = __pyx_state[1]; __pyx_result.size = __pyx_state[2]; __pyx_result.values = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[4])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(4, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_broadcast__set_state(broadcast __pyx_result, tuple __pyx_state):
 *     __pyx_result.nd = __pyx_state[0]; __pyx_result.shape = __pyx_state[1]; __pyx_result.size = __pyx_state[2]; __pyx_result.values = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_broadcast__set_state(<broadcast> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_broadcast__set_state(broadcast __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.nd = __pyx_state[0]; __pyx_result.shape = __pyx_state[1]; __pyx_result.size = __pyx_state[2]; __pyx_result.values = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_broadcast__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "vector.from_py":45
 * 
 * @cname("__pyx_convert_vector_from_py_Py_ssize_t")
 * cdef vector[X] __pyx_convert_vector_from_py_Py_ssize_t(object o) except *:             # <<<<<<<<<<<<<<
 *     cdef vector[X] v
 *     for item in o:
 */

static std::vector<Py_ssize_t>  __pyx_convert_vector_from_py_Py_ssize_t(PyObject *__pyx_v_o) {
  std::vector<Py_ssize_t>  __pyx_v_v;
  PyObject *__pyx_v_item = NULL;
  std::vector<Py_ssize_t>  __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  __Pyx_RefNannySetupContext("__pyx_convert_vector_from_py_Py_ssize_t", 0);

  /* "vector.from_py":47
 * cdef vector[X] __pyx_convert_vector_from_py_Py_ssize_t(object o) except *:
 *     cdef vector[X] v
 *     for item in o:             # <<<<<<<<<<<<<<
 *         v.push_back(<X>item)
 *     return v
 */
  if (likely(PyList_CheckExact(__pyx_v_o)) || PyTuple_CheckExact(__pyx_v_o)) {
    __pyx_t_1 = __pyx_v_o; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_o); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 47, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 47, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(4, 47, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 47, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(4, 47, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 47, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(4, 47, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "vector.from_py":48
 *     cdef vector[X] v
 *     for item in o:
 *         v.push_back(<X>item)             # <<<<<<<<<<<<<<
 *     return v
 * 
 */
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_item); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 48, __pyx_L1_error)
    __pyx_v_v.push_back(((Py_ssize_t)__pyx_t_5));

    /* "vector.from_py":47
 * cdef vector[X] __pyx_convert_vector_from_py_Py_ssize_t(object o) except *:
 *     cdef vector[X] v
 *     for item in o:             # <<<<<<<<<<<<<<
 *         v.push_back(<X>item)
 *     return v
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "vector.from_py":49
 *     for item in o:
 *         v.push_back(<X>item)
 *     return v             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_v;
  goto __pyx_L0;

  /* "vector.from_py":45
 * 
 * @cname("__pyx_convert_vector_from_py_Py_ssize_t")
 * cdef vector[X] __pyx_convert_vector_from_py_Py_ssize_t(object o) except *:             # <<<<<<<<<<<<<<
 *     cdef vector[X] v
 *     for item in o:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("vector.from_py.__pyx_convert_vector_from_py_Py_ssize_t", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static std::vector<size_t>  __pyx_convert_vector_from_py_size_t(PyObject *__pyx_v_o) {
  std::vector<size_t>  __pyx_v_v;
  PyObject *__pyx_v_item = NULL;
  std::vector<size_t>  __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  __Pyx_RefNannySetupContext("__pyx_convert_vector_from_py_size_t", 0);

  /* "vector.from_py":47
 * cdef vector[X] __pyx_convert_vector_from_py_size_t(object o) except *:
 *     cdef vector[X] v
 *     for item in o:             # <<<<<<<<<<<<<<
 *         v.push_back(<X>item)
 *     return v
 */
  if (likely(PyList_CheckExact(__pyx_v_o)) || PyTuple_CheckExact(__pyx_v_o)) {
    __pyx_t_1 = __pyx_v_o; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_o); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 47, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 47, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(4, 47, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 47, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(4, 47, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 47, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(4, 47, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "vector.from_py":48
 *     cdef vector[X] v
 *     for item in o:
 *         v.push_back(<X>item)             # <<<<<<<<<<<<<<
 *     return v
 * 
 */
    __pyx_t_5 = __Pyx_PyInt_As_size_t(__pyx_v_item); if (unlikely((__pyx_t_5 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 48, __pyx_L1_error)
    __pyx_v_v.push_back(((size_t)__pyx_t_5));

    /* "vector.from_py":47
 * cdef vector[X] __pyx_convert_vector_from_py_size_t(object o) except *:
 *     cdef vector[X] v
 *     for item in o:             # <<<<<<<<<<<<<<
 *         v.push_back(<X>item)
 *     return v
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "vector.from_py":49
 *     for item in o:
 *         v.push_back(<X>item)
 *     return v             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_v;
  goto __pyx_L0;

  /* "vector.from_py":45
 * 
 * @cname("__pyx_convert_vector_from_py_size_t")
 * cdef vector[X] __pyx_convert_vector_from_py_size_t(object o) except *:             # <<<<<<<<<<<<<<
 *     cdef vector[X] v
 *     for item in o:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("vector.from_py.__pyx_convert_vector_from_py_size_t", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "vector.to_py":60
 * 
 * @cname("__pyx_convert_vector_to_py_Py_ssize_t")
 * cdef object __pyx_convert_vector_to_py_Py_ssize_t(vector[X]& v):             # <<<<<<<<<<<<<<
 *     return [v[i] for i in range(v.size())]
 * 
 */

static PyObject *__pyx_convert_vector_to_py_Py_ssize_t(const std::vector<Py_ssize_t>  &__pyx_v_v) {
  size_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__pyx_convert_vector_to_py_Py_ssize_t", 0);

  /* "vector.to_py":61
 * @cname("__pyx_convert_vector_to_py_Py_ssize_t")
 * cdef object __pyx_convert_vector_to_py_Py_ssize_t(vector[X]& v):
 *     return [v[i] for i in range(v.size())]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_v_v.size();
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;
    __pyx_t_4 = PyInt_FromSsize_t((__pyx_v_v[__pyx_v_i])); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) __PYX_ERR(4, 61, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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_4);
  __Pyx_AddTraceback("vector.to_py.__pyx_convert_vector_to_py_Py_ssize_t", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_convert_vector_to_py_size_t(const std::vector<size_t>  &__pyx_v_v) {
  size_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__pyx_convert_vector_to_py_size_t", 0);

  /* "vector.to_py":61
 * @cname("__pyx_convert_vector_to_py_size_t")
 * cdef object __pyx_convert_vector_to_py_size_t(vector[X]& v):
 *     return [v[i] for i in range(v.size())]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_v_v.size();
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;
    __pyx_t_4 = __Pyx_PyInt_FromSize_t((__pyx_v_v[__pyx_v_i])); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) __PYX_ERR(4, 61, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "vector.to_py":60
 * 
 * @cname("__pyx_convert_vector_to_py_size_t")
 * cdef object __pyx_convert_vector_to_py_size_t(vector[X]& v):             # <<<<<<<<<<<<<<
 *     return [v[i] for i in range(v.size())]
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("vector.to_py.__pyx_convert_vector_to_py_size_t", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":120
 *         cdef bint dtype_is_object
 * 
 *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
 *                   mode="c", bint allocate_buffer=True):
 * 
 */

/* Python wrapper */
static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_shape = 0;
  Py_ssize_t __pyx_v_itemsize;
  PyObject *__pyx_v_format = 0;
  PyObject *__pyx_v_mode = 0;
  int __pyx_v_allocate_buffer;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_itemsize,&__pyx_n_s_format,&__pyx_n_s_mode,&__pyx_n_s_allocate_buffer,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[3] = ((PyObject *)__pyx_n_s_c);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); __PYX_ERR(4, 120, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); __PYX_ERR(4, 120, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mode);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_allocate_buffer);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(4, 120, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_shape = ((PyObject*)values[0]);
    __pyx_v_itemsize = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_itemsize == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 120, __pyx_L3_error)
    __pyx_v_format = values[2];
    __pyx_v_mode = values[3];
    if (values[4]) {
      __pyx_v_allocate_buffer = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_allocate_buffer == (int)-1) && PyErr_Occurred())) __PYX_ERR(4, 121, __pyx_L3_error)
    } else {

      /* "View.MemoryView":121
 * 
 *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,
 *                   mode="c", bint allocate_buffer=True):             # <<<<<<<<<<<<<<
 * 
 *         cdef int idx
 */
      __pyx_v_allocate_buffer = ((int)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 120, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(4, 120, __pyx_L1_error)
  if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) {
    PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); __PYX_ERR(4, 120, __pyx_L1_error)
  }
  __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(((struct __pyx_array_obj *)__pyx_v_self), __pyx_v_shape, __pyx_v_itemsize, __pyx_v_format, __pyx_v_mode, __pyx_v_allocate_buffer);

  /* "View.MemoryView":120
 *         cdef bint dtype_is_object
 * 
 *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
 *                   mode="c", bint allocate_buffer=True):
 * 
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer) {
  int __pyx_v_idx;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_dim;
  PyObject **__pyx_v_p;
  char __pyx_v_order;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  char *__pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("__cinit__", 0);
  __Pyx_INCREF(__pyx_v_format);

  /* "View.MemoryView":127
 *         cdef PyObject **p
 * 
 *         self.ndim = <int> len(shape)             # <<<<<<<<<<<<<<
 *         self.itemsize = itemsize
 * 
 */
  if (unlikely(__pyx_v_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(4, 127, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(4, 127, __pyx_L1_error)
  __pyx_v_self->ndim = ((int)__pyx_t_1);

  /* "View.MemoryView":128
 * 
 *         self.ndim = <int> len(shape)
 *         self.itemsize = itemsize             # <<<<<<<<<<<<<<
 * 
 *         if not self.ndim:
 */
  __pyx_v_self->itemsize = __pyx_v_itemsize;

  /* "View.MemoryView":130
 *         self.itemsize = itemsize
 * 
 *         if not self.ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError("Empty shape tuple for cython.array")
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_self->ndim != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":131
 * 
 *         if not self.ndim:
 *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
 * 
 *         if itemsize <= 0:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__202, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 131, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 131, __pyx_L1_error)

    /* "View.MemoryView":130
 *         self.itemsize = itemsize
 * 
 *         if not self.ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError("Empty shape tuple for cython.array")
 * 
 */
  }

  /* "View.MemoryView":133
 *             raise ValueError("Empty shape tuple for cython.array")
 * 
 *         if itemsize <= 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("itemsize <= 0 for cython.array")
 * 
 */
  __pyx_t_2 = ((__pyx_v_itemsize <= 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":134
 * 
 *         if itemsize <= 0:
 *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
 * 
 *         if not isinstance(format, bytes):
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__203, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 134, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 134, __pyx_L1_error)

    /* "View.MemoryView":133
 *             raise ValueError("Empty shape tuple for cython.array")
 * 
 *         if itemsize <= 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("itemsize <= 0 for cython.array")
 * 
 */
  }

  /* "View.MemoryView":136
 *             raise ValueError("itemsize <= 0 for cython.array")
 * 
 *         if not isinstance(format, bytes):             # <<<<<<<<<<<<<<
 *             format = format.encode('ASCII')
 *         self._format = format  # keep a reference to the byte string
 */
  __pyx_t_2 = PyBytes_Check(__pyx_v_format); 
  __pyx_t_4 = ((!(__pyx_t_2 != 0)) != 0);
  if (__pyx_t_4) {

    /* "View.MemoryView":137
 * 
 *         if not isinstance(format, bytes):
 *             format = format.encode('ASCII')             # <<<<<<<<<<<<<<
 *         self._format = format  # keep a reference to the byte string
 *         self.format = self._format
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 137, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__204, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 137, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "View.MemoryView":136
 *             raise ValueError("itemsize <= 0 for cython.array")
 * 
 *         if not isinstance(format, bytes):             # <<<<<<<<<<<<<<
 *             format = format.encode('ASCII')
 *         self._format = format  # keep a reference to the byte string
 */
  }

  /* "View.MemoryView":138
 *         if not isinstance(format, bytes):
 *             format = format.encode('ASCII')
 *         self._format = format  # keep a reference to the byte string             # <<<<<<<<<<<<<<
 *         self.format = self._format
 * 
 */
  if (!(likely(PyBytes_CheckExact(__pyx_v_format))||((__pyx_v_format) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_format)->tp_name), 0))) __PYX_ERR(4, 138, __pyx_L1_error)
  __pyx_t_5 = __pyx_v_format;
  __Pyx_INCREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_GOTREF(__pyx_v_self->_format);
  __Pyx_DECREF(__pyx_v_self->_format);
  __pyx_v_self->_format = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "View.MemoryView":139
 *             format = format.encode('ASCII')
 *         self._format = format  # keep a reference to the byte string
 *         self.format = self._format             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_6 = __Pyx_PyObject_AsWritableString(__pyx_v_self->_format); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(4, 139, __pyx_L1_error)
  __pyx_v_self->format = __pyx_t_6;

  /* "View.MemoryView":142
 * 
 * 
 *         self._shape = <Py_ssize_t *> PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2)             # <<<<<<<<<<<<<<
 *         self._strides = self._shape + self.ndim
 * 
 */
  __pyx_v_self->_shape = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2)));

  /* "View.MemoryView":143
 * 
 *         self._shape = <Py_ssize_t *> PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2)
 *         self._strides = self._shape + self.ndim             # <<<<<<<<<<<<<<
 * 
 *         if not self._shape:
 */
  __pyx_v_self->_strides = (__pyx_v_self->_shape + __pyx_v_self->ndim);

  /* "View.MemoryView":145
 *         self._strides = self._shape + self.ndim
 * 
 *         if not self._shape:             # <<<<<<<<<<<<<<
 *             raise MemoryError("unable to allocate shape and strides.")
 * 
 */
  __pyx_t_4 = ((!(__pyx_v_self->_shape != 0)) != 0);
  if (__pyx_t_4) {

    /* "View.MemoryView":146
 * 
 *         if not self._shape:
 *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__205, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(4, 146, __pyx_L1_error)

    /* "View.MemoryView":145
 *         self._strides = self._shape + self.ndim
 * 
 *         if not self._shape:             # <<<<<<<<<<<<<<
 *             raise MemoryError("unable to allocate shape and strides.")
 * 
 */
  }

  /* "View.MemoryView":149
 * 
 * 
 *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
 *             if dim <= 0:
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
 */
  __pyx_t_7 = 0;
  __pyx_t_5 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(4, 149, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 149, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 149, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_dim = __pyx_t_8;
    __pyx_v_idx = __pyx_t_7;
    __pyx_t_7 = (__pyx_t_7 + 1);

    /* "View.MemoryView":150
 * 
 *         for idx, dim in enumerate(shape):
 *             if dim <= 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
 *             self._shape[idx] = dim
 */
    __pyx_t_4 = ((__pyx_v_dim <= 0) != 0);
    if (__pyx_t_4) {

      /* "View.MemoryView":151
 *         for idx, dim in enumerate(shape):
 *             if dim <= 0:
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))             # <<<<<<<<<<<<<<
 *             self._shape[idx] = dim
 * 
 */
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 151, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 151, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 151, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
      __pyx_t_3 = 0;
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 151, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 151, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 151, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(4, 151, __pyx_L1_error)

      /* "View.MemoryView":150
 * 
 *         for idx, dim in enumerate(shape):
 *             if dim <= 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
 *             self._shape[idx] = dim
 */
    }

    /* "View.MemoryView":152
 *             if dim <= 0:
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
 *             self._shape[idx] = dim             # <<<<<<<<<<<<<<
 * 
 *         cdef char order
 */
    (__pyx_v_self->_shape[__pyx_v_idx]) = __pyx_v_dim;

    /* "View.MemoryView":149
 * 
 * 
 *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
 *             if dim <= 0:
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "View.MemoryView":155
 * 
 *         cdef char order
 *         if mode == 'fortran':             # <<<<<<<<<<<<<<
 *             order = b'F'
 *             self.mode = u'fortran'
 */
  __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_fortran, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(4, 155, __pyx_L1_error)
  if (__pyx_t_4) {

    /* "View.MemoryView":156
 *         cdef char order
 *         if mode == 'fortran':
 *             order = b'F'             # <<<<<<<<<<<<<<
 *             self.mode = u'fortran'
 *         elif mode == 'c':
 */
    __pyx_v_order = 'F';

    /* "View.MemoryView":157
 *         if mode == 'fortran':
 *             order = b'F'
 *             self.mode = u'fortran'             # <<<<<<<<<<<<<<
 *         elif mode == 'c':
 *             order = b'C'
 */
    __Pyx_INCREF(__pyx_n_u_fortran);
    __Pyx_GIVEREF(__pyx_n_u_fortran);
    __Pyx_GOTREF(__pyx_v_self->mode);
    __Pyx_DECREF(__pyx_v_self->mode);
    __pyx_v_self->mode = __pyx_n_u_fortran;

    /* "View.MemoryView":155
 * 
 *         cdef char order
 *         if mode == 'fortran':             # <<<<<<<<<<<<<<
 *             order = b'F'
 *             self.mode = u'fortran'
 */
    goto __pyx_L10;
  }

  /* "View.MemoryView":158
 *             order = b'F'
 *             self.mode = u'fortran'
 *         elif mode == 'c':             # <<<<<<<<<<<<<<
 *             order = b'C'
 *             self.mode = u'c'
 */
  __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(4, 158, __pyx_L1_error)
  if (__pyx_t_4) {

    /* "View.MemoryView":159
 *             self.mode = u'fortran'
 *         elif mode == 'c':
 *             order = b'C'             # <<<<<<<<<<<<<<
 *             self.mode = u'c'
 *         else:
 */
    __pyx_v_order = 'C';

    /* "View.MemoryView":160
 *         elif mode == 'c':
 *             order = b'C'
 *             self.mode = u'c'             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
 */
    __Pyx_INCREF(__pyx_n_u_c);
    __Pyx_GIVEREF(__pyx_n_u_c);
    __Pyx_GOTREF(__pyx_v_self->mode);
    __Pyx_DECREF(__pyx_v_self->mode);
    __pyx_v_self->mode = __pyx_n_u_c;

    /* "View.MemoryView":158
 *             order = b'F'
 *             self.mode = u'fortran'
 *         elif mode == 'c':             # <<<<<<<<<<<<<<
 *             order = b'C'
 *             self.mode = u'c'
 */
    goto __pyx_L10;
  }

  /* "View.MemoryView":162
 *             self.mode = u'c'
 *         else:
 *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)             # <<<<<<<<<<<<<<
 * 
 *         self.len = fill_contig_strides_array(self._shape, self._strides,
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_v_mode); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 162, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 162, __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_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 162, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(4, 162, __pyx_L1_error)
  }
  __pyx_L10:;

  /* "View.MemoryView":164
 *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
 * 
 *         self.len = fill_contig_strides_array(self._shape, self._strides,             # <<<<<<<<<<<<<<
 *                                              itemsize, self.ndim, order)
 * 
 */
  __pyx_v_self->len = __pyx_fill_contig_strides_array(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_itemsize, __pyx_v_self->ndim, __pyx_v_order);

  /* "View.MemoryView":167
 *                                              itemsize, self.ndim, order)
 * 
 *         self.free_data = allocate_buffer             # <<<<<<<<<<<<<<
 *         self.dtype_is_object = format == b'O'
 *         if allocate_buffer:
 */
  __pyx_v_self->free_data = __pyx_v_allocate_buffer;

  /* "View.MemoryView":168
 * 
 *         self.free_data = allocate_buffer
 *         self.dtype_is_object = format == b'O'             # <<<<<<<<<<<<<<
 *         if allocate_buffer:
 * 
 */
  __pyx_t_5 = PyObject_RichCompare(__pyx_v_format, __pyx_n_b_O, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 168, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(4, 168, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_self->dtype_is_object = __pyx_t_4;

  /* "View.MemoryView":169
 *         self.free_data = allocate_buffer
 *         self.dtype_is_object = format == b'O'
 *         if allocate_buffer:             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = (__pyx_v_allocate_buffer != 0);
  if (__pyx_t_4) {

    /* "View.MemoryView":172
 * 
 * 
 *             self.data = <char *>malloc(self.len)             # <<<<<<<<<<<<<<
 *             if not self.data:
 *                 raise MemoryError("unable to allocate array data.")
 */
    __pyx_v_self->data = ((char *)malloc(__pyx_v_self->len));

    /* "View.MemoryView":173
 * 
 *             self.data = <char *>malloc(self.len)
 *             if not self.data:             # <<<<<<<<<<<<<<
 *                 raise MemoryError("unable to allocate array data.")
 * 
 */
    __pyx_t_4 = ((!(__pyx_v_self->data != 0)) != 0);
    if (__pyx_t_4) {

      /* "View.MemoryView":174
 *             self.data = <char *>malloc(self.len)
 *             if not self.data:
 *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
 * 
 *             if self.dtype_is_object:
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__206, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(4, 174, __pyx_L1_error)

      /* "View.MemoryView":173
 * 
 *             self.data = <char *>malloc(self.len)
 *             if not self.data:             # <<<<<<<<<<<<<<
 *                 raise MemoryError("unable to allocate array data.")
 * 
 */
    }

    /* "View.MemoryView":176
 *                 raise MemoryError("unable to allocate array data.")
 * 
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 p = <PyObject **> self.data
 *                 for i in range(self.len / itemsize):
 */
    __pyx_t_4 = (__pyx_v_self->dtype_is_object != 0);
    if (__pyx_t_4) {

      /* "View.MemoryView":177
 * 
 *             if self.dtype_is_object:
 *                 p = <PyObject **> self.data             # <<<<<<<<<<<<<<
 *                 for i in range(self.len / itemsize):
 *                     p[i] = Py_None
 */
      __pyx_v_p = ((PyObject **)__pyx_v_self->data);

      /* "View.MemoryView":178
 *             if self.dtype_is_object:
 *                 p = <PyObject **> self.data
 *                 for i in range(self.len / itemsize):             # <<<<<<<<<<<<<<
 *                     p[i] = Py_None
 *                     Py_INCREF(Py_None)
 */
      if (unlikely(__pyx_v_itemsize == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
        __PYX_ERR(4, 178, __pyx_L1_error)
      }
      else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_self->len))) {
        PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
        __PYX_ERR(4, 178, __pyx_L1_error)
      }
      __pyx_t_1 = __Pyx_div_Py_ssize_t(__pyx_v_self->len, __pyx_v_itemsize);
      for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_1; __pyx_t_8+=1) {
        __pyx_v_i = __pyx_t_8;

        /* "View.MemoryView":179
 *                 p = <PyObject **> self.data
 *                 for i in range(self.len / itemsize):
 *                     p[i] = Py_None             # <<<<<<<<<<<<<<
 *                     Py_INCREF(Py_None)
 * 
 */
        (__pyx_v_p[__pyx_v_i]) = Py_None;

        /* "View.MemoryView":180
 *                 for i in range(self.len / itemsize):
 *                     p[i] = Py_None
 *                     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
 * 
 *     @cname('getbuffer')
 */
        Py_INCREF(Py_None);
      }

      /* "View.MemoryView":176
 *                 raise MemoryError("unable to allocate array data.")
 * 
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 p = <PyObject **> self.data
 *                 for i in range(self.len / itemsize):
 */
    }

    /* "View.MemoryView":169
 *         self.free_data = allocate_buffer
 *         self.dtype_is_object = format == b'O'
 *         if allocate_buffer:             # <<<<<<<<<<<<<<
 * 
 * 
 */
  }

  /* "View.MemoryView":120
 *         cdef bint dtype_is_object
 * 
 *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
 *                   mode="c", bint allocate_buffer=True):
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_format);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":183
 * 
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
 *         cdef int bufmode = -1
 *         if self.mode == u"c":
 */

/* Python wrapper */
static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
  __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(((struct __pyx_array_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_v_bufmode;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  char *__pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t *__pyx_t_7;
  __Pyx_RefNannySetupContext("__getbuffer__", 0);
  if (__pyx_v_info != NULL) {
    __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(__pyx_v_info->obj);
  }

  /* "View.MemoryView":184
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):
 *         cdef int bufmode = -1             # <<<<<<<<<<<<<<
 *         if self.mode == u"c":
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 */
  __pyx_v_bufmode = -1;

  /* "View.MemoryView":185
 *     def __getbuffer__(self, Py_buffer *info, int flags):
 *         cdef int bufmode = -1
 *         if self.mode == u"c":             # <<<<<<<<<<<<<<
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         elif self.mode == u"fortran":
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(4, 185, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":186
 *         cdef int bufmode = -1
 *         if self.mode == u"c":
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
 *         elif self.mode == u"fortran":
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 */
    __pyx_v_bufmode = (PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);

    /* "View.MemoryView":185
 *     def __getbuffer__(self, Py_buffer *info, int flags):
 *         cdef int bufmode = -1
 *         if self.mode == u"c":             # <<<<<<<<<<<<<<
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         elif self.mode == u"fortran":
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":187
 *         if self.mode == u"c":
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         elif self.mode == u"fortran":             # <<<<<<<<<<<<<<
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         if not (flags & bufmode):
 */
  __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_fortran, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(4, 187, __pyx_L1_error)
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":188
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         elif self.mode == u"fortran":
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
 *         if not (flags & bufmode):
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")
 */
    __pyx_v_bufmode = (PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);

    /* "View.MemoryView":187
 *         if self.mode == u"c":
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         elif self.mode == u"fortran":             # <<<<<<<<<<<<<<
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         if not (flags & bufmode):
 */
  }
  __pyx_L3:;

  /* "View.MemoryView":189
 *         elif self.mode == u"fortran":
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         if not (flags & bufmode):             # <<<<<<<<<<<<<<
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")
 *         info.buf = self.data
 */
  __pyx_t_1 = ((!((__pyx_v_flags & __pyx_v_bufmode) != 0)) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":190
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         if not (flags & bufmode):
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")             # <<<<<<<<<<<<<<
 *         info.buf = self.data
 *         info.len = self.len
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__207, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 190, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 190, __pyx_L1_error)

    /* "View.MemoryView":189
 *         elif self.mode == u"fortran":
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         if not (flags & bufmode):             # <<<<<<<<<<<<<<
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")
 *         info.buf = self.data
 */
  }

  /* "View.MemoryView":191
 *         if not (flags & bufmode):
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")
 *         info.buf = self.data             # <<<<<<<<<<<<<<
 *         info.len = self.len
 *         info.ndim = self.ndim
 */
  __pyx_t_4 = __pyx_v_self->data;
  __pyx_v_info->buf = __pyx_t_4;

  /* "View.MemoryView":192
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")
 *         info.buf = self.data
 *         info.len = self.len             # <<<<<<<<<<<<<<
 *         info.ndim = self.ndim
 *         info.shape = self._shape
 */
  __pyx_t_5 = __pyx_v_self->len;
  __pyx_v_info->len = __pyx_t_5;

  /* "View.MemoryView":193
 *         info.buf = self.data
 *         info.len = self.len
 *         info.ndim = self.ndim             # <<<<<<<<<<<<<<
 *         info.shape = self._shape
 *         info.strides = self._strides
 */
  __pyx_t_6 = __pyx_v_self->ndim;
  __pyx_v_info->ndim = __pyx_t_6;

  /* "View.MemoryView":194
 *         info.len = self.len
 *         info.ndim = self.ndim
 *         info.shape = self._shape             # <<<<<<<<<<<<<<
 *         info.strides = self._strides
 *         info.suboffsets = NULL
 */
  __pyx_t_7 = __pyx_v_self->_shape;
  __pyx_v_info->shape = __pyx_t_7;

  /* "View.MemoryView":195
 *         info.ndim = self.ndim
 *         info.shape = self._shape
 *         info.strides = self._strides             # <<<<<<<<<<<<<<
 *         info.suboffsets = NULL
 *         info.itemsize = self.itemsize
 */
  __pyx_t_7 = __pyx_v_self->_strides;
  __pyx_v_info->strides = __pyx_t_7;

  /* "View.MemoryView":196
 *         info.shape = self._shape
 *         info.strides = self._strides
 *         info.suboffsets = NULL             # <<<<<<<<<<<<<<
 *         info.itemsize = self.itemsize
 *         info.readonly = 0
 */
  __pyx_v_info->suboffsets = NULL;

  /* "View.MemoryView":197
 *         info.strides = self._strides
 *         info.suboffsets = NULL
 *         info.itemsize = self.itemsize             # <<<<<<<<<<<<<<
 *         info.readonly = 0
 * 
 */
  __pyx_t_5 = __pyx_v_self->itemsize;
  __pyx_v_info->itemsize = __pyx_t_5;

  /* "View.MemoryView":198
 *         info.suboffsets = NULL
 *         info.itemsize = self.itemsize
 *         info.readonly = 0             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_FORMAT:
 */
  __pyx_v_info->readonly = 0;

  /* "View.MemoryView":200
 *         info.readonly = 0
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             info.format = self.format
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":201
 * 
 *         if flags & PyBUF_FORMAT:
 *             info.format = self.format             # <<<<<<<<<<<<<<
 *         else:
 *             info.format = NULL
 */
    __pyx_t_4 = __pyx_v_self->format;
    __pyx_v_info->format = __pyx_t_4;

    /* "View.MemoryView":200
 *         info.readonly = 0
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             info.format = self.format
 *         else:
 */
    goto __pyx_L5;
  }

  /* "View.MemoryView":203
 *             info.format = self.format
 *         else:
 *             info.format = NULL             # <<<<<<<<<<<<<<
 * 
 *         info.obj = self
 */
  /*else*/ {
    __pyx_v_info->format = NULL;
  }
  __pyx_L5:;

  /* "View.MemoryView":205
 *             info.format = NULL
 * 
 *         info.obj = self             # <<<<<<<<<<<<<<
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __Pyx_GOTREF(__pyx_v_info->obj);
  __Pyx_DECREF(__pyx_v_info->obj);
  __pyx_v_info->obj = ((PyObject *)__pyx_v_self);

  /* "View.MemoryView":183
 * 
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
 *         cdef int bufmode = -1
 *         if self.mode == u"c":
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) {
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
  }
  goto __pyx_L2;
  __pyx_L0:;
  if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
    __Pyx_GOTREF(Py_None);
    __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
  }
  __pyx_L2:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":209
 *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
 * 
 *     def __dealloc__(array self):             # <<<<<<<<<<<<<<
 *         if self.callback_free_data != NULL:
 *             self.callback_free_data(self.data)
 */

/* Python wrapper */
static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_array___dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "View.MemoryView":210
 * 
 *     def __dealloc__(array self):
 *         if self.callback_free_data != NULL:             # <<<<<<<<<<<<<<
 *             self.callback_free_data(self.data)
 *         elif self.free_data:
 */
  __pyx_t_1 = ((__pyx_v_self->callback_free_data != NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":211
 *     def __dealloc__(array self):
 *         if self.callback_free_data != NULL:
 *             self.callback_free_data(self.data)             # <<<<<<<<<<<<<<
 *         elif self.free_data:
 *             if self.dtype_is_object:
 */
    __pyx_v_self->callback_free_data(__pyx_v_self->data);

    /* "View.MemoryView":210
 * 
 *     def __dealloc__(array self):
 *         if self.callback_free_data != NULL:             # <<<<<<<<<<<<<<
 *             self.callback_free_data(self.data)
 *         elif self.free_data:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":212
 *         if self.callback_free_data != NULL:
 *             self.callback_free_data(self.data)
 *         elif self.free_data:             # <<<<<<<<<<<<<<
 *             if self.dtype_is_object:
 *                 refcount_objects_in_slice(self.data, self._shape,
 */
  __pyx_t_1 = (__pyx_v_self->free_data != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":213
 *             self.callback_free_data(self.data)
 *         elif self.free_data:
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 refcount_objects_in_slice(self.data, self._shape,
 *                                           self._strides, self.ndim, False)
 */
    __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":214
 *         elif self.free_data:
 *             if self.dtype_is_object:
 *                 refcount_objects_in_slice(self.data, self._shape,             # <<<<<<<<<<<<<<
 *                                           self._strides, self.ndim, False)
 *             free(self.data)
 */
      __pyx_memoryview_refcount_objects_in_slice(__pyx_v_self->data, __pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_self->ndim, 0);

      /* "View.MemoryView":213
 *             self.callback_free_data(self.data)
 *         elif self.free_data:
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 refcount_objects_in_slice(self.data, self._shape,
 *                                           self._strides, self.ndim, False)
 */
    }

    /* "View.MemoryView":216
 *                 refcount_objects_in_slice(self.data, self._shape,
 *                                           self._strides, self.ndim, False)
 *             free(self.data)             # <<<<<<<<<<<<<<
 *         PyObject_Free(self._shape)
 * 
 */
    free(__pyx_v_self->data);

    /* "View.MemoryView":212
 *         if self.callback_free_data != NULL:
 *             self.callback_free_data(self.data)
 *         elif self.free_data:             # <<<<<<<<<<<<<<
 *             if self.dtype_is_object:
 *                 refcount_objects_in_slice(self.data, self._shape,
 */
  }
  __pyx_L3:;

  /* "View.MemoryView":217
 *                                           self._strides, self.ndim, False)
 *             free(self.data)
 *         PyObject_Free(self._shape)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  PyObject_Free(__pyx_v_self->_shape);

  /* "View.MemoryView":209
 *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
 * 
 *     def __dealloc__(array self):             # <<<<<<<<<<<<<<
 *         if self.callback_free_data != NULL:
 *             self.callback_free_data(self.data)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "View.MemoryView":220
 * 
 *     @property
 *     def memview(self):             # <<<<<<<<<<<<<<
 *         return self.get_memview()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":221
 *     @property
 *     def memview(self):
 *         return self.get_memview()             # <<<<<<<<<<<<<<
 * 
 *     @cname('get_memview')
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_array *)__pyx_v_self->__pyx_vtab)->get_memview(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":220
 * 
 *     @property
 *     def memview(self):             # <<<<<<<<<<<<<<
 *         return self.get_memview()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.array.memview.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":224
 * 
 *     @cname('get_memview')
 *     cdef get_memview(self):             # <<<<<<<<<<<<<<
 *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
 *         return  memoryview(self, flags, self.dtype_is_object)
 */

static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self) {
  int __pyx_v_flags;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("get_memview", 0);

  /* "View.MemoryView":225
 *     @cname('get_memview')
 *     cdef get_memview(self):
 *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE             # <<<<<<<<<<<<<<
 *         return  memoryview(self, flags, self.dtype_is_object)
 * 
 */
  __pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE);

  /* "View.MemoryView":226
 *     cdef get_memview(self):
 *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
 *         return  memoryview(self, flags, self.dtype_is_object)             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 226, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 226, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 226, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 226, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":224
 * 
 *     @cname('get_memview')
 *     cdef get_memview(self):             # <<<<<<<<<<<<<<
 *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
 *         return  memoryview(self, flags, self.dtype_is_object)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.array.get_memview", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":228
 *         return  memoryview(self, flags, self.dtype_is_object)
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self._shape[0]
 * 
 */

/* Python wrapper */
static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(((struct __pyx_array_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "View.MemoryView":229
 * 
 *     def __len__(self):
 *         return self._shape[0]             # <<<<<<<<<<<<<<
 * 
 *     def __getattr__(self, attr):
 */
  __pyx_r = (__pyx_v_self->_shape[0]);
  goto __pyx_L0;

  /* "View.MemoryView":228
 *         return  memoryview(self, flags, self.dtype_is_object)
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self._shape[0]
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":231
 *         return self._shape[0]
 * 
 *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
 *         return getattr(self.memview, attr)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr); /*proto*/
static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0);
  __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__getattr__", 0);

  /* "View.MemoryView":232
 * 
 *     def __getattr__(self, attr):
 *         return getattr(self.memview, attr)             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, item):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 232, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetAttr(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 232, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":231
 *         return self._shape[0]
 * 
 *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
 *         return getattr(self.memview, attr)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.array.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":234
 *         return getattr(self.memview, attr)
 * 
 *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
 *         return self.memview[item]
 * 
 */

/* Python wrapper */
static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "View.MemoryView":235
 * 
 *     def __getitem__(self, item):
 *         return self.memview[item]             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, item, value):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 235, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 235, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":234
 *         return getattr(self.memview, attr)
 * 
 *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
 *         return self.memview[item]
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.array.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":237
 *         return self.memview[item]
 * 
 *     def __setitem__(self, item, value):             # <<<<<<<<<<<<<<
 *         self.memview[item] = value
 * 
 */

/* Python wrapper */
static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /*proto*/
static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
  __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setitem__", 0);

  /* "View.MemoryView":238
 * 
 *     def __setitem__(self, item, value):
 *         self.memview[item] = value             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) __PYX_ERR(4, 238, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "View.MemoryView":237
 *         return self.memview[item]
 * 
 *     def __setitem__(self, item, value):             # <<<<<<<<<<<<<<
 *         self.memview[item] = value
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.array.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf___pyx_array___reduce_cython__(((struct __pyx_array_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__208, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(4, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.array.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf___pyx_array_2__setstate_cython__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__209, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(4, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.array.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":242
 * 
 * @cname("__pyx_array_new")
 * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format,             # <<<<<<<<<<<<<<
 *                           char *mode, char *buf):
 *     cdef array result
 */

static struct __pyx_array_obj *__pyx_array_new(PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, char *__pyx_v_format, char *__pyx_v_mode, char *__pyx_v_buf) {
  struct __pyx_array_obj *__pyx_v_result = 0;
  struct __pyx_array_obj *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("array_cwrapper", 0);

  /* "View.MemoryView":246
 *     cdef array result
 * 
 *     if buf == NULL:             # <<<<<<<<<<<<<<
 *         result = array(shape, itemsize, format, mode.decode('ASCII'))
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_buf == NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":247
 * 
 *     if buf == NULL:
 *         result = array(shape, itemsize, format, mode.decode('ASCII'))             # <<<<<<<<<<<<<<
 *     else:
 *         result = array(shape, itemsize, format, mode.decode('ASCII'),
 */
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 247, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 247, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 247, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 247, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_shape);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 247, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "View.MemoryView":246
 *     cdef array result
 * 
 *     if buf == NULL:             # <<<<<<<<<<<<<<
 *         result = array(shape, itemsize, format, mode.decode('ASCII'))
 *     else:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":249
 *         result = array(shape, itemsize, format, mode.decode('ASCII'))
 *     else:
 *         result = array(shape, itemsize, format, mode.decode('ASCII'),             # <<<<<<<<<<<<<<
 *                        allocate_buffer=False)
 *         result.data = buf
 */
  /*else*/ {
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 249, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 249, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 249, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 249, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_3 = 0;

    /* "View.MemoryView":250
 *     else:
 *         result = array(shape, itemsize, format, mode.decode('ASCII'),
 *                        allocate_buffer=False)             # <<<<<<<<<<<<<<
 *         result.data = buf
 * 
 */
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 250, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) __PYX_ERR(4, 250, __pyx_L1_error)

    /* "View.MemoryView":249
 *         result = array(shape, itemsize, format, mode.decode('ASCII'))
 *     else:
 *         result = array(shape, itemsize, format, mode.decode('ASCII'),             # <<<<<<<<<<<<<<
 *                        allocate_buffer=False)
 *         result.data = buf
 */
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 249, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "View.MemoryView":251
 *         result = array(shape, itemsize, format, mode.decode('ASCII'),
 *                        allocate_buffer=False)
 *         result.data = buf             # <<<<<<<<<<<<<<
 * 
 *     return result
 */
    __pyx_v_result->data = __pyx_v_buf;
  }
  __pyx_L3:;

  /* "View.MemoryView":253
 *         result.data = buf
 * 
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "View.MemoryView":242
 * 
 * @cname("__pyx_array_new")
 * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format,             # <<<<<<<<<<<<<<
 *                           char *mode, char *buf):
 *     cdef array result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.array_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":279
 * cdef class Enum(object):
 *     cdef object name
 *     def __init__(self, name):             # <<<<<<<<<<<<<<
 *         self.name = name
 *     def __repr__(self):
 */

/* Python wrapper */
static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(4, 279, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_name = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 279, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("View.MemoryView.Enum.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "View.MemoryView":280
 *     cdef object name
 *     def __init__(self, name):
 *         self.name = name             # <<<<<<<<<<<<<<
 *     def __repr__(self):
 *         return self.name
 */
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(__pyx_v_self->name);
  __pyx_v_self->name = __pyx_v_name;

  /* "View.MemoryView":279
 * cdef class Enum(object):
 *     cdef object name
 *     def __init__(self, name):             # <<<<<<<<<<<<<<
 *         self.name = name
 *     def __repr__(self):
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":281
 *     def __init__(self, name):
 *         self.name = name
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return self.name
 * 
 */

/* Python wrapper */
static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "View.MemoryView":282
 *         self.name = name
 *     def __repr__(self):
 *         return self.name             # <<<<<<<<<<<<<<
 * 
 * cdef generic = Enum("<strided and direct or indirect>")
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->name);
  __pyx_r = __pyx_v_self->name;
  goto __pyx_L0;

  /* "View.MemoryView":281
 *     def __init__(self, name):
 *         self.name = name
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return self.name
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.name,)
 */

/* Python wrapper */
static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf___pyx_MemviewEnum___reduce_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.name,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->name);
  __Pyx_GIVEREF(__pyx_v_self->name);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->name);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.name,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":5
 *     state = (self.name,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.name is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.name,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.name is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_self->name != Py_None);
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.name is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":11
 *         use_setstate = self.name is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_184977713);
    __Pyx_GIVEREF(__pyx_int_184977713);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.name is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
 *     else:
 *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_184977713);
    __Pyx_GIVEREF(__pyx_int_184977713);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.name,)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.Enum.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf___pyx_MemviewEnum_2__setstate_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Enum__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(4, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_unpickle_Enum__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.Enum.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":296
 * 
 * @cname('__pyx_align_pointer')
 * cdef void *align_pointer(void *memory, size_t alignment) nogil:             # <<<<<<<<<<<<<<
 *     "Align pointer memory on a given boundary"
 *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
 */

static void *__pyx_align_pointer(void *__pyx_v_memory, size_t __pyx_v_alignment) {
  Py_intptr_t __pyx_v_aligned_p;
  size_t __pyx_v_offset;
  void *__pyx_r;
  int __pyx_t_1;

  /* "View.MemoryView":298
 * cdef void *align_pointer(void *memory, size_t alignment) nogil:
 *     "Align pointer memory on a given boundary"
 *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory             # <<<<<<<<<<<<<<
 *     cdef size_t offset
 * 
 */
  __pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory);

  /* "View.MemoryView":302
 * 
 *     with cython.cdivision(True):
 *         offset = aligned_p % alignment             # <<<<<<<<<<<<<<
 * 
 *     if offset > 0:
 */
  __pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment);

  /* "View.MemoryView":304
 *         offset = aligned_p % alignment
 * 
 *     if offset > 0:             # <<<<<<<<<<<<<<
 *         aligned_p += alignment - offset
 * 
 */
  __pyx_t_1 = ((__pyx_v_offset > 0) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":305
 * 
 *     if offset > 0:
 *         aligned_p += alignment - offset             # <<<<<<<<<<<<<<
 * 
 *     return <void *> aligned_p
 */
    __pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset));

    /* "View.MemoryView":304
 *         offset = aligned_p % alignment
 * 
 *     if offset > 0:             # <<<<<<<<<<<<<<
 *         aligned_p += alignment - offset
 * 
 */
  }

  /* "View.MemoryView":307
 *         aligned_p += alignment - offset
 * 
 *     return <void *> aligned_p             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = ((void *)__pyx_v_aligned_p);
  goto __pyx_L0;

  /* "View.MemoryView":296
 * 
 * @cname('__pyx_align_pointer')
 * cdef void *align_pointer(void *memory, size_t alignment) nogil:             # <<<<<<<<<<<<<<
 *     "Align pointer memory on a given boundary"
 *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":343
 *     cdef __Pyx_TypeInfo *typeinfo
 * 
 *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):             # <<<<<<<<<<<<<<
 *         self.obj = obj
 *         self.flags = flags
 */

/* Python wrapper */
static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_obj = 0;
  int __pyx_v_flags;
  int __pyx_v_dtype_is_object;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_flags,&__pyx_n_s_dtype_is_object,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); __PYX_ERR(4, 343, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype_is_object);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(4, 343, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_obj = values[0];
    __pyx_v_flags = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(4, 343, __pyx_L3_error)
    if (values[2]) {
      __pyx_v_dtype_is_object = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_dtype_is_object == (int)-1) && PyErr_Occurred())) __PYX_ERR(4, 343, __pyx_L3_error)
    } else {
      __pyx_v_dtype_is_object = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 343, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_obj, __pyx_v_flags, __pyx_v_dtype_is_object);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "View.MemoryView":344
 * 
 *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
 *         self.obj = obj             # <<<<<<<<<<<<<<
 *         self.flags = flags
 *         if type(self) is memoryview or obj is not None:
 */
  __Pyx_INCREF(__pyx_v_obj);
  __Pyx_GIVEREF(__pyx_v_obj);
  __Pyx_GOTREF(__pyx_v_self->obj);
  __Pyx_DECREF(__pyx_v_self->obj);
  __pyx_v_self->obj = __pyx_v_obj;

  /* "View.MemoryView":345
 *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
 *         self.obj = obj
 *         self.flags = flags             # <<<<<<<<<<<<<<
 *         if type(self) is memoryview or obj is not None:
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 */
  __pyx_v_self->flags = __pyx_v_flags;

  /* "View.MemoryView":346
 *         self.obj = obj
 *         self.flags = flags
 *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> self.view.obj == NULL:
 */
  __pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)__pyx_memoryview_type));
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_obj != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "View.MemoryView":347
 *         self.flags = flags
 *         if type(self) is memoryview or obj is not None:
 *             __Pyx_GetBuffer(obj, &self.view, flags)             # <<<<<<<<<<<<<<
 *             if <PyObject *> self.view.obj == NULL:
 *                 (<__pyx_buffer *> &self.view).obj = Py_None
 */
    __pyx_t_4 = __Pyx_GetBuffer(__pyx_v_obj, (&__pyx_v_self->view), __pyx_v_flags); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(4, 347, __pyx_L1_error)

    /* "View.MemoryView":348
 *         if type(self) is memoryview or obj is not None:
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> self.view.obj == NULL:             # <<<<<<<<<<<<<<
 *                 (<__pyx_buffer *> &self.view).obj = Py_None
 *                 Py_INCREF(Py_None)
 */
    __pyx_t_1 = ((((PyObject *)__pyx_v_self->view.obj) == NULL) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":349
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> self.view.obj == NULL:
 *                 (<__pyx_buffer *> &self.view).obj = Py_None             # <<<<<<<<<<<<<<
 *                 Py_INCREF(Py_None)
 * 
 */
      ((Py_buffer *)(&__pyx_v_self->view))->obj = Py_None;

      /* "View.MemoryView":350
 *             if <PyObject *> self.view.obj == NULL:
 *                 (<__pyx_buffer *> &self.view).obj = Py_None
 *                 Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
 * 
 *         global __pyx_memoryview_thread_locks_used
 */
      Py_INCREF(Py_None);

      /* "View.MemoryView":348
 *         if type(self) is memoryview or obj is not None:
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> self.view.obj == NULL:             # <<<<<<<<<<<<<<
 *                 (<__pyx_buffer *> &self.view).obj = Py_None
 *                 Py_INCREF(Py_None)
 */
    }

    /* "View.MemoryView":346
 *         self.obj = obj
 *         self.flags = flags
 *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> self.view.obj == NULL:
 */
  }

  /* "View.MemoryView":353
 * 
 *         global __pyx_memoryview_thread_locks_used
 *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:             # <<<<<<<<<<<<<<
 *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
 *             __pyx_memoryview_thread_locks_used += 1
 */
  __pyx_t_1 = ((__pyx_memoryview_thread_locks_used < 8) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":354
 *         global __pyx_memoryview_thread_locks_used
 *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
 *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]             # <<<<<<<<<<<<<<
 *             __pyx_memoryview_thread_locks_used += 1
 *         if self.lock is NULL:
 */
    __pyx_v_self->lock = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);

    /* "View.MemoryView":355
 *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
 *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
 *             __pyx_memoryview_thread_locks_used += 1             # <<<<<<<<<<<<<<
 *         if self.lock is NULL:
 *             self.lock = PyThread_allocate_lock()
 */
    __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used + 1);

    /* "View.MemoryView":353
 * 
 *         global __pyx_memoryview_thread_locks_used
 *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:             # <<<<<<<<<<<<<<
 *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
 *             __pyx_memoryview_thread_locks_used += 1
 */
  }

  /* "View.MemoryView":356
 *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
 *             __pyx_memoryview_thread_locks_used += 1
 *         if self.lock is NULL:             # <<<<<<<<<<<<<<
 *             self.lock = PyThread_allocate_lock()
 *             if self.lock is NULL:
 */
  __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":357
 *             __pyx_memoryview_thread_locks_used += 1
 *         if self.lock is NULL:
 *             self.lock = PyThread_allocate_lock()             # <<<<<<<<<<<<<<
 *             if self.lock is NULL:
 *                 raise MemoryError
 */
    __pyx_v_self->lock = PyThread_allocate_lock();

    /* "View.MemoryView":358
 *         if self.lock is NULL:
 *             self.lock = PyThread_allocate_lock()
 *             if self.lock is NULL:             # <<<<<<<<<<<<<<
 *                 raise MemoryError
 * 
 */
    __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":359
 *             self.lock = PyThread_allocate_lock()
 *             if self.lock is NULL:
 *                 raise MemoryError             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_FORMAT:
 */
      PyErr_NoMemory(); __PYX_ERR(4, 359, __pyx_L1_error)

      /* "View.MemoryView":358
 *         if self.lock is NULL:
 *             self.lock = PyThread_allocate_lock()
 *             if self.lock is NULL:             # <<<<<<<<<<<<<<
 *                 raise MemoryError
 * 
 */
    }

    /* "View.MemoryView":356
 *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
 *             __pyx_memoryview_thread_locks_used += 1
 *         if self.lock is NULL:             # <<<<<<<<<<<<<<
 *             self.lock = PyThread_allocate_lock()
 *             if self.lock is NULL:
 */
  }

  /* "View.MemoryView":361
 *                 raise MemoryError
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":362
 * 
 *         if flags & PyBUF_FORMAT:
 *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')             # <<<<<<<<<<<<<<
 *         else:
 *             self.dtype_is_object = dtype_is_object
 */
    __pyx_t_2 = (((__pyx_v_self->view.format[0]) == 'O') != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_self->view.format[1]) == '\x00') != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L11_bool_binop_done:;
    __pyx_v_self->dtype_is_object = __pyx_t_1;

    /* "View.MemoryView":361
 *                 raise MemoryError
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
 *         else:
 */
    goto __pyx_L10;
  }

  /* "View.MemoryView":364
 *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
 *         else:
 *             self.dtype_is_object = dtype_is_object             # <<<<<<<<<<<<<<
 * 
 *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
 */
  /*else*/ {
    __pyx_v_self->dtype_is_object = __pyx_v_dtype_is_object;
  }
  __pyx_L10:;

  /* "View.MemoryView":366
 *             self.dtype_is_object = dtype_is_object
 * 
 *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(             # <<<<<<<<<<<<<<
 *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
 *         self.typeinfo = NULL
 */
  __pyx_v_self->acquisition_count_aligned_p = ((__pyx_atomic_int *)__pyx_align_pointer(((void *)(&(__pyx_v_self->acquisition_count[0]))), (sizeof(__pyx_atomic_int))));

  /* "View.MemoryView":368
 *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
 *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
 *         self.typeinfo = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(memoryview self):
 */
  __pyx_v_self->typeinfo = NULL;

  /* "View.MemoryView":343
 *     cdef __Pyx_TypeInfo *typeinfo
 * 
 *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):             # <<<<<<<<<<<<<<
 *         self.obj = obj
 *         self.flags = flags
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":370
 *         self.typeinfo = NULL
 * 
 *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
 *         if self.obj is not None:
 *             __Pyx_ReleaseBuffer(&self.view)
 */

/* Python wrapper */
static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) {
  int __pyx_v_i;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyThread_type_lock __pyx_t_5;
  PyThread_type_lock __pyx_t_6;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "View.MemoryView":371
 * 
 *     def __dealloc__(memoryview self):
 *         if self.obj is not None:             # <<<<<<<<<<<<<<
 *             __Pyx_ReleaseBuffer(&self.view)
 * 
 */
  __pyx_t_1 = (__pyx_v_self->obj != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":372
 *     def __dealloc__(memoryview self):
 *         if self.obj is not None:
 *             __Pyx_ReleaseBuffer(&self.view)             # <<<<<<<<<<<<<<
 * 
 *         cdef int i
 */
    __Pyx_ReleaseBuffer((&__pyx_v_self->view));

    /* "View.MemoryView":371
 * 
 *     def __dealloc__(memoryview self):
 *         if self.obj is not None:             # <<<<<<<<<<<<<<
 *             __Pyx_ReleaseBuffer(&self.view)
 * 
 */
  }

  /* "View.MemoryView":376
 *         cdef int i
 *         global __pyx_memoryview_thread_locks_used
 *         if self.lock != NULL:             # <<<<<<<<<<<<<<
 *             for i in range(__pyx_memoryview_thread_locks_used):
 *                 if __pyx_memoryview_thread_locks[i] is self.lock:
 */
  __pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":377
 *         global __pyx_memoryview_thread_locks_used
 *         if self.lock != NULL:
 *             for i in range(__pyx_memoryview_thread_locks_used):             # <<<<<<<<<<<<<<
 *                 if __pyx_memoryview_thread_locks[i] is self.lock:
 *                     __pyx_memoryview_thread_locks_used -= 1
 */
    __pyx_t_3 = __pyx_memoryview_thread_locks_used;
    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_v_i = __pyx_t_4;

      /* "View.MemoryView":378
 *         if self.lock != NULL:
 *             for i in range(__pyx_memoryview_thread_locks_used):
 *                 if __pyx_memoryview_thread_locks[i] is self.lock:             # <<<<<<<<<<<<<<
 *                     __pyx_memoryview_thread_locks_used -= 1
 *                     if i != __pyx_memoryview_thread_locks_used:
 */
      __pyx_t_2 = (((__pyx_memoryview_thread_locks[__pyx_v_i]) == __pyx_v_self->lock) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":379
 *             for i in range(__pyx_memoryview_thread_locks_used):
 *                 if __pyx_memoryview_thread_locks[i] is self.lock:
 *                     __pyx_memoryview_thread_locks_used -= 1             # <<<<<<<<<<<<<<
 *                     if i != __pyx_memoryview_thread_locks_used:
 *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
 */
        __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used - 1);

        /* "View.MemoryView":380
 *                 if __pyx_memoryview_thread_locks[i] is self.lock:
 *                     __pyx_memoryview_thread_locks_used -= 1
 *                     if i != __pyx_memoryview_thread_locks_used:             # <<<<<<<<<<<<<<
 *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
 *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
 */
        __pyx_t_2 = ((__pyx_v_i != __pyx_memoryview_thread_locks_used) != 0);
        if (__pyx_t_2) {

          /* "View.MemoryView":382
 *                     if i != __pyx_memoryview_thread_locks_used:
 *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
 *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])             # <<<<<<<<<<<<<<
 *                     break
 *             else:
 */
          __pyx_t_5 = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
          __pyx_t_6 = (__pyx_memoryview_thread_locks[__pyx_v_i]);

          /* "View.MemoryView":381
 *                     __pyx_memoryview_thread_locks_used -= 1
 *                     if i != __pyx_memoryview_thread_locks_used:
 *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (             # <<<<<<<<<<<<<<
 *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
 *                     break
 */
          (__pyx_memoryview_thread_locks[__pyx_v_i]) = __pyx_t_5;
          (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]) = __pyx_t_6;

          /* "View.MemoryView":380
 *                 if __pyx_memoryview_thread_locks[i] is self.lock:
 *                     __pyx_memoryview_thread_locks_used -= 1
 *                     if i != __pyx_memoryview_thread_locks_used:             # <<<<<<<<<<<<<<
 *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
 *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
 */
        }

        /* "View.MemoryView":383
 *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
 *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
 *                     break             # <<<<<<<<<<<<<<
 *             else:
 *                 PyThread_free_lock(self.lock)
 */
        goto __pyx_L6_break;

        /* "View.MemoryView":378
 *         if self.lock != NULL:
 *             for i in range(__pyx_memoryview_thread_locks_used):
 *                 if __pyx_memoryview_thread_locks[i] is self.lock:             # <<<<<<<<<<<<<<
 *                     __pyx_memoryview_thread_locks_used -= 1
 *                     if i != __pyx_memoryview_thread_locks_used:
 */
      }
    }
    /*else*/ {

      /* "View.MemoryView":385
 *                     break
 *             else:
 *                 PyThread_free_lock(self.lock)             # <<<<<<<<<<<<<<
 * 
 *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
 */
      PyThread_free_lock(__pyx_v_self->lock);
    }
    __pyx_L6_break:;

    /* "View.MemoryView":376
 *         cdef int i
 *         global __pyx_memoryview_thread_locks_used
 *         if self.lock != NULL:             # <<<<<<<<<<<<<<
 *             for i in range(__pyx_memoryview_thread_locks_used):
 *                 if __pyx_memoryview_thread_locks[i] is self.lock:
 */
  }

  /* "View.MemoryView":370
 *         self.typeinfo = NULL
 * 
 *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
 *         if self.obj is not None:
 *             __Pyx_ReleaseBuffer(&self.view)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "View.MemoryView":387
 *                 PyThread_free_lock(self.lock)
 * 
 *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t dim
 *         cdef char *itemp = <char *> self.view.buf
 */

static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
  Py_ssize_t __pyx_v_dim;
  char *__pyx_v_itemp;
  PyObject *__pyx_v_idx = NULL;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  char *__pyx_t_7;
  __Pyx_RefNannySetupContext("get_item_pointer", 0);

  /* "View.MemoryView":389
 *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
 *         cdef Py_ssize_t dim
 *         cdef char *itemp = <char *> self.view.buf             # <<<<<<<<<<<<<<
 * 
 *         for dim, idx in enumerate(index):
 */
  __pyx_v_itemp = ((char *)__pyx_v_self->view.buf);

  /* "View.MemoryView":391
 *         cdef char *itemp = <char *> self.view.buf
 * 
 *         for dim, idx in enumerate(index):             # <<<<<<<<<<<<<<
 *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
 * 
 */
  __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_v_index)) || PyTuple_CheckExact(__pyx_v_index)) {
    __pyx_t_2 = __pyx_v_index; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 391, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(4, 391, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 391, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(4, 391, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 391, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(4, 391, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_v_dim = __pyx_t_1;
    __pyx_t_1 = (__pyx_t_1 + 1);

    /* "View.MemoryView":392
 * 
 *         for dim, idx in enumerate(index):
 *             itemp = pybuffer_index(&self.view, itemp, idx, dim)             # <<<<<<<<<<<<<<
 * 
 *         return itemp
 */
    __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 392, __pyx_L1_error)
    __pyx_t_7 = __pyx_pybuffer_index((&__pyx_v_self->view), __pyx_v_itemp, __pyx_t_6, __pyx_v_dim); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(4, 392, __pyx_L1_error)
    __pyx_v_itemp = __pyx_t_7;

    /* "View.MemoryView":391
 *         cdef char *itemp = <char *> self.view.buf
 * 
 *         for dim, idx in enumerate(index):             # <<<<<<<<<<<<<<
 *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "View.MemoryView":394
 *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
 * 
 *         return itemp             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_itemp;
  goto __pyx_L0;

  /* "View.MemoryView":387
 *                 PyThread_free_lock(self.lock)
 * 
 *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t dim
 *         cdef char *itemp = <char *> self.view.buf
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.memoryview.get_item_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_idx);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":397
 * 
 * 
 *     def __getitem__(memoryview self, object index):             # <<<<<<<<<<<<<<
 *         if index is Ellipsis:
 *             return self
 */

/* Python wrapper */
static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/
static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
  PyObject *__pyx_v_have_slices = NULL;
  PyObject *__pyx_v_indices = NULL;
  char *__pyx_v_itemp;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  char *__pyx_t_6;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "View.MemoryView":398
 * 
 *     def __getitem__(memoryview self, object index):
 *         if index is Ellipsis:             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  __pyx_t_1 = (__pyx_v_index == __pyx_builtin_Ellipsis);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":399
 *     def __getitem__(memoryview self, object index):
 *         if index is Ellipsis:
 *             return self             # <<<<<<<<<<<<<<
 * 
 *         have_slices, indices = _unellipsify(index, self.view.ndim)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = ((PyObject *)__pyx_v_self);
    goto __pyx_L0;

    /* "View.MemoryView":398
 * 
 *     def __getitem__(memoryview self, object index):
 *         if index is Ellipsis:             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  }

  /* "View.MemoryView":401
 *             return self
 * 
 *         have_slices, indices = _unellipsify(index, self.view.ndim)             # <<<<<<<<<<<<<<
 * 
 *         cdef char *itemp
 */
  __pyx_t_3 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (likely(__pyx_t_3 != Py_None)) {
    PyObject* sequence = __pyx_t_3;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(4, 401, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 401, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 401, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(4, 401, __pyx_L1_error)
  }
  __pyx_v_have_slices = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_v_indices = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "View.MemoryView":404
 * 
 *         cdef char *itemp
 *         if have_slices:             # <<<<<<<<<<<<<<
 *             return memview_slice(self, indices)
 *         else:
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(4, 404, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "View.MemoryView":405
 *         cdef char *itemp
 *         if have_slices:
 *             return memview_slice(self, indices)             # <<<<<<<<<<<<<<
 *         else:
 *             itemp = self.get_item_pointer(indices)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = ((PyObject *)__pyx_memview_slice(__pyx_v_self, __pyx_v_indices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 405, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "View.MemoryView":404
 * 
 *         cdef char *itemp
 *         if have_slices:             # <<<<<<<<<<<<<<
 *             return memview_slice(self, indices)
 *         else:
 */
  }

  /* "View.MemoryView":407
 *             return memview_slice(self, indices)
 *         else:
 *             itemp = self.get_item_pointer(indices)             # <<<<<<<<<<<<<<
 *             return self.convert_item_to_object(itemp)
 * 
 */
  /*else*/ {
    __pyx_t_6 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_indices); if (unlikely(__pyx_t_6 == NULL)) __PYX_ERR(4, 407, __pyx_L1_error)
    __pyx_v_itemp = __pyx_t_6;

    /* "View.MemoryView":408
 *         else:
 *             itemp = self.get_item_pointer(indices)
 *             return self.convert_item_to_object(itemp)             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(memoryview self, object index, object value):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->convert_item_to_object(__pyx_v_self, __pyx_v_itemp); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "View.MemoryView":397
 * 
 * 
 *     def __getitem__(memoryview self, object index):             # <<<<<<<<<<<<<<
 *         if index is Ellipsis:
 *             return self
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.memoryview.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_have_slices);
  __Pyx_XDECREF(__pyx_v_indices);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":410
 *             return self.convert_item_to_object(itemp)
 * 
 *     def __setitem__(memoryview self, object index, object value):             # <<<<<<<<<<<<<<
 *         have_slices, index = _unellipsify(index, self.view.ndim)
 * 
 */

/* Python wrapper */
static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /*proto*/
static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
  PyObject *__pyx_v_have_slices = NULL;
  PyObject *__pyx_v_obj = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("__setitem__", 0);
  __Pyx_INCREF(__pyx_v_index);

  /* "View.MemoryView":411
 * 
 *     def __setitem__(memoryview self, object index, object value):
 *         have_slices, index = _unellipsify(index, self.view.ndim)             # <<<<<<<<<<<<<<
 * 
 *         if have_slices:
 */
  __pyx_t_1 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 411, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(4, 411, __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(4, 411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(4, 411, __pyx_L1_error)
  }
  __pyx_v_have_slices = __pyx_t_2;
  __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_index, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "View.MemoryView":413
 *         have_slices, index = _unellipsify(index, self.view.ndim)
 * 
 *         if have_slices:             # <<<<<<<<<<<<<<
 *             obj = self.is_slice(value)
 *             if obj:
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(4, 413, __pyx_L1_error)
  if (__pyx_t_4) {

    /* "View.MemoryView":414
 * 
 *         if have_slices:
 *             obj = self.is_slice(value)             # <<<<<<<<<<<<<<
 *             if obj:
 *                 self.setitem_slice_assignment(self[index], obj)
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->is_slice(__pyx_v_self, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 414, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_obj = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "View.MemoryView":415
 *         if have_slices:
 *             obj = self.is_slice(value)
 *             if obj:             # <<<<<<<<<<<<<<
 *                 self.setitem_slice_assignment(self[index], obj)
 *             else:
 */
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(4, 415, __pyx_L1_error)
    if (__pyx_t_4) {

      /* "View.MemoryView":416
 *             obj = self.is_slice(value)
 *             if obj:
 *                 self.setitem_slice_assignment(self[index], obj)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.setitem_slice_assign_scalar(self[index], value)
 */
      __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 416, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assignment(__pyx_v_self, __pyx_t_1, __pyx_v_obj); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 416, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "View.MemoryView":415
 *         if have_slices:
 *             obj = self.is_slice(value)
 *             if obj:             # <<<<<<<<<<<<<<
 *                 self.setitem_slice_assignment(self[index], obj)
 *             else:
 */
      goto __pyx_L4;
    }

    /* "View.MemoryView":418
 *                 self.setitem_slice_assignment(self[index], obj)
 *             else:
 *                 self.setitem_slice_assign_scalar(self[index], value)             # <<<<<<<<<<<<<<
 *         else:
 *             self.setitem_indexed(index, value)
 */
    /*else*/ {
      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 418, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(4, 418, __pyx_L1_error)
      __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assign_scalar(__pyx_v_self, ((struct __pyx_memoryview_obj *)__pyx_t_3), __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 418, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L4:;

    /* "View.MemoryView":413
 *         have_slices, index = _unellipsify(index, self.view.ndim)
 * 
 *         if have_slices:             # <<<<<<<<<<<<<<
 *             obj = self.is_slice(value)
 *             if obj:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":420
 *                 self.setitem_slice_assign_scalar(self[index], value)
 *         else:
 *             self.setitem_indexed(index, value)             # <<<<<<<<<<<<<<
 * 
 *     cdef is_slice(self, obj):
 */
  /*else*/ {
    __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_indexed(__pyx_v_self, __pyx_v_index, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 420, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "View.MemoryView":410
 *             return self.convert_item_to_object(itemp)
 * 
 *     def __setitem__(memoryview self, object index, object value):             # <<<<<<<<<<<<<<
 *         have_slices, index = _unellipsify(index, self.view.ndim)
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.memoryview.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_have_slices);
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_XDECREF(__pyx_v_index);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":422
 *             self.setitem_indexed(index, value)
 * 
 *     cdef is_slice(self, obj):             # <<<<<<<<<<<<<<
 *         if not isinstance(obj, memoryview):
 *             try:
 */

static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("is_slice", 0);
  __Pyx_INCREF(__pyx_v_obj);

  /* "View.MemoryView":423
 * 
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_memoryview_type); 
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":424
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):
 *             try:             # <<<<<<<<<<<<<<
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 *                                  self.dtype_is_object)
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_5);
      /*try:*/ {

        /* "View.MemoryView":425
 *         if not isinstance(obj, memoryview):
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
 *                                  self.dtype_is_object)
 *             except TypeError:
 */
        __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_self->flags | PyBUF_ANY_CONTIGUOUS)); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 425, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);

        /* "View.MemoryView":426
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 *                                  self.dtype_is_object)             # <<<<<<<<<<<<<<
 *             except TypeError:
 *                 return None
 */
        __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 426, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);

        /* "View.MemoryView":425
 *         if not isinstance(obj, memoryview):
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
 *                                  self.dtype_is_object)
 *             except TypeError:
 */
        __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 425, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_INCREF(__pyx_v_obj);
        __Pyx_GIVEREF(__pyx_v_obj);
        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
        __pyx_t_6 = 0;
        __pyx_t_7 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 425, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_7);
        __pyx_t_7 = 0;

        /* "View.MemoryView":424
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):
 *             try:             # <<<<<<<<<<<<<<
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 *                                  self.dtype_is_object)
 */
      }
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L9_try_end;
      __pyx_L4_error:;
      __Pyx_PyThreadState_assign
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "View.MemoryView":427
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 *                                  self.dtype_is_object)
 *             except TypeError:             # <<<<<<<<<<<<<<
 *                 return None
 * 
 */
      __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
      if (__pyx_t_9) {
        __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) __PYX_ERR(4, 427, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GOTREF(__pyx_t_6);

        /* "View.MemoryView":428
 *                                  self.dtype_is_object)
 *             except TypeError:
 *                 return None             # <<<<<<<<<<<<<<
 * 
 *         return obj
 */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_None);
        __pyx_r = Py_None;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L7_except_return;
      }
      goto __pyx_L6_except_error;
      __pyx_L6_except_error:;

      /* "View.MemoryView":424
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):
 *             try:             # <<<<<<<<<<<<<<
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 *                                  self.dtype_is_object)
 */
      __Pyx_PyThreadState_assign
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      goto __pyx_L1_error;
      __pyx_L7_except_return:;
      __Pyx_PyThreadState_assign
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      goto __pyx_L0;
      __pyx_L9_try_end:;
    }

    /* "View.MemoryView":423
 * 
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 */
  }

  /* "View.MemoryView":430
 *                 return None
 * 
 *         return obj             # <<<<<<<<<<<<<<
 * 
 *     cdef setitem_slice_assignment(self, dst, src):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_obj);
  __pyx_r = __pyx_v_obj;
  goto __pyx_L0;

  /* "View.MemoryView":422
 *             self.setitem_indexed(index, value)
 * 
 *     cdef is_slice(self, obj):             # <<<<<<<<<<<<<<
 *         if not isinstance(obj, memoryview):
 *             try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":432
 *         return obj
 * 
 *     cdef setitem_slice_assignment(self, dst, src):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice dst_slice
 *         cdef __Pyx_memviewslice src_slice
 */

static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src) {
  __Pyx_memviewslice __pyx_v_dst_slice;
  __Pyx_memviewslice __pyx_v_src_slice;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("setitem_slice_assignment", 0);

  /* "View.MemoryView":436
 *         cdef __Pyx_memviewslice src_slice
 * 
 *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],             # <<<<<<<<<<<<<<
 *                                  get_slice_from_memview(dst, &dst_slice)[0],
 *                                  src.ndim, dst.ndim, self.dtype_is_object)
 */
  if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_memoryview_type))))) __PYX_ERR(4, 436, __pyx_L1_error)

  /* "View.MemoryView":437
 * 
 *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
 *                                  get_slice_from_memview(dst, &dst_slice)[0],             # <<<<<<<<<<<<<<
 *                                  src.ndim, dst.ndim, self.dtype_is_object)
 * 
 */
  if (!(likely(((__pyx_v_dst) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dst, __pyx_memoryview_type))))) __PYX_ERR(4, 437, __pyx_L1_error)

  /* "View.MemoryView":438
 *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
 *                                  get_slice_from_memview(dst, &dst_slice)[0],
 *                                  src.ndim, dst.ndim, self.dtype_is_object)             # <<<<<<<<<<<<<<
 * 
 *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(4, 438, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dst, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(4, 438, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "View.MemoryView":436
 *         cdef __Pyx_memviewslice src_slice
 * 
 *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],             # <<<<<<<<<<<<<<
 *                                  get_slice_from_memview(dst, &dst_slice)[0],
 *                                  src.ndim, dst.ndim, self.dtype_is_object)
 */
  __pyx_t_4 = __pyx_memoryview_copy_contents((__pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_src), (&__pyx_v_src_slice))[0]), (__pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_dst), (&__pyx_v_dst_slice))[0]), __pyx_t_2, __pyx_t_3, __pyx_v_self->dtype_is_object); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(4, 436, __pyx_L1_error)

  /* "View.MemoryView":432
 *         return obj
 * 
 *     cdef setitem_slice_assignment(self, dst, src):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice dst_slice
 *         cdef __Pyx_memviewslice src_slice
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assignment", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":440
 *                                  src.ndim, dst.ndim, self.dtype_is_object)
 * 
 *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):             # <<<<<<<<<<<<<<
 *         cdef int array[128]
 *         cdef void *tmp = NULL
 */

static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value) {
  int __pyx_v_array[0x80];
  void *__pyx_v_tmp;
  void *__pyx_v_item;
  __Pyx_memviewslice *__pyx_v_dst_slice;
  __Pyx_memviewslice __pyx_v_tmp_slice;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  char const *__pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0);

  /* "View.MemoryView":442
 *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):
 *         cdef int array[128]
 *         cdef void *tmp = NULL             # <<<<<<<<<<<<<<
 *         cdef void *item
 * 
 */
  __pyx_v_tmp = NULL;

  /* "View.MemoryView":447
 *         cdef __Pyx_memviewslice *dst_slice
 *         cdef __Pyx_memviewslice tmp_slice
 *         dst_slice = get_slice_from_memview(dst, &tmp_slice)             # <<<<<<<<<<<<<<
 * 
 *         if <size_t>self.view.itemsize > sizeof(array):
 */
  __pyx_v_dst_slice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_dst, (&__pyx_v_tmp_slice));

  /* "View.MemoryView":449
 *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
 * 
 *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:
 */
  __pyx_t_1 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":450
 * 
 *         if <size_t>self.view.itemsize > sizeof(array):
 *             tmp = PyMem_Malloc(self.view.itemsize)             # <<<<<<<<<<<<<<
 *             if tmp == NULL:
 *                 raise MemoryError
 */
    __pyx_v_tmp = PyMem_Malloc(__pyx_v_self->view.itemsize);

    /* "View.MemoryView":451
 *         if <size_t>self.view.itemsize > sizeof(array):
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:             # <<<<<<<<<<<<<<
 *                 raise MemoryError
 *             item = tmp
 */
    __pyx_t_1 = ((__pyx_v_tmp == NULL) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":452
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:
 *                 raise MemoryError             # <<<<<<<<<<<<<<
 *             item = tmp
 *         else:
 */
      PyErr_NoMemory(); __PYX_ERR(4, 452, __pyx_L1_error)

      /* "View.MemoryView":451
 *         if <size_t>self.view.itemsize > sizeof(array):
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:             # <<<<<<<<<<<<<<
 *                 raise MemoryError
 *             item = tmp
 */
    }

    /* "View.MemoryView":453
 *             if tmp == NULL:
 *                 raise MemoryError
 *             item = tmp             # <<<<<<<<<<<<<<
 *         else:
 *             item = <void *> array
 */
    __pyx_v_item = __pyx_v_tmp;

    /* "View.MemoryView":449
 *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
 * 
 *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":455
 *             item = tmp
 *         else:
 *             item = <void *> array             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  /*else*/ {
    __pyx_v_item = ((void *)__pyx_v_array);
  }
  __pyx_L3:;

  /* "View.MemoryView":457
 *             item = <void *> array
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if self.dtype_is_object:
 *                 (<PyObject **> item)[0] = <PyObject *> value
 */
  /*try:*/ {

    /* "View.MemoryView":458
 * 
 *         try:
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 (<PyObject **> item)[0] = <PyObject *> value
 *             else:
 */
    __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":459
 *         try:
 *             if self.dtype_is_object:
 *                 (<PyObject **> item)[0] = <PyObject *> value             # <<<<<<<<<<<<<<
 *             else:
 *                 self.assign_item_from_object(<char *> item, value)
 */
      (((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value);

      /* "View.MemoryView":458
 * 
 *         try:
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 (<PyObject **> item)[0] = <PyObject *> value
 *             else:
 */
      goto __pyx_L8;
    }

    /* "View.MemoryView":461
 *                 (<PyObject **> item)[0] = <PyObject *> value
 *             else:
 *                 self.assign_item_from_object(<char *> item, value)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    /*else*/ {
      __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, ((char *)__pyx_v_item), __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 461, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __pyx_L8:;

    /* "View.MemoryView":465
 * 
 * 
 *             if self.view.suboffsets != NULL:             # <<<<<<<<<<<<<<
 *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
 *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
 */
    __pyx_t_1 = ((__pyx_v_self->view.suboffsets != NULL) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":466
 * 
 *             if self.view.suboffsets != NULL:
 *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)             # <<<<<<<<<<<<<<
 *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
 *                                 item, self.dtype_is_object)
 */
      __pyx_t_2 = assert_direct_dimensions(__pyx_v_self->view.suboffsets, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 466, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "View.MemoryView":465
 * 
 * 
 *             if self.view.suboffsets != NULL:             # <<<<<<<<<<<<<<
 *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
 *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
 */
    }

    /* "View.MemoryView":467
 *             if self.view.suboffsets != NULL:
 *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
 *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,             # <<<<<<<<<<<<<<
 *                                 item, self.dtype_is_object)
 *         finally:
 */
    __pyx_memoryview_slice_assign_scalar(__pyx_v_dst_slice, __pyx_v_dst->view.ndim, __pyx_v_self->view.itemsize, __pyx_v_item, __pyx_v_self->dtype_is_object);
  }

  /* "View.MemoryView":470
 *                                 item, self.dtype_is_object)
 *         finally:
 *             PyMem_Free(tmp)             # <<<<<<<<<<<<<<
 * 
 *     cdef setitem_indexed(self, index, value):
 */
  /*finally:*/ {
    /*normal exit:*/{
      PyMem_Free(__pyx_v_tmp);
      goto __pyx_L7;
    }
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __pyx_L6_error:;
      __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
      __Pyx_PyThreadState_assign
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __pyx_t_3 = __pyx_lineno; __pyx_t_4 = __pyx_clineno; __pyx_t_5 = __pyx_filename;
      {
        PyMem_Free(__pyx_v_tmp);
      }
      __Pyx_PyThreadState_assign
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
      __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_4; __pyx_filename = __pyx_t_5;
      goto __pyx_L1_error;
    }
    __pyx_L7:;
  }

  /* "View.MemoryView":440
 *                                  src.ndim, dst.ndim, self.dtype_is_object)
 * 
 *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):             # <<<<<<<<<<<<<<
 *         cdef int array[128]
 *         cdef void *tmp = NULL
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assign_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":472
 *             PyMem_Free(tmp)
 * 
 *     cdef setitem_indexed(self, index, value):             # <<<<<<<<<<<<<<
 *         cdef char *itemp = self.get_item_pointer(index)
 *         self.assign_item_from_object(itemp, value)
 */

static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
  char *__pyx_v_itemp;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  char *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("setitem_indexed", 0);

  /* "View.MemoryView":473
 * 
 *     cdef setitem_indexed(self, index, value):
 *         cdef char *itemp = self.get_item_pointer(index)             # <<<<<<<<<<<<<<
 *         self.assign_item_from_object(itemp, value)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_index); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(4, 473, __pyx_L1_error)
  __pyx_v_itemp = __pyx_t_1;

  /* "View.MemoryView":474
 *     cdef setitem_indexed(self, index, value):
 *         cdef char *itemp = self.get_item_pointer(index)
 *         self.assign_item_from_object(itemp, value)             # <<<<<<<<<<<<<<
 * 
 *     cdef convert_item_to_object(self, char *itemp):
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 474, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "View.MemoryView":472
 *             PyMem_Free(tmp)
 * 
 *     cdef setitem_indexed(self, index, value):             # <<<<<<<<<<<<<<
 *         cdef char *itemp = self.get_item_pointer(index)
 *         self.assign_item_from_object(itemp, value)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_indexed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":476
 *         self.assign_item_from_object(itemp, value)
 * 
 *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 */

static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp) {
  PyObject *__pyx_v_struct = NULL;
  PyObject *__pyx_v_bytesitem = 0;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  size_t __pyx_t_10;
  int __pyx_t_11;
  __Pyx_RefNannySetupContext("convert_item_to_object", 0);

  /* "View.MemoryView":479
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 *         import struct             # <<<<<<<<<<<<<<
 *         cdef bytes bytesitem
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 479, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_struct = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "View.MemoryView":482
 *         cdef bytes bytesitem
 * 
 *         bytesitem = itemp[:self.view.itemsize]             # <<<<<<<<<<<<<<
 *         try:
 *             result = struct.unpack(self.view.format, bytesitem)
 */
  __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_itemp + 0, __pyx_v_self->view.itemsize - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 482, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_bytesitem = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":483
 * 
 *         bytesitem = itemp[:self.view.itemsize]
 *         try:             # <<<<<<<<<<<<<<
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    /*try:*/ {

      /* "View.MemoryView":484
 *         bytesitem = itemp[:self.view.itemsize]
 *         try:
 *             result = struct.unpack(self.view.format, bytesitem)             # <<<<<<<<<<<<<<
 *         except struct.error:
 *             raise ValueError("Unable to convert item to object")
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_unpack); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 484, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 484, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_8 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 484, __pyx_L3_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 484, __pyx_L3_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 484, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (__pyx_t_7) {
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6);
        __Pyx_INCREF(__pyx_v_bytesitem);
        __Pyx_GIVEREF(__pyx_v_bytesitem);
        PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 484, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_result = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "View.MemoryView":483
 * 
 *         bytesitem = itemp[:self.view.itemsize]
 *         try:             # <<<<<<<<<<<<<<
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:
 */
    }

    /* "View.MemoryView":488
 *             raise ValueError("Unable to convert item to object")
 *         else:
 *             if len(self.view.format) == 1:             # <<<<<<<<<<<<<<
 *                 return result[0]
 *             return result
 */
    /*else:*/ {
      __pyx_t_10 = strlen(__pyx_v_self->view.format); 
      __pyx_t_11 = ((__pyx_t_10 == 1) != 0);
      if (__pyx_t_11) {

        /* "View.MemoryView":489
 *         else:
 *             if len(self.view.format) == 1:
 *                 return result[0]             # <<<<<<<<<<<<<<
 *             return result
 * 
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_result, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 489, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_r = __pyx_t_1;
        __pyx_t_1 = 0;
        goto __pyx_L6_except_return;

        /* "View.MemoryView":488
 *             raise ValueError("Unable to convert item to object")
 *         else:
 *             if len(self.view.format) == 1:             # <<<<<<<<<<<<<<
 *                 return result[0]
 *             return result
 */
      }

      /* "View.MemoryView":490
 *             if len(self.view.format) == 1:
 *                 return result[0]
 *             return result             # <<<<<<<<<<<<<<
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_result);
      __pyx_r = __pyx_v_result;
      goto __pyx_L6_except_return;
    }
    __pyx_L3_error:;
    __Pyx_PyThreadState_assign
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "View.MemoryView":485
 *         try:
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:             # <<<<<<<<<<<<<<
 *             raise ValueError("Unable to convert item to object")
 *         else:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 485, __pyx_L5_except_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_8) {
      __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9) < 0) __PYX_ERR(4, 485, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_9);

      /* "View.MemoryView":486
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:
 *             raise ValueError("Unable to convert item to object")             # <<<<<<<<<<<<<<
 *         else:
 *             if len(self.view.format) == 1:
 */
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__210, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 486, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __PYX_ERR(4, 486, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "View.MemoryView":483
 * 
 *         bytesitem = itemp[:self.view.itemsize]
 *         try:             # <<<<<<<<<<<<<<
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:
 */
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
    goto __pyx_L0;
  }

  /* "View.MemoryView":476
 *         self.assign_item_from_object(itemp, value)
 * 
 *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_struct);
  __Pyx_XDECREF(__pyx_v_bytesitem);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":492
 *             return result
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 */

static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
  PyObject *__pyx_v_struct = NULL;
  char __pyx_v_c;
  PyObject *__pyx_v_bytesvalue = 0;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  char *__pyx_t_11;
  char *__pyx_t_12;
  char *__pyx_t_13;
  char *__pyx_t_14;
  __Pyx_RefNannySetupContext("assign_item_from_object", 0);

  /* "View.MemoryView":495
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 *         import struct             # <<<<<<<<<<<<<<
 *         cdef char c
 *         cdef bytes bytesvalue
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 495, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_struct = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "View.MemoryView":500
 *         cdef Py_ssize_t i
 * 
 *         if isinstance(value, tuple):             # <<<<<<<<<<<<<<
 *             bytesvalue = struct.pack(self.view.format, *value)
 *         else:
 */
  __pyx_t_2 = PyTuple_Check(__pyx_v_value); 
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "View.MemoryView":501
 * 
 *         if isinstance(value, tuple):
 *             bytesvalue = struct.pack(self.view.format, *value)             # <<<<<<<<<<<<<<
 *         else:
 *             bytesvalue = struct.pack(self.view.format, value)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 501, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 501, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 501, __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 = PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 501, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 501, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 501, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(4, 501, __pyx_L1_error)
    __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "View.MemoryView":500
 *         cdef Py_ssize_t i
 * 
 *         if isinstance(value, tuple):             # <<<<<<<<<<<<<<
 *             bytesvalue = struct.pack(self.view.format, *value)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":503
 *             bytesvalue = struct.pack(self.view.format, *value)
 *         else:
 *             bytesvalue = struct.pack(self.view.format, value)             # <<<<<<<<<<<<<<
 * 
 *         for i, c in enumerate(bytesvalue):
 */
  /*else*/ {
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 503, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 503, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 503, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value);
      __pyx_t_1 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 503, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(4, 503, __pyx_L1_error)
    __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "View.MemoryView":505
 *             bytesvalue = struct.pack(self.view.format, value)
 * 
 *         for i, c in enumerate(bytesvalue):             # <<<<<<<<<<<<<<
 *             itemp[i] = c
 * 
 */
  __pyx_t_9 = 0;
  if (unlikely(__pyx_v_bytesvalue == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
    __PYX_ERR(4, 505, __pyx_L1_error)
  }
  __Pyx_INCREF(__pyx_v_bytesvalue);
  __pyx_t_10 = __pyx_v_bytesvalue;
  __pyx_t_12 = PyBytes_AS_STRING(__pyx_t_10);
  __pyx_t_13 = (__pyx_t_12 + PyBytes_GET_SIZE(__pyx_t_10));
  for (__pyx_t_14 = __pyx_t_12; __pyx_t_14 < __pyx_t_13; __pyx_t_14++) {
    __pyx_t_11 = __pyx_t_14;
    __pyx_v_c = (__pyx_t_11[0]);

    /* "View.MemoryView":506
 * 
 *         for i, c in enumerate(bytesvalue):
 *             itemp[i] = c             # <<<<<<<<<<<<<<
 * 
 *     @cname('getbuffer')
 */
    __pyx_v_i = __pyx_t_9;

    /* "View.MemoryView":505
 *             bytesvalue = struct.pack(self.view.format, value)
 * 
 *         for i, c in enumerate(bytesvalue):             # <<<<<<<<<<<<<<
 *             itemp[i] = c
 * 
 */
    __pyx_t_9 = (__pyx_t_9 + 1);

    /* "View.MemoryView":506
 * 
 *         for i, c in enumerate(bytesvalue):
 *             itemp[i] = c             # <<<<<<<<<<<<<<
 * 
 *     @cname('getbuffer')
 */
    (__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "View.MemoryView":492
 *             return result
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_struct);
  __Pyx_XDECREF(__pyx_v_bytesvalue);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":509
 * 
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
 *         if flags & PyBUF_STRIDES:
 *             info.shape = self.view.shape
 */

/* Python wrapper */
static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  Py_ssize_t *__pyx_t_2;
  char *__pyx_t_3;
  void *__pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__getbuffer__", 0);
  if (__pyx_v_info != NULL) {
    __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(__pyx_v_info->obj);
  }

  /* "View.MemoryView":510
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):
 *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
 *             info.shape = self.view.shape
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":511
 *     def __getbuffer__(self, Py_buffer *info, int flags):
 *         if flags & PyBUF_STRIDES:
 *             info.shape = self.view.shape             # <<<<<<<<<<<<<<
 *         else:
 *             info.shape = NULL
 */
    __pyx_t_2 = __pyx_v_self->view.shape;
    __pyx_v_info->shape = __pyx_t_2;

    /* "View.MemoryView":510
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):
 *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
 *             info.shape = self.view.shape
 *         else:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":513
 *             info.shape = self.view.shape
 *         else:
 *             info.shape = NULL             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_STRIDES:
 */
  /*else*/ {
    __pyx_v_info->shape = NULL;
  }
  __pyx_L3:;

  /* "View.MemoryView":515
 *             info.shape = NULL
 * 
 *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
 *             info.strides = self.view.strides
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":516
 * 
 *         if flags & PyBUF_STRIDES:
 *             info.strides = self.view.strides             # <<<<<<<<<<<<<<
 *         else:
 *             info.strides = NULL
 */
    __pyx_t_2 = __pyx_v_self->view.strides;
    __pyx_v_info->strides = __pyx_t_2;

    /* "View.MemoryView":515
 *             info.shape = NULL
 * 
 *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
 *             info.strides = self.view.strides
 *         else:
 */
    goto __pyx_L4;
  }

  /* "View.MemoryView":518
 *             info.strides = self.view.strides
 *         else:
 *             info.strides = NULL             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_INDIRECT:
 */
  /*else*/ {
    __pyx_v_info->strides = NULL;
  }
  __pyx_L4:;

  /* "View.MemoryView":520
 *             info.strides = NULL
 * 
 *         if flags & PyBUF_INDIRECT:             # <<<<<<<<<<<<<<
 *             info.suboffsets = self.view.suboffsets
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_INDIRECT) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":521
 * 
 *         if flags & PyBUF_INDIRECT:
 *             info.suboffsets = self.view.suboffsets             # <<<<<<<<<<<<<<
 *         else:
 *             info.suboffsets = NULL
 */
    __pyx_t_2 = __pyx_v_self->view.suboffsets;
    __pyx_v_info->suboffsets = __pyx_t_2;

    /* "View.MemoryView":520
 *             info.strides = NULL
 * 
 *         if flags & PyBUF_INDIRECT:             # <<<<<<<<<<<<<<
 *             info.suboffsets = self.view.suboffsets
 *         else:
 */
    goto __pyx_L5;
  }

  /* "View.MemoryView":523
 *             info.suboffsets = self.view.suboffsets
 *         else:
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_FORMAT:
 */
  /*else*/ {
    __pyx_v_info->suboffsets = NULL;
  }
  __pyx_L5:;

  /* "View.MemoryView":525
 *             info.suboffsets = NULL
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             info.format = self.view.format
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":526
 * 
 *         if flags & PyBUF_FORMAT:
 *             info.format = self.view.format             # <<<<<<<<<<<<<<
 *         else:
 *             info.format = NULL
 */
    __pyx_t_3 = __pyx_v_self->view.format;
    __pyx_v_info->format = __pyx_t_3;

    /* "View.MemoryView":525
 *             info.suboffsets = NULL
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             info.format = self.view.format
 *         else:
 */
    goto __pyx_L6;
  }

  /* "View.MemoryView":528
 *             info.format = self.view.format
 *         else:
 *             info.format = NULL             # <<<<<<<<<<<<<<
 * 
 *         info.buf = self.view.buf
 */
  /*else*/ {
    __pyx_v_info->format = NULL;
  }
  __pyx_L6:;

  /* "View.MemoryView":530
 *             info.format = NULL
 * 
 *         info.buf = self.view.buf             # <<<<<<<<<<<<<<
 *         info.ndim = self.view.ndim
 *         info.itemsize = self.view.itemsize
 */
  __pyx_t_4 = __pyx_v_self->view.buf;
  __pyx_v_info->buf = __pyx_t_4;

  /* "View.MemoryView":531
 * 
 *         info.buf = self.view.buf
 *         info.ndim = self.view.ndim             # <<<<<<<<<<<<<<
 *         info.itemsize = self.view.itemsize
 *         info.len = self.view.len
 */
  __pyx_t_5 = __pyx_v_self->view.ndim;
  __pyx_v_info->ndim = __pyx_t_5;

  /* "View.MemoryView":532
 *         info.buf = self.view.buf
 *         info.ndim = self.view.ndim
 *         info.itemsize = self.view.itemsize             # <<<<<<<<<<<<<<
 *         info.len = self.view.len
 *         info.readonly = 0
 */
  __pyx_t_6 = __pyx_v_self->view.itemsize;
  __pyx_v_info->itemsize = __pyx_t_6;

  /* "View.MemoryView":533
 *         info.ndim = self.view.ndim
 *         info.itemsize = self.view.itemsize
 *         info.len = self.view.len             # <<<<<<<<<<<<<<
 *         info.readonly = 0
 *         info.obj = self
 */
  __pyx_t_6 = __pyx_v_self->view.len;
  __pyx_v_info->len = __pyx_t_6;

  /* "View.MemoryView":534
 *         info.itemsize = self.view.itemsize
 *         info.len = self.view.len
 *         info.readonly = 0             # <<<<<<<<<<<<<<
 *         info.obj = self
 * 
 */
  __pyx_v_info->readonly = 0;

  /* "View.MemoryView":535
 *         info.len = self.view.len
 *         info.readonly = 0
 *         info.obj = self             # <<<<<<<<<<<<<<
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __Pyx_GOTREF(__pyx_v_info->obj);
  __Pyx_DECREF(__pyx_v_info->obj);
  __pyx_v_info->obj = ((PyObject *)__pyx_v_self);

  /* "View.MemoryView":509
 * 
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
 *         if flags & PyBUF_STRIDES:
 *             info.shape = self.view.shape
 */

  /* function exit code */
  __pyx_r = 0;
  if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
    __Pyx_GOTREF(Py_None);
    __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":541
 * 
 *     @property
 *     def T(self):             # <<<<<<<<<<<<<<
 *         cdef _memoryviewslice result = memoryview_copy(self)
 *         transpose_memslice(&result.from_slice)
 */

/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":542
 *     @property
 *     def T(self):
 *         cdef _memoryviewslice result = memoryview_copy(self)             # <<<<<<<<<<<<<<
 *         transpose_memslice(&result.from_slice)
 *         return result
 */
  __pyx_t_1 = __pyx_memoryview_copy_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 542, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_memoryviewslice_type))))) __PYX_ERR(4, 542, __pyx_L1_error)
  __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":543
 *     def T(self):
 *         cdef _memoryviewslice result = memoryview_copy(self)
 *         transpose_memslice(&result.from_slice)             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
  __pyx_t_2 = __pyx_memslice_transpose((&__pyx_v_result->from_slice)); if (unlikely(__pyx_t_2 == 0)) __PYX_ERR(4, 543, __pyx_L1_error)

  /* "View.MemoryView":544
 *         cdef _memoryviewslice result = memoryview_copy(self)
 *         transpose_memslice(&result.from_slice)
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "View.MemoryView":541
 * 
 *     @property
 *     def T(self):             # <<<<<<<<<<<<<<
 *         cdef _memoryviewslice result = memoryview_copy(self)
 *         transpose_memslice(&result.from_slice)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":547
 * 
 *     @property
 *     def base(self):             # <<<<<<<<<<<<<<
 *         return self.obj
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":548
 *     @property
 *     def base(self):
 *         return self.obj             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->obj);
  __pyx_r = __pyx_v_self->obj;
  goto __pyx_L0;

  /* "View.MemoryView":547
 * 
 *     @property
 *     def base(self):             # <<<<<<<<<<<<<<
 *         return self.obj
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":551
 * 
 *     @property
 *     def shape(self):             # <<<<<<<<<<<<<<
 *         return tuple([length for length in self.view.shape[:self.view.ndim]])
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  Py_ssize_t __pyx_v_length;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t *__pyx_t_2;
  Py_ssize_t *__pyx_t_3;
  Py_ssize_t *__pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":552
 *     @property
 *     def shape(self):
 *         return tuple([length for length in self.view.shape[:self.view.ndim]])             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
  for (__pyx_t_4 = __pyx_v_self->view.shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
    __pyx_t_2 = __pyx_t_4;
    __pyx_v_length = (__pyx_t_2[0]);
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 552, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(4, 552, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":551
 * 
 *     @property
 *     def shape(self):             # <<<<<<<<<<<<<<
 *         return tuple([length for length in self.view.shape[:self.view.ndim]])
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":555
 * 
 *     @property
 *     def strides(self):             # <<<<<<<<<<<<<<
 *         if self.view.strides == NULL:
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  Py_ssize_t __pyx_v_stride;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t *__pyx_t_3;
  Py_ssize_t *__pyx_t_4;
  Py_ssize_t *__pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":556
 *     @property
 *     def strides(self):
 *         if self.view.strides == NULL:             # <<<<<<<<<<<<<<
 * 
 *             raise ValueError("Buffer view does not expose strides")
 */
  __pyx_t_1 = ((__pyx_v_self->view.strides == NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":558
 *         if self.view.strides == NULL:
 * 
 *             raise ValueError("Buffer view does not expose strides")             # <<<<<<<<<<<<<<
 * 
 *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__211, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 558, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(4, 558, __pyx_L1_error)

    /* "View.MemoryView":556
 *     @property
 *     def strides(self):
 *         if self.view.strides == NULL:             # <<<<<<<<<<<<<<
 * 
 *             raise ValueError("Buffer view does not expose strides")
 */
  }

  /* "View.MemoryView":560
 *             raise ValueError("Buffer view does not expose strides")
 * 
 *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = (__pyx_v_self->view.strides + __pyx_v_self->view.ndim);
  for (__pyx_t_5 = __pyx_v_self->view.strides; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
    __pyx_t_3 = __pyx_t_5;
    __pyx_v_stride = (__pyx_t_3[0]);
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_stride); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 560, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(4, 560, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":555
 * 
 *     @property
 *     def strides(self):             # <<<<<<<<<<<<<<
 *         if self.view.strides == NULL:
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":563
 * 
 *     @property
 *     def suboffsets(self):             # <<<<<<<<<<<<<<
 *         if self.view.suboffsets == NULL:
 *             return (-1,) * self.view.ndim
 */

/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  Py_ssize_t __pyx_v_suboffset;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t *__pyx_t_4;
  Py_ssize_t *__pyx_t_5;
  Py_ssize_t *__pyx_t_6;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":564
 *     @property
 *     def suboffsets(self):
 *         if self.view.suboffsets == NULL:             # <<<<<<<<<<<<<<
 *             return (-1,) * self.view.ndim
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":565
 *     def suboffsets(self):
 *         if self.view.suboffsets == NULL:
 *             return (-1,) * self.view.ndim             # <<<<<<<<<<<<<<
 * 
 *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__212, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "View.MemoryView":564
 *     @property
 *     def suboffsets(self):
 *         if self.view.suboffsets == NULL:             # <<<<<<<<<<<<<<
 *             return (-1,) * self.view.ndim
 * 
 */
  }

  /* "View.MemoryView":567
 *             return (-1,) * self.view.ndim
 * 
 *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = (__pyx_v_self->view.suboffsets + __pyx_v_self->view.ndim);
  for (__pyx_t_6 = __pyx_v_self->view.suboffsets; __pyx_t_6 < __pyx_t_5; __pyx_t_6++) {
    __pyx_t_4 = __pyx_t_6;
    __pyx_v_suboffset = (__pyx_t_4[0]);
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_suboffset); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 567, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(4, 567, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":563
 * 
 *     @property
 *     def suboffsets(self):             # <<<<<<<<<<<<<<
 *         if self.view.suboffsets == NULL:
 *             return (-1,) * self.view.ndim
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":570
 * 
 *     @property
 *     def ndim(self):             # <<<<<<<<<<<<<<
 *         return self.view.ndim
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":571
 *     @property
 *     def ndim(self):
 *         return self.view.ndim             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 571, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":570
 * 
 *     @property
 *     def ndim(self):             # <<<<<<<<<<<<<<
 *         return self.view.ndim
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":574
 * 
 *     @property
 *     def itemsize(self):             # <<<<<<<<<<<<<<
 *         return self.view.itemsize
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":575
 *     @property
 *     def itemsize(self):
 *         return self.view.itemsize             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 575, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":574
 * 
 *     @property
 *     def itemsize(self):             # <<<<<<<<<<<<<<
 *         return self.view.itemsize
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":578
 * 
 *     @property
 *     def nbytes(self):             # <<<<<<<<<<<<<<
 *         return self.size * self.view.itemsize
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":579
 *     @property
 *     def nbytes(self):
 *         return self.size * self.view.itemsize             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 579, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 579, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 579, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":578
 * 
 *     @property
 *     def nbytes(self):             # <<<<<<<<<<<<<<
 *         return self.size * self.view.itemsize
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.memoryview.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":582
 * 
 *     @property
 *     def size(self):             # <<<<<<<<<<<<<<
 *         if self._size is None:
 *             result = 1
 */

/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_length = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  Py_ssize_t *__pyx_t_3;
  Py_ssize_t *__pyx_t_4;
  Py_ssize_t *__pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":583
 *     @property
 *     def size(self):
 *         if self._size is None:             # <<<<<<<<<<<<<<
 *             result = 1
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_size == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":584
 *     def size(self):
 *         if self._size is None:
 *             result = 1             # <<<<<<<<<<<<<<
 * 
 *             for length in self.view.shape[:self.view.ndim]:
 */
    __Pyx_INCREF(__pyx_int_1);
    __pyx_v_result = __pyx_int_1;

    /* "View.MemoryView":586
 *             result = 1
 * 
 *             for length in self.view.shape[:self.view.ndim]:             # <<<<<<<<<<<<<<
 *                 result *= length
 * 
 */
    __pyx_t_4 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
    for (__pyx_t_5 = __pyx_v_self->view.shape; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
      __pyx_t_3 = __pyx_t_5;
      __pyx_t_6 = PyInt_FromSsize_t((__pyx_t_3[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 586, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "View.MemoryView":587
 * 
 *             for length in self.view.shape[:self.view.ndim]:
 *                 result *= length             # <<<<<<<<<<<<<<
 * 
 *             self._size = result
 */
      __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 587, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6);
      __pyx_t_6 = 0;
    }

    /* "View.MemoryView":589
 *                 result *= length
 * 
 *             self._size = result             # <<<<<<<<<<<<<<
 * 
 *         return self._size
 */
    __Pyx_INCREF(__pyx_v_result);
    __Pyx_GIVEREF(__pyx_v_result);
    __Pyx_GOTREF(__pyx_v_self->_size);
    __Pyx_DECREF(__pyx_v_self->_size);
    __pyx_v_self->_size = __pyx_v_result;

    /* "View.MemoryView":583
 *     @property
 *     def size(self):
 *         if self._size is None:             # <<<<<<<<<<<<<<
 *             result = 1
 * 
 */
  }

  /* "View.MemoryView":591
 *             self._size = result
 * 
 *         return self._size             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_size);
  __pyx_r = __pyx_v_self->_size;
  goto __pyx_L0;

  /* "View.MemoryView":582
 * 
 *     @property
 *     def size(self):             # <<<<<<<<<<<<<<
 *         if self._size is None:
 *             result = 1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_length);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":593
 *         return self._size
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         if self.view.ndim >= 1:
 *             return self.view.shape[0]
 */

/* Python wrapper */
static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "View.MemoryView":594
 * 
 *     def __len__(self):
 *         if self.view.ndim >= 1:             # <<<<<<<<<<<<<<
 *             return self.view.shape[0]
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->view.ndim >= 1) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":595
 *     def __len__(self):
 *         if self.view.ndim >= 1:
 *             return self.view.shape[0]             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
    __pyx_r = (__pyx_v_self->view.shape[0]);
    goto __pyx_L0;

    /* "View.MemoryView":594
 * 
 *     def __len__(self):
 *         if self.view.ndim >= 1:             # <<<<<<<<<<<<<<
 *             return self.view.shape[0]
 * 
 */
  }

  /* "View.MemoryView":597
 *             return self.view.shape[0]
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "View.MemoryView":593
 *         return self._size
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         if self.view.ndim >= 1:
 *             return self.view.shape[0]
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":599
 *         return 0
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
 *                                                id(self))
 */

/* Python wrapper */
static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "View.MemoryView":600
 * 
 *     def __repr__(self):
 *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
 *                                                id(self))
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 600, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 600, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 600, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "View.MemoryView":601
 *     def __repr__(self):
 *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
 *                                                id(self))             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 601, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 601, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "View.MemoryView":600
 * 
 *     def __repr__(self):
 *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
 *                                                id(self))
 * 
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 600, __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_t_3 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 600, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":599
 *         return 0
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
 *                                                id(self))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.memoryview.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":603
 *                                                id(self))
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "View.MemoryView":604
 * 
 *     def __str__(self):
 *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 604, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 604, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 604, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 604, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_object, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 604, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":603
 *                                                id(self))
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.memoryview.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":607
 * 
 * 
 *     def is_c_contig(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
  __Pyx_memviewslice *__pyx_v_mslice;
  __Pyx_memviewslice __pyx_v_tmp;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("is_c_contig", 0);

  /* "View.MemoryView":610
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 *         mslice = get_slice_from_memview(self, &tmp)             # <<<<<<<<<<<<<<
 *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
 * 
 */
  __pyx_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp));

  /* "View.MemoryView":611
 *         cdef __Pyx_memviewslice tmp
 *         mslice = get_slice_from_memview(self, &tmp)
 *         return slice_is_contig(mslice[0], 'C', self.view.ndim)             # <<<<<<<<<<<<<<
 * 
 *     def is_f_contig(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'C', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 611, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":607
 * 
 * 
 *     def is_c_contig(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.is_c_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":613
 *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
 * 
 *     def is_f_contig(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
  __Pyx_memviewslice *__pyx_v_mslice;
  __Pyx_memviewslice __pyx_v_tmp;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("is_f_contig", 0);

  /* "View.MemoryView":616
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 *         mslice = get_slice_from_memview(self, &tmp)             # <<<<<<<<<<<<<<
 *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
 * 
 */
  __pyx_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp));

  /* "View.MemoryView":617
 *         cdef __Pyx_memviewslice tmp
 *         mslice = get_slice_from_memview(self, &tmp)
 *         return slice_is_contig(mslice[0], 'F', self.view.ndim)             # <<<<<<<<<<<<<<
 * 
 *     def copy(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'F', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 617, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":613
 *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
 * 
 *     def is_f_contig(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.is_f_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":619
 *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice mslice
 *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) {
  __Pyx_memviewslice __pyx_v_mslice;
  int __pyx_v_flags;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_memviewslice __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("copy", 0);

  /* "View.MemoryView":621
 *     def copy(self):
 *         cdef __Pyx_memviewslice mslice
 *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS             # <<<<<<<<<<<<<<
 * 
 *         slice_copy(self, &mslice)
 */
  __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_F_CONTIGUOUS));

  /* "View.MemoryView":623
 *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
 * 
 *         slice_copy(self, &mslice)             # <<<<<<<<<<<<<<
 *         mslice = slice_copy_contig(&mslice, "c", self.view.ndim,
 *                                    self.view.itemsize,
 */
  __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_mslice));

  /* "View.MemoryView":624
 * 
 *         slice_copy(self, &mslice)
 *         mslice = slice_copy_contig(&mslice, "c", self.view.ndim,             # <<<<<<<<<<<<<<
 *                                    self.view.itemsize,
 *                                    flags|PyBUF_C_CONTIGUOUS,
 */
  __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_mslice), ((char *)"c"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_C_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(4, 624, __pyx_L1_error)
  __pyx_v_mslice = __pyx_t_1;

  /* "View.MemoryView":629
 *                                    self.dtype_is_object)
 * 
 *         return memoryview_copy_from_slice(self, &mslice)             # <<<<<<<<<<<<<<
 * 
 *     def copy_fortran(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_mslice)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":619
 *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice mslice
 *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.memoryview.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":631
 *         return memoryview_copy_from_slice(self, &mslice)
 * 
 *     def copy_fortran(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice src, dst
 *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) {
  __Pyx_memviewslice __pyx_v_src;
  __Pyx_memviewslice __pyx_v_dst;
  int __pyx_v_flags;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_memviewslice __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("copy_fortran", 0);

  /* "View.MemoryView":633
 *     def copy_fortran(self):
 *         cdef __Pyx_memviewslice src, dst
 *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS             # <<<<<<<<<<<<<<
 * 
 *         slice_copy(self, &src)
 */
  __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_C_CONTIGUOUS));

  /* "View.MemoryView":635
 *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
 * 
 *         slice_copy(self, &src)             # <<<<<<<<<<<<<<
 *         dst = slice_copy_contig(&src, "fortran", self.view.ndim,
 *                                 self.view.itemsize,
 */
  __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_src));

  /* "View.MemoryView":636
 * 
 *         slice_copy(self, &src)
 *         dst = slice_copy_contig(&src, "fortran", self.view.ndim,             # <<<<<<<<<<<<<<
 *                                 self.view.itemsize,
 *                                 flags|PyBUF_F_CONTIGUOUS,
 */
  __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_src), ((char *)"fortran"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_F_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(4, 636, __pyx_L1_error)
  __pyx_v_dst = __pyx_t_1;

  /* "View.MemoryView":641
 *                                 self.dtype_is_object)
 * 
 *         return memoryview_copy_from_slice(self, &dst)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_dst)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 641, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":631
 *         return memoryview_copy_from_slice(self, &mslice)
 * 
 *     def copy_fortran(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice src, dst
 *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.memoryview.copy_fortran", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf___pyx_memoryview___reduce_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__213, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(4, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf___pyx_memoryview_2__setstate_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__214, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(4, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":645
 * 
 * @cname('__pyx_memoryview_new')
 * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):             # <<<<<<<<<<<<<<
 *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
 *     result.typeinfo = typeinfo
 */

static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_flags, int __pyx_v_dtype_is_object, __Pyx_TypeInfo *__pyx_v_typeinfo) {
  struct __pyx_memoryview_obj *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("memoryview_cwrapper", 0);

  /* "View.MemoryView":646
 * @cname('__pyx_memoryview_new')
 * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
 *     cdef memoryview result = memoryview(o, flags, dtype_is_object)             # <<<<<<<<<<<<<<
 *     result.typeinfo = typeinfo
 *     return result
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_o);
  __Pyx_GIVEREF(__pyx_v_o);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_result = ((struct __pyx_memoryview_obj *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "View.MemoryView":647
 * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
 *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
 *     result.typeinfo = typeinfo             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  __pyx_v_result->typeinfo = __pyx_v_typeinfo;

  /* "View.MemoryView":648
 *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
 *     result.typeinfo = typeinfo
 *     return result             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_check')
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "View.MemoryView":645
 * 
 * @cname('__pyx_memoryview_new')
 * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):             # <<<<<<<<<<<<<<
 *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
 *     result.typeinfo = typeinfo
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.memoryview_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":651
 * 
 * @cname('__pyx_memoryview_check')
 * cdef inline bint memoryview_check(object o):             # <<<<<<<<<<<<<<
 *     return isinstance(o, memoryview)
 * 
 */

static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("memoryview_check", 0);

  /* "View.MemoryView":652
 * @cname('__pyx_memoryview_check')
 * cdef inline bint memoryview_check(object o):
 *     return isinstance(o, memoryview)             # <<<<<<<<<<<<<<
 * 
 * cdef tuple _unellipsify(object index, int ndim):
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, __pyx_memoryview_type); 
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* "View.MemoryView":651
 * 
 * @cname('__pyx_memoryview_check')
 * cdef inline bint memoryview_check(object o):             # <<<<<<<<<<<<<<
 *     return isinstance(o, memoryview)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":654
 *     return isinstance(o, memoryview)
 * 
 * cdef tuple _unellipsify(object index, int ndim):             # <<<<<<<<<<<<<<
 *     """
 *     Replace all ellipses with full slices and fill incomplete indices with
 */

static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) {
  PyObject *__pyx_v_tup = NULL;
  PyObject *__pyx_v_result = NULL;
  int __pyx_v_have_slices;
  int __pyx_v_seen_ellipsis;
  CYTHON_UNUSED PyObject *__pyx_v_idx = NULL;
  PyObject *__pyx_v_item = NULL;
  Py_ssize_t __pyx_v_nslices;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("_unellipsify", 0);

  /* "View.MemoryView":659
 *     full slices.
 *     """
 *     if not isinstance(index, tuple):             # <<<<<<<<<<<<<<
 *         tup = (index,)
 *     else:
 */
  __pyx_t_1 = PyTuple_Check(__pyx_v_index); 
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":660
 *     """
 *     if not isinstance(index, tuple):
 *         tup = (index,)             # <<<<<<<<<<<<<<
 *     else:
 *         tup = index
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 660, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_index);
    __Pyx_GIVEREF(__pyx_v_index);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index);
    __pyx_v_tup = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "View.MemoryView":659
 *     full slices.
 *     """
 *     if not isinstance(index, tuple):             # <<<<<<<<<<<<<<
 *         tup = (index,)
 *     else:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":662
 *         tup = (index,)
 *     else:
 *         tup = index             # <<<<<<<<<<<<<<
 * 
 *     result = []
 */
  /*else*/ {
    __Pyx_INCREF(__pyx_v_index);
    __pyx_v_tup = __pyx_v_index;
  }
  __pyx_L3:;

  /* "View.MemoryView":664
 *         tup = index
 * 
 *     result = []             # <<<<<<<<<<<<<<
 *     have_slices = False
 *     seen_ellipsis = False
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 664, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_result = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "View.MemoryView":665
 * 
 *     result = []
 *     have_slices = False             # <<<<<<<<<<<<<<
 *     seen_ellipsis = False
 *     for idx, item in enumerate(tup):
 */
  __pyx_v_have_slices = 0;

  /* "View.MemoryView":666
 *     result = []
 *     have_slices = False
 *     seen_ellipsis = False             # <<<<<<<<<<<<<<
 *     for idx, item in enumerate(tup):
 *         if item is Ellipsis:
 */
  __pyx_v_seen_ellipsis = 0;

  /* "View.MemoryView":667
 *     have_slices = False
 *     seen_ellipsis = False
 *     for idx, item in enumerate(tup):             # <<<<<<<<<<<<<<
 *         if item is Ellipsis:
 *             if not seen_ellipsis:
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_3 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
    __pyx_t_4 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 667, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 667, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(4, 667, __pyx_L1_error)
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 667, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(4, 667, __pyx_L1_error)
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 667, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      }
    } else {
      __pyx_t_7 = __pyx_t_6(__pyx_t_4);
      if (unlikely(!__pyx_t_7)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(4, 667, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_7);
    }
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3);
    __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 667, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_3 = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "View.MemoryView":668
 *     seen_ellipsis = False
 *     for idx, item in enumerate(tup):
 *         if item is Ellipsis:             # <<<<<<<<<<<<<<
 *             if not seen_ellipsis:
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
 */
    __pyx_t_2 = (__pyx_v_item == __pyx_builtin_Ellipsis);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":669
 *     for idx, item in enumerate(tup):
 *         if item is Ellipsis:
 *             if not seen_ellipsis:             # <<<<<<<<<<<<<<
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
 *                 seen_ellipsis = True
 */
      __pyx_t_1 = ((!(__pyx_v_seen_ellipsis != 0)) != 0);
      if (__pyx_t_1) {

        /* "View.MemoryView":670
 *         if item is Ellipsis:
 *             if not seen_ellipsis:
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
 *                 seen_ellipsis = True
 *             else:
 */
        __pyx_t_8 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(4, 670, __pyx_L1_error)
        __pyx_t_7 = PyList_New(1 * ((((__pyx_v_ndim - __pyx_t_8) + 1)<0) ? 0:((__pyx_v_ndim - __pyx_t_8) + 1))); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 670, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        { Py_ssize_t __pyx_temp;
          for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) {
            __Pyx_INCREF(__pyx_slice__215);
            __Pyx_GIVEREF(__pyx_slice__215);
            PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__215);
          }
        }
        __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(4, 670, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "View.MemoryView":671
 *             if not seen_ellipsis:
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
 *                 seen_ellipsis = True             # <<<<<<<<<<<<<<
 *             else:
 *                 result.append(slice(None))
 */
        __pyx_v_seen_ellipsis = 1;

        /* "View.MemoryView":669
 *     for idx, item in enumerate(tup):
 *         if item is Ellipsis:
 *             if not seen_ellipsis:             # <<<<<<<<<<<<<<
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
 *                 seen_ellipsis = True
 */
        goto __pyx_L7;
      }

      /* "View.MemoryView":673
 *                 seen_ellipsis = True
 *             else:
 *                 result.append(slice(None))             # <<<<<<<<<<<<<<
 *             have_slices = True
 *         else:
 */
      /*else*/ {
        __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__216); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(4, 673, __pyx_L1_error)
      }
      __pyx_L7:;

      /* "View.MemoryView":674
 *             else:
 *                 result.append(slice(None))
 *             have_slices = True             # <<<<<<<<<<<<<<
 *         else:
 *             if not isinstance(item, slice) and not PyIndex_Check(item):
 */
      __pyx_v_have_slices = 1;

      /* "View.MemoryView":668
 *     seen_ellipsis = False
 *     for idx, item in enumerate(tup):
 *         if item is Ellipsis:             # <<<<<<<<<<<<<<
 *             if not seen_ellipsis:
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
 */
      goto __pyx_L6;
    }

    /* "View.MemoryView":676
 *             have_slices = True
 *         else:
 *             if not isinstance(item, slice) and not PyIndex_Check(item):             # <<<<<<<<<<<<<<
 *                 raise TypeError("Cannot index with type '%s'" % type(item))
 * 
 */
    /*else*/ {
      __pyx_t_2 = PySlice_Check(__pyx_v_item); 
      __pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0);
      if (__pyx_t_10) {
      } else {
        __pyx_t_1 = __pyx_t_10;
        goto __pyx_L9_bool_binop_done;
      }
      __pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0);
      __pyx_t_1 = __pyx_t_10;
      __pyx_L9_bool_binop_done:;
      if (__pyx_t_1) {

        /* "View.MemoryView":677
 *         else:
 *             if not isinstance(item, slice) and not PyIndex_Check(item):
 *                 raise TypeError("Cannot index with type '%s'" % type(item))             # <<<<<<<<<<<<<<
 * 
 *             have_slices = have_slices or isinstance(item, slice)
 */
        __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Cannot_index_with_type_s, ((PyObject *)Py_TYPE(__pyx_v_item))); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 677, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(4, 677, __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 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 677, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_Raise(__pyx_t_7, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __PYX_ERR(4, 677, __pyx_L1_error)

        /* "View.MemoryView":676
 *             have_slices = True
 *         else:
 *             if not isinstance(item, slice) and not PyIndex_Check(item):             # <<<<<<<<<<<<<<
 *                 raise TypeError("Cannot index with type '%s'" % type(item))
 * 
 */
      }

      /* "View.MemoryView":679
 *                 raise TypeError("Cannot index with type '%s'" % type(item))
 * 
 *             have_slices = have_slices or isinstance(item, slice)             # <<<<<<<<<<<<<<
 *             result.append(item)
 * 
 */
      __pyx_t_10 = (__pyx_v_have_slices != 0);
      if (!__pyx_t_10) {
      } else {
        __pyx_t_1 = __pyx_t_10;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_10 = PySlice_Check(__pyx_v_item); 
      __pyx_t_2 = (__pyx_t_10 != 0);
      __pyx_t_1 = __pyx_t_2;
      __pyx_L11_bool_binop_done:;
      __pyx_v_have_slices = __pyx_t_1;

      /* "View.MemoryView":680
 * 
 *             have_slices = have_slices or isinstance(item, slice)
 *             result.append(item)             # <<<<<<<<<<<<<<
 * 
 *     nslices = ndim - len(result)
 */
      __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(4, 680, __pyx_L1_error)
    }
    __pyx_L6:;

    /* "View.MemoryView":667
 *     have_slices = False
 *     seen_ellipsis = False
 *     for idx, item in enumerate(tup):             # <<<<<<<<<<<<<<
 *         if item is Ellipsis:
 *             if not seen_ellipsis:
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "View.MemoryView":682
 *             result.append(item)
 * 
 *     nslices = ndim - len(result)             # <<<<<<<<<<<<<<
 *     if nslices:
 *         result.extend([slice(None)] * nslices)
 */
  __pyx_t_5 = PyList_GET_SIZE(__pyx_v_result); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(4, 682, __pyx_L1_error)
  __pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5);

  /* "View.MemoryView":683
 * 
 *     nslices = ndim - len(result)
 *     if nslices:             # <<<<<<<<<<<<<<
 *         result.extend([slice(None)] * nslices)
 * 
 */
  __pyx_t_1 = (__pyx_v_nslices != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":684
 *     nslices = ndim - len(result)
 *     if nslices:
 *         result.extend([slice(None)] * nslices)             # <<<<<<<<<<<<<<
 * 
 *     return have_slices or nslices, tuple(result)
 */
    __pyx_t_3 = PyList_New(1 * ((__pyx_v_nslices<0) ? 0:__pyx_v_nslices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 684, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    { Py_ssize_t __pyx_temp;
      for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) {
        __Pyx_INCREF(__pyx_slice__217);
        __Pyx_GIVEREF(__pyx_slice__217);
        PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__217);
      }
    }
    __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(4, 684, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "View.MemoryView":683
 * 
 *     nslices = ndim - len(result)
 *     if nslices:             # <<<<<<<<<<<<<<
 *         result.extend([slice(None)] * nslices)
 * 
 */
  }

  /* "View.MemoryView":686
 *         result.extend([slice(None)] * nslices)
 * 
 *     return have_slices or nslices, tuple(result)             # <<<<<<<<<<<<<<
 * 
 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
 */
  __Pyx_XDECREF(__pyx_r);
  if (!__pyx_v_have_slices) {
  } else {
    __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 686, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L14_bool_binop_done;
  }
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_L14_bool_binop_done:;
  __pyx_t_4 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_r = ((PyObject*)__pyx_t_7);
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":654
 *     return isinstance(o, memoryview)
 * 
 * cdef tuple _unellipsify(object index, int ndim):             # <<<<<<<<<<<<<<
 *     """
 *     Replace all ellipses with full slices and fill incomplete indices with
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("View.MemoryView._unellipsify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_tup);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_idx);
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":688
 *     return have_slices or nslices, tuple(result)
 * 
 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):             # <<<<<<<<<<<<<<
 *     for suboffset in suboffsets[:ndim]:
 *         if suboffset >= 0:
 */

static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) {
  Py_ssize_t __pyx_v_suboffset;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t *__pyx_t_1;
  Py_ssize_t *__pyx_t_2;
  Py_ssize_t *__pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("assert_direct_dimensions", 0);

  /* "View.MemoryView":689
 * 
 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
 *     for suboffset in suboffsets[:ndim]:             # <<<<<<<<<<<<<<
 *         if suboffset >= 0:
 *             raise ValueError("Indirect dimensions not supported")
 */
  __pyx_t_2 = (__pyx_v_suboffsets + __pyx_v_ndim);
  for (__pyx_t_3 = __pyx_v_suboffsets; __pyx_t_3 < __pyx_t_2; __pyx_t_3++) {
    __pyx_t_1 = __pyx_t_3;
    __pyx_v_suboffset = (__pyx_t_1[0]);

    /* "View.MemoryView":690
 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
 *     for suboffset in suboffsets[:ndim]:
 *         if suboffset >= 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("Indirect dimensions not supported")
 * 
 */
    __pyx_t_4 = ((__pyx_v_suboffset >= 0) != 0);
    if (__pyx_t_4) {

      /* "View.MemoryView":691
 *     for suboffset in suboffsets[:ndim]:
 *         if suboffset >= 0:
 *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__218, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 691, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(4, 691, __pyx_L1_error)

      /* "View.MemoryView":690
 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
 *     for suboffset in suboffsets[:ndim]:
 *         if suboffset >= 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("Indirect dimensions not supported")
 * 
 */
    }
  }

  /* "View.MemoryView":688
 *     return have_slices or nslices, tuple(result)
 * 
 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):             # <<<<<<<<<<<<<<
 *     for suboffset in suboffsets[:ndim]:
 *         if suboffset >= 0:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":698
 * 
 * @cname('__pyx_memview_slice')
 * cdef memoryview memview_slice(memoryview memview, object indices):             # <<<<<<<<<<<<<<
 *     cdef int new_ndim = 0, suboffset_dim = -1, dim
 *     cdef bint negative_step
 */

static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *__pyx_v_memview, PyObject *__pyx_v_indices) {
  int __pyx_v_new_ndim;
  int __pyx_v_suboffset_dim;
  int __pyx_v_dim;
  __Pyx_memviewslice __pyx_v_src;
  __Pyx_memviewslice __pyx_v_dst;
  __Pyx_memviewslice *__pyx_v_p_src;
  struct __pyx_memoryviewslice_obj *__pyx_v_memviewsliceobj = 0;
  __Pyx_memviewslice *__pyx_v_p_dst;
  int *__pyx_v_p_suboffset_dim;
  Py_ssize_t __pyx_v_start;
  Py_ssize_t __pyx_v_stop;
  Py_ssize_t __pyx_v_step;
  int __pyx_v_have_start;
  int __pyx_v_have_stop;
  int __pyx_v_have_step;
  PyObject *__pyx_v_index = NULL;
  struct __pyx_memoryview_obj *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  struct __pyx_memoryview_obj *__pyx_t_4;
  char *__pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  int __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  __Pyx_RefNannySetupContext("memview_slice", 0);

  /* "View.MemoryView":699
 * @cname('__pyx_memview_slice')
 * cdef memoryview memview_slice(memoryview memview, object indices):
 *     cdef int new_ndim = 0, suboffset_dim = -1, dim             # <<<<<<<<<<<<<<
 *     cdef bint negative_step
 *     cdef __Pyx_memviewslice src, dst
 */
  __pyx_v_new_ndim = 0;
  __pyx_v_suboffset_dim = -1;

  /* "View.MemoryView":706
 * 
 * 
 *     memset(&dst, 0, sizeof(dst))             # <<<<<<<<<<<<<<
 * 
 *     cdef _memoryviewslice memviewsliceobj
 */
  memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst)));

  /* "View.MemoryView":710
 *     cdef _memoryviewslice memviewsliceobj
 * 
 *     assert memview.view.ndim > 0             # <<<<<<<<<<<<<<
 * 
 *     if isinstance(memview, _memoryviewslice):
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(4, 710, __pyx_L1_error)
    }
  }
  #endif

  /* "View.MemoryView":712
 *     assert memview.view.ndim > 0
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         memviewsliceobj = memview
 *         p_src = &memviewsliceobj.from_slice
 */
  __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":713
 * 
 *     if isinstance(memview, _memoryviewslice):
 *         memviewsliceobj = memview             # <<<<<<<<<<<<<<
 *         p_src = &memviewsliceobj.from_slice
 *     else:
 */
    if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(4, 713, __pyx_L1_error)
    __pyx_t_3 = ((PyObject *)__pyx_v_memview);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "View.MemoryView":714
 *     if isinstance(memview, _memoryviewslice):
 *         memviewsliceobj = memview
 *         p_src = &memviewsliceobj.from_slice             # <<<<<<<<<<<<<<
 *     else:
 *         slice_copy(memview, &src)
 */
    __pyx_v_p_src = (&__pyx_v_memviewsliceobj->from_slice);

    /* "View.MemoryView":712
 *     assert memview.view.ndim > 0
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         memviewsliceobj = memview
 *         p_src = &memviewsliceobj.from_slice
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":716
 *         p_src = &memviewsliceobj.from_slice
 *     else:
 *         slice_copy(memview, &src)             # <<<<<<<<<<<<<<
 *         p_src = &src
 * 
 */
  /*else*/ {
    __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src));

    /* "View.MemoryView":717
 *     else:
 *         slice_copy(memview, &src)
 *         p_src = &src             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_v_p_src = (&__pyx_v_src);
  }
  __pyx_L3:;

  /* "View.MemoryView":723
 * 
 * 
 *     dst.memview = p_src.memview             # <<<<<<<<<<<<<<
 *     dst.data = p_src.data
 * 
 */
  __pyx_t_4 = __pyx_v_p_src->memview;
  __pyx_v_dst.memview = __pyx_t_4;

  /* "View.MemoryView":724
 * 
 *     dst.memview = p_src.memview
 *     dst.data = p_src.data             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __pyx_v_p_src->data;
  __pyx_v_dst.data = __pyx_t_5;

  /* "View.MemoryView":729
 * 
 * 
 *     cdef __Pyx_memviewslice *p_dst = &dst             # <<<<<<<<<<<<<<
 *     cdef int *p_suboffset_dim = &suboffset_dim
 *     cdef Py_ssize_t start, stop, step
 */
  __pyx_v_p_dst = (&__pyx_v_dst);

  /* "View.MemoryView":730
 * 
 *     cdef __Pyx_memviewslice *p_dst = &dst
 *     cdef int *p_suboffset_dim = &suboffset_dim             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t start, stop, step
 *     cdef bint have_start, have_stop, have_step
 */
  __pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim);

  /* "View.MemoryView":734
 *     cdef bint have_start, have_stop, have_step
 * 
 *     for dim, index in enumerate(indices):             # <<<<<<<<<<<<<<
 *         if PyIndex_Check(index):
 *             slice_memviewslice(
 */
  __pyx_t_6 = 0;
  if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) {
    __pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 734, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 734, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(4, 734, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 734, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(4, 734, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 734, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      }
    } else {
      __pyx_t_9 = __pyx_t_8(__pyx_t_3);
      if (unlikely(!__pyx_t_9)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(4, 734, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_9);
    }
    __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_v_dim = __pyx_t_6;
    __pyx_t_6 = (__pyx_t_6 + 1);

    /* "View.MemoryView":735
 * 
 *     for dim, index in enumerate(indices):
 *         if PyIndex_Check(index):             # <<<<<<<<<<<<<<
 *             slice_memviewslice(
 *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
 */
    __pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":739
 *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
 *                 dim, new_ndim, p_suboffset_dim,
 *                 index, 0, 0, # start, stop, step             # <<<<<<<<<<<<<<
 *                 0, 0, 0, # have_{start,stop,step}
 *                 False)
 */
      __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 739, __pyx_L1_error)

      /* "View.MemoryView":736
 *     for dim, index in enumerate(indices):
 *         if PyIndex_Check(index):
 *             slice_memviewslice(             # <<<<<<<<<<<<<<
 *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
 *                 dim, new_ndim, p_suboffset_dim,
 */
      __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_t_10, 0, 0, 0, 0, 0, 0); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(4, 736, __pyx_L1_error)

      /* "View.MemoryView":735
 * 
 *     for dim, index in enumerate(indices):
 *         if PyIndex_Check(index):             # <<<<<<<<<<<<<<
 *             slice_memviewslice(
 *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
 */
      goto __pyx_L6;
    }

    /* "View.MemoryView":742
 *                 0, 0, 0, # have_{start,stop,step}
 *                 False)
 *         elif index is None:             # <<<<<<<<<<<<<<
 *             p_dst.shape[new_ndim] = 1
 *             p_dst.strides[new_ndim] = 0
 */
    __pyx_t_2 = (__pyx_v_index == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":743
 *                 False)
 *         elif index is None:
 *             p_dst.shape[new_ndim] = 1             # <<<<<<<<<<<<<<
 *             p_dst.strides[new_ndim] = 0
 *             p_dst.suboffsets[new_ndim] = -1
 */
      (__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1;

      /* "View.MemoryView":744
 *         elif index is None:
 *             p_dst.shape[new_ndim] = 1
 *             p_dst.strides[new_ndim] = 0             # <<<<<<<<<<<<<<
 *             p_dst.suboffsets[new_ndim] = -1
 *             new_ndim += 1
 */
      (__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0;

      /* "View.MemoryView":745
 *             p_dst.shape[new_ndim] = 1
 *             p_dst.strides[new_ndim] = 0
 *             p_dst.suboffsets[new_ndim] = -1             # <<<<<<<<<<<<<<
 *             new_ndim += 1
 *         else:
 */
      (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1L;

      /* "View.MemoryView":746
 *             p_dst.strides[new_ndim] = 0
 *             p_dst.suboffsets[new_ndim] = -1
 *             new_ndim += 1             # <<<<<<<<<<<<<<
 *         else:
 *             start = index.start or 0
 */
      __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);

      /* "View.MemoryView":742
 *                 0, 0, 0, # have_{start,stop,step}
 *                 False)
 *         elif index is None:             # <<<<<<<<<<<<<<
 *             p_dst.shape[new_ndim] = 1
 *             p_dst.strides[new_ndim] = 0
 */
      goto __pyx_L6;
    }

    /* "View.MemoryView":748
 *             new_ndim += 1
 *         else:
 *             start = index.start or 0             # <<<<<<<<<<<<<<
 *             stop = index.stop or 0
 *             step = index.step or 0
 */
    /*else*/ {
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 748, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(4, 748, __pyx_L1_error)
      if (!__pyx_t_1) {
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 748, __pyx_L1_error)
        __pyx_t_10 = __pyx_t_12;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_10 = 0;
      __pyx_L7_bool_binop_done:;
      __pyx_v_start = __pyx_t_10;

      /* "View.MemoryView":749
 *         else:
 *             start = index.start or 0
 *             stop = index.stop or 0             # <<<<<<<<<<<<<<
 *             step = index.step or 0
 * 
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 749, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(4, 749, __pyx_L1_error)
      if (!__pyx_t_1) {
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 749, __pyx_L1_error)
        __pyx_t_10 = __pyx_t_12;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L9_bool_binop_done;
      }
      __pyx_t_10 = 0;
      __pyx_L9_bool_binop_done:;
      __pyx_v_stop = __pyx_t_10;

      /* "View.MemoryView":750
 *             start = index.start or 0
 *             stop = index.stop or 0
 *             step = index.step or 0             # <<<<<<<<<<<<<<
 * 
 *             have_start = index.start is not None
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 750, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(4, 750, __pyx_L1_error)
      if (!__pyx_t_1) {
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 750, __pyx_L1_error)
        __pyx_t_10 = __pyx_t_12;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_10 = 0;
      __pyx_L11_bool_binop_done:;
      __pyx_v_step = __pyx_t_10;

      /* "View.MemoryView":752
 *             step = index.step or 0
 * 
 *             have_start = index.start is not None             # <<<<<<<<<<<<<<
 *             have_stop = index.stop is not None
 *             have_step = index.step is not None
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 752, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = (__pyx_t_9 != Py_None);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_have_start = __pyx_t_1;

      /* "View.MemoryView":753
 * 
 *             have_start = index.start is not None
 *             have_stop = index.stop is not None             # <<<<<<<<<<<<<<
 *             have_step = index.step is not None
 * 
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 753, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = (__pyx_t_9 != Py_None);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_have_stop = __pyx_t_1;

      /* "View.MemoryView":754
 *             have_start = index.start is not None
 *             have_stop = index.stop is not None
 *             have_step = index.step is not None             # <<<<<<<<<<<<<<
 * 
 *             slice_memviewslice(
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 754, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = (__pyx_t_9 != Py_None);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_have_step = __pyx_t_1;

      /* "View.MemoryView":756
 *             have_step = index.step is not None
 * 
 *             slice_memviewslice(             # <<<<<<<<<<<<<<
 *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
 *                 dim, new_ndim, p_suboffset_dim,
 */
      __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_v_start, __pyx_v_stop, __pyx_v_step, __pyx_v_have_start, __pyx_v_have_stop, __pyx_v_have_step, 1); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(4, 756, __pyx_L1_error)

      /* "View.MemoryView":762
 *                 have_start, have_stop, have_step,
 *                 True)
 *             new_ndim += 1             # <<<<<<<<<<<<<<
 * 
 *     if isinstance(memview, _memoryviewslice):
 */
      __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
    }
    __pyx_L6:;

    /* "View.MemoryView":734
 *     cdef bint have_start, have_stop, have_step
 * 
 *     for dim, index in enumerate(indices):             # <<<<<<<<<<<<<<
 *         if PyIndex_Check(index):
 *             slice_memviewslice(
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "View.MemoryView":764
 *             new_ndim += 1
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         return memoryview_fromslice(dst, new_ndim,
 *                                     memviewsliceobj.to_object_func,
 */
  __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":765
 * 
 *     if isinstance(memview, _memoryviewslice):
 *         return memoryview_fromslice(dst, new_ndim,             # <<<<<<<<<<<<<<
 *                                     memviewsliceobj.to_object_func,
 *                                     memviewsliceobj.to_dtype_func,
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));

    /* "View.MemoryView":766
 *     if isinstance(memview, _memoryviewslice):
 *         return memoryview_fromslice(dst, new_ndim,
 *                                     memviewsliceobj.to_object_func,             # <<<<<<<<<<<<<<
 *                                     memviewsliceobj.to_dtype_func,
 *                                     memview.dtype_is_object)
 */
    if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(4, 766, __pyx_L1_error) }

    /* "View.MemoryView":767
 *         return memoryview_fromslice(dst, new_ndim,
 *                                     memviewsliceobj.to_object_func,
 *                                     memviewsliceobj.to_dtype_func,             # <<<<<<<<<<<<<<
 *                                     memview.dtype_is_object)
 *     else:
 */
    if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(4, 767, __pyx_L1_error) }

    /* "View.MemoryView":765
 * 
 *     if isinstance(memview, _memoryviewslice):
 *         return memoryview_fromslice(dst, new_ndim,             # <<<<<<<<<<<<<<
 *                                     memviewsliceobj.to_object_func,
 *                                     memviewsliceobj.to_dtype_func,
 */
    __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, __pyx_v_memviewsliceobj->to_object_func, __pyx_v_memviewsliceobj->to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 765, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(4, 765, __pyx_L1_error)
    __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "View.MemoryView":764
 *             new_ndim += 1
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         return memoryview_fromslice(dst, new_ndim,
 *                                     memviewsliceobj.to_object_func,
 */
  }

  /* "View.MemoryView":770
 *                                     memview.dtype_is_object)
 *     else:
 *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,             # <<<<<<<<<<<<<<
 *                                     memview.dtype_is_object)
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));

    /* "View.MemoryView":771
 *     else:
 *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,
 *                                     memview.dtype_is_object)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, NULL, NULL, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 770, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "View.MemoryView":770
 *                                     memview.dtype_is_object)
 *     else:
 *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,             # <<<<<<<<<<<<<<
 *                                     memview.dtype_is_object)
 * 
 */
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(4, 770, __pyx_L1_error)
    __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "View.MemoryView":698
 * 
 * @cname('__pyx_memview_slice')
 * cdef memoryview memview_slice(memoryview memview, object indices):             # <<<<<<<<<<<<<<
 *     cdef int new_ndim = 0, suboffset_dim = -1, dim
 *     cdef bint negative_step
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("View.MemoryView.memview_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_memviewsliceobj);
  __Pyx_XDECREF(__pyx_v_index);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":795
 * 
 * @cname('__pyx_memoryview_slice_memviewslice')
 * cdef int slice_memviewslice(             # <<<<<<<<<<<<<<
 *         __Pyx_memviewslice *dst,
 *         Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
 */

static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, Py_ssize_t __pyx_v_shape, Py_ssize_t __pyx_v_stride, Py_ssize_t __pyx_v_suboffset, int __pyx_v_dim, int __pyx_v_new_ndim, int *__pyx_v_suboffset_dim, Py_ssize_t __pyx_v_start, Py_ssize_t __pyx_v_stop, Py_ssize_t __pyx_v_step, int __pyx_v_have_start, int __pyx_v_have_stop, int __pyx_v_have_step, int __pyx_v_is_slice) {
  Py_ssize_t __pyx_v_new_shape;
  int __pyx_v_negative_step;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;

  /* "View.MemoryView":815
 *     cdef bint negative_step
 * 
 *     if not is_slice:             # <<<<<<<<<<<<<<
 * 
 *         if start < 0:
 */
  __pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":817
 *     if not is_slice:
 * 
 *         if start < 0:             # <<<<<<<<<<<<<<
 *             start += shape
 *         if not 0 <= start < shape:
 */
    __pyx_t_1 = ((__pyx_v_start < 0) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":818
 * 
 *         if start < 0:
 *             start += shape             # <<<<<<<<<<<<<<
 *         if not 0 <= start < shape:
 *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
 */
      __pyx_v_start = (__pyx_v_start + __pyx_v_shape);

      /* "View.MemoryView":817
 *     if not is_slice:
 * 
 *         if start < 0:             # <<<<<<<<<<<<<<
 *             start += shape
 *         if not 0 <= start < shape:
 */
    }

    /* "View.MemoryView":819
 *         if start < 0:
 *             start += shape
 *         if not 0 <= start < shape:             # <<<<<<<<<<<<<<
 *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
 *     else:
 */
    __pyx_t_1 = (0 <= __pyx_v_start);
    if (__pyx_t_1) {
      __pyx_t_1 = (__pyx_v_start < __pyx_v_shape);
    }
    __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":820
 *             start += shape
 *         if not 0 <= start < shape:
 *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)             # <<<<<<<<<<<<<<
 *     else:
 * 
 */
      __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"Index out of bounds (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(4, 820, __pyx_L1_error)

      /* "View.MemoryView":819
 *         if start < 0:
 *             start += shape
 *         if not 0 <= start < shape:             # <<<<<<<<<<<<<<
 *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
 *     else:
 */
    }

    /* "View.MemoryView":815
 *     cdef bint negative_step
 * 
 *     if not is_slice:             # <<<<<<<<<<<<<<
 * 
 *         if start < 0:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":823
 *     else:
 * 
 *         negative_step = have_step != 0 and step < 0             # <<<<<<<<<<<<<<
 * 
 *         if have_step and step == 0:
 */
  /*else*/ {
    __pyx_t_1 = ((__pyx_v_have_step != 0) != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_1 = ((__pyx_v_step < 0) != 0);
    __pyx_t_2 = __pyx_t_1;
    __pyx_L6_bool_binop_done:;
    __pyx_v_negative_step = __pyx_t_2;

    /* "View.MemoryView":825
 *         negative_step = have_step != 0 and step < 0
 * 
 *         if have_step and step == 0:             # <<<<<<<<<<<<<<
 *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
 * 
 */
    __pyx_t_1 = (__pyx_v_have_step != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_1 = ((__pyx_v_step == 0) != 0);
    __pyx_t_2 = __pyx_t_1;
    __pyx_L9_bool_binop_done:;
    if (__pyx_t_2) {

      /* "View.MemoryView":826
 * 
 *         if have_step and step == 0:
 *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Step may not be zero (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(4, 826, __pyx_L1_error)

      /* "View.MemoryView":825
 *         negative_step = have_step != 0 and step < 0
 * 
 *         if have_step and step == 0:             # <<<<<<<<<<<<<<
 *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
 * 
 */
    }

    /* "View.MemoryView":829
 * 
 * 
 *         if have_start:             # <<<<<<<<<<<<<<
 *             if start < 0:
 *                 start += shape
 */
    __pyx_t_2 = (__pyx_v_have_start != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":830
 * 
 *         if have_start:
 *             if start < 0:             # <<<<<<<<<<<<<<
 *                 start += shape
 *                 if start < 0:
 */
      __pyx_t_2 = ((__pyx_v_start < 0) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":831
 *         if have_start:
 *             if start < 0:
 *                 start += shape             # <<<<<<<<<<<<<<
 *                 if start < 0:
 *                     start = 0
 */
        __pyx_v_start = (__pyx_v_start + __pyx_v_shape);

        /* "View.MemoryView":832
 *             if start < 0:
 *                 start += shape
 *                 if start < 0:             # <<<<<<<<<<<<<<
 *                     start = 0
 *             elif start >= shape:
 */
        __pyx_t_2 = ((__pyx_v_start < 0) != 0);
        if (__pyx_t_2) {

          /* "View.MemoryView":833
 *                 start += shape
 *                 if start < 0:
 *                     start = 0             # <<<<<<<<<<<<<<
 *             elif start >= shape:
 *                 if negative_step:
 */
          __pyx_v_start = 0;

          /* "View.MemoryView":832
 *             if start < 0:
 *                 start += shape
 *                 if start < 0:             # <<<<<<<<<<<<<<
 *                     start = 0
 *             elif start >= shape:
 */
        }

        /* "View.MemoryView":830
 * 
 *         if have_start:
 *             if start < 0:             # <<<<<<<<<<<<<<
 *                 start += shape
 *                 if start < 0:
 */
        goto __pyx_L12;
      }

      /* "View.MemoryView":834
 *                 if start < 0:
 *                     start = 0
 *             elif start >= shape:             # <<<<<<<<<<<<<<
 *                 if negative_step:
 *                     start = shape - 1
 */
      __pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":835
 *                     start = 0
 *             elif start >= shape:
 *                 if negative_step:             # <<<<<<<<<<<<<<
 *                     start = shape - 1
 *                 else:
 */
        __pyx_t_2 = (__pyx_v_negative_step != 0);
        if (__pyx_t_2) {

          /* "View.MemoryView":836
 *             elif start >= shape:
 *                 if negative_step:
 *                     start = shape - 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     start = shape
 */
          __pyx_v_start = (__pyx_v_shape - 1);

          /* "View.MemoryView":835
 *                     start = 0
 *             elif start >= shape:
 *                 if negative_step:             # <<<<<<<<<<<<<<
 *                     start = shape - 1
 *                 else:
 */
          goto __pyx_L14;
        }

        /* "View.MemoryView":838
 *                     start = shape - 1
 *                 else:
 *                     start = shape             # <<<<<<<<<<<<<<
 *         else:
 *             if negative_step:
 */
        /*else*/ {
          __pyx_v_start = __pyx_v_shape;
        }
        __pyx_L14:;

        /* "View.MemoryView":834
 *                 if start < 0:
 *                     start = 0
 *             elif start >= shape:             # <<<<<<<<<<<<<<
 *                 if negative_step:
 *                     start = shape - 1
 */
      }
      __pyx_L12:;

      /* "View.MemoryView":829
 * 
 * 
 *         if have_start:             # <<<<<<<<<<<<<<
 *             if start < 0:
 *                 start += shape
 */
      goto __pyx_L11;
    }

    /* "View.MemoryView":840
 *                     start = shape
 *         else:
 *             if negative_step:             # <<<<<<<<<<<<<<
 *                 start = shape - 1
 *             else:
 */
    /*else*/ {
      __pyx_t_2 = (__pyx_v_negative_step != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":841
 *         else:
 *             if negative_step:
 *                 start = shape - 1             # <<<<<<<<<<<<<<
 *             else:
 *                 start = 0
 */
        __pyx_v_start = (__pyx_v_shape - 1);

        /* "View.MemoryView":840
 *                     start = shape
 *         else:
 *             if negative_step:             # <<<<<<<<<<<<<<
 *                 start = shape - 1
 *             else:
 */
        goto __pyx_L15;
      }

      /* "View.MemoryView":843
 *                 start = shape - 1
 *             else:
 *                 start = 0             # <<<<<<<<<<<<<<
 * 
 *         if have_stop:
 */
      /*else*/ {
        __pyx_v_start = 0;
      }
      __pyx_L15:;
    }
    __pyx_L11:;

    /* "View.MemoryView":845
 *                 start = 0
 * 
 *         if have_stop:             # <<<<<<<<<<<<<<
 *             if stop < 0:
 *                 stop += shape
 */
    __pyx_t_2 = (__pyx_v_have_stop != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":846
 * 
 *         if have_stop:
 *             if stop < 0:             # <<<<<<<<<<<<<<
 *                 stop += shape
 *                 if stop < 0:
 */
      __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":847
 *         if have_stop:
 *             if stop < 0:
 *                 stop += shape             # <<<<<<<<<<<<<<
 *                 if stop < 0:
 *                     stop = 0
 */
        __pyx_v_stop = (__pyx_v_stop + __pyx_v_shape);

        /* "View.MemoryView":848
 *             if stop < 0:
 *                 stop += shape
 *                 if stop < 0:             # <<<<<<<<<<<<<<
 *                     stop = 0
 *             elif stop > shape:
 */
        __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
        if (__pyx_t_2) {

          /* "View.MemoryView":849
 *                 stop += shape
 *                 if stop < 0:
 *                     stop = 0             # <<<<<<<<<<<<<<
 *             elif stop > shape:
 *                 stop = shape
 */
          __pyx_v_stop = 0;

          /* "View.MemoryView":848
 *             if stop < 0:
 *                 stop += shape
 *                 if stop < 0:             # <<<<<<<<<<<<<<
 *                     stop = 0
 *             elif stop > shape:
 */
        }

        /* "View.MemoryView":846
 * 
 *         if have_stop:
 *             if stop < 0:             # <<<<<<<<<<<<<<
 *                 stop += shape
 *                 if stop < 0:
 */
        goto __pyx_L17;
      }

      /* "View.MemoryView":850
 *                 if stop < 0:
 *                     stop = 0
 *             elif stop > shape:             # <<<<<<<<<<<<<<
 *                 stop = shape
 *         else:
 */
      __pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":851
 *                     stop = 0
 *             elif stop > shape:
 *                 stop = shape             # <<<<<<<<<<<<<<
 *         else:
 *             if negative_step:
 */
        __pyx_v_stop = __pyx_v_shape;

        /* "View.MemoryView":850
 *                 if stop < 0:
 *                     stop = 0
 *             elif stop > shape:             # <<<<<<<<<<<<<<
 *                 stop = shape
 *         else:
 */
      }
      __pyx_L17:;

      /* "View.MemoryView":845
 *                 start = 0
 * 
 *         if have_stop:             # <<<<<<<<<<<<<<
 *             if stop < 0:
 *                 stop += shape
 */
      goto __pyx_L16;
    }

    /* "View.MemoryView":853
 *                 stop = shape
 *         else:
 *             if negative_step:             # <<<<<<<<<<<<<<
 *                 stop = -1
 *             else:
 */
    /*else*/ {
      __pyx_t_2 = (__pyx_v_negative_step != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":854
 *         else:
 *             if negative_step:
 *                 stop = -1             # <<<<<<<<<<<<<<
 *             else:
 *                 stop = shape
 */
        __pyx_v_stop = -1L;

        /* "View.MemoryView":853
 *                 stop = shape
 *         else:
 *             if negative_step:             # <<<<<<<<<<<<<<
 *                 stop = -1
 *             else:
 */
        goto __pyx_L19;
      }

      /* "View.MemoryView":856
 *                 stop = -1
 *             else:
 *                 stop = shape             # <<<<<<<<<<<<<<
 * 
 *         if not have_step:
 */
      /*else*/ {
        __pyx_v_stop = __pyx_v_shape;
      }
      __pyx_L19:;
    }
    __pyx_L16:;

    /* "View.MemoryView":858
 *                 stop = shape
 * 
 *         if not have_step:             # <<<<<<<<<<<<<<
 *             step = 1
 * 
 */
    __pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":859
 * 
 *         if not have_step:
 *             step = 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_v_step = 1;

      /* "View.MemoryView":858
 *                 stop = shape
 * 
 *         if not have_step:             # <<<<<<<<<<<<<<
 *             step = 1
 * 
 */
    }

    /* "View.MemoryView":863
 * 
 *         with cython.cdivision(True):
 *             new_shape = (stop - start) // step             # <<<<<<<<<<<<<<
 * 
 *             if (stop - start) - step * new_shape:
 */
    __pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step);

    /* "View.MemoryView":865
 *             new_shape = (stop - start) // step
 * 
 *             if (stop - start) - step * new_shape:             # <<<<<<<<<<<<<<
 *                 new_shape += 1
 * 
 */
    __pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":866
 * 
 *             if (stop - start) - step * new_shape:
 *                 new_shape += 1             # <<<<<<<<<<<<<<
 * 
 *         if new_shape < 0:
 */
      __pyx_v_new_shape = (__pyx_v_new_shape + 1);

      /* "View.MemoryView":865
 *             new_shape = (stop - start) // step
 * 
 *             if (stop - start) - step * new_shape:             # <<<<<<<<<<<<<<
 *                 new_shape += 1
 * 
 */
    }

    /* "View.MemoryView":868
 *                 new_shape += 1
 * 
 *         if new_shape < 0:             # <<<<<<<<<<<<<<
 *             new_shape = 0
 * 
 */
    __pyx_t_2 = ((__pyx_v_new_shape < 0) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":869
 * 
 *         if new_shape < 0:
 *             new_shape = 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_v_new_shape = 0;

      /* "View.MemoryView":868
 *                 new_shape += 1
 * 
 *         if new_shape < 0:             # <<<<<<<<<<<<<<
 *             new_shape = 0
 * 
 */
    }

    /* "View.MemoryView":872
 * 
 * 
 *         dst.strides[new_ndim] = stride * step             # <<<<<<<<<<<<<<
 *         dst.shape[new_ndim] = new_shape
 *         dst.suboffsets[new_ndim] = suboffset
 */
    (__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step);

    /* "View.MemoryView":873
 * 
 *         dst.strides[new_ndim] = stride * step
 *         dst.shape[new_ndim] = new_shape             # <<<<<<<<<<<<<<
 *         dst.suboffsets[new_ndim] = suboffset
 * 
 */
    (__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape;

    /* "View.MemoryView":874
 *         dst.strides[new_ndim] = stride * step
 *         dst.shape[new_ndim] = new_shape
 *         dst.suboffsets[new_ndim] = suboffset             # <<<<<<<<<<<<<<
 * 
 * 
 */
    (__pyx_v_dst->suboffsets[__pyx_v_new_ndim]) = __pyx_v_suboffset;
  }
  __pyx_L3:;

  /* "View.MemoryView":877
 * 
 * 
 *     if suboffset_dim[0] < 0:             # <<<<<<<<<<<<<<
 *         dst.data += start * stride
 *     else:
 */
  __pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":878
 * 
 *     if suboffset_dim[0] < 0:
 *         dst.data += start * stride             # <<<<<<<<<<<<<<
 *     else:
 *         dst.suboffsets[suboffset_dim[0]] += start * stride
 */
    __pyx_v_dst->data = (__pyx_v_dst->data + (__pyx_v_start * __pyx_v_stride));

    /* "View.MemoryView":877
 * 
 * 
 *     if suboffset_dim[0] < 0:             # <<<<<<<<<<<<<<
 *         dst.data += start * stride
 *     else:
 */
    goto __pyx_L23;
  }

  /* "View.MemoryView":880
 *         dst.data += start * stride
 *     else:
 *         dst.suboffsets[suboffset_dim[0]] += start * stride             # <<<<<<<<<<<<<<
 * 
 *     if suboffset >= 0:
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_suboffset_dim[0]);
    (__pyx_v_dst->suboffsets[__pyx_t_3]) = ((__pyx_v_dst->suboffsets[__pyx_t_3]) + (__pyx_v_start * __pyx_v_stride));
  }
  __pyx_L23:;

  /* "View.MemoryView":882
 *         dst.suboffsets[suboffset_dim[0]] += start * stride
 * 
 *     if suboffset >= 0:             # <<<<<<<<<<<<<<
 *         if not is_slice:
 *             if new_ndim == 0:
 */
  __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":883
 * 
 *     if suboffset >= 0:
 *         if not is_slice:             # <<<<<<<<<<<<<<
 *             if new_ndim == 0:
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 */
    __pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":884
 *     if suboffset >= 0:
 *         if not is_slice:
 *             if new_ndim == 0:             # <<<<<<<<<<<<<<
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 *             else:
 */
      __pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":885
 *         if not is_slice:
 *             if new_ndim == 0:
 *                 dst.data = (<char **> dst.data)[0] + suboffset             # <<<<<<<<<<<<<<
 *             else:
 *                 _err_dim(IndexError, "All dimensions preceding dimension %d "
 */
        __pyx_v_dst->data = ((((char **)__pyx_v_dst->data)[0]) + __pyx_v_suboffset);

        /* "View.MemoryView":884
 *     if suboffset >= 0:
 *         if not is_slice:
 *             if new_ndim == 0:             # <<<<<<<<<<<<<<
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 *             else:
 */
        goto __pyx_L26;
      }

      /* "View.MemoryView":887
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 *             else:
 *                 _err_dim(IndexError, "All dimensions preceding dimension %d "             # <<<<<<<<<<<<<<
 *                                      "must be indexed and not sliced", dim)
 *         else:
 */
      /*else*/ {

        /* "View.MemoryView":888
 *             else:
 *                 _err_dim(IndexError, "All dimensions preceding dimension %d "
 *                                      "must be indexed and not sliced", dim)             # <<<<<<<<<<<<<<
 *         else:
 *             suboffset_dim[0] = new_ndim
 */
        __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"All dimensions preceding dimension %d must be indexed and not sliced"), __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(4, 887, __pyx_L1_error)
      }
      __pyx_L26:;

      /* "View.MemoryView":883
 * 
 *     if suboffset >= 0:
 *         if not is_slice:             # <<<<<<<<<<<<<<
 *             if new_ndim == 0:
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 */
      goto __pyx_L25;
    }

    /* "View.MemoryView":890
 *                                      "must be indexed and not sliced", dim)
 *         else:
 *             suboffset_dim[0] = new_ndim             # <<<<<<<<<<<<<<
 * 
 *     return 0
 */
    /*else*/ {
      (__pyx_v_suboffset_dim[0]) = __pyx_v_new_ndim;
    }
    __pyx_L25:;

    /* "View.MemoryView":882
 *         dst.suboffsets[suboffset_dim[0]] += start * stride
 * 
 *     if suboffset >= 0:             # <<<<<<<<<<<<<<
 *         if not is_slice:
 *             if new_ndim == 0:
 */
  }

  /* "View.MemoryView":892
 *             suboffset_dim[0] = new_ndim
 * 
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "View.MemoryView":795
 * 
 * @cname('__pyx_memoryview_slice_memviewslice')
 * cdef int slice_memviewslice(             # <<<<<<<<<<<<<<
 *         __Pyx_memviewslice *dst,
 *         Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
 */

  /* function exit code */
  __pyx_L1_error:;
  {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
    #endif
    __Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
    #ifdef WITH_THREAD
    __Pyx_PyGILState_Release(__pyx_gilstate_save);
    #endif
  }
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":898
 * 
 * @cname('__pyx_pybuffer_index')
 * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,             # <<<<<<<<<<<<<<
 *                           Py_ssize_t dim) except NULL:
 *     cdef Py_ssize_t shape, stride, suboffset = -1
 */

static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, Py_ssize_t __pyx_v_index, Py_ssize_t __pyx_v_dim) {
  Py_ssize_t __pyx_v_shape;
  Py_ssize_t __pyx_v_stride;
  Py_ssize_t __pyx_v_suboffset;
  Py_ssize_t __pyx_v_itemsize;
  char *__pyx_v_resultp;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("pybuffer_index", 0);

  /* "View.MemoryView":900
 * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,
 *                           Py_ssize_t dim) except NULL:
 *     cdef Py_ssize_t shape, stride, suboffset = -1             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t itemsize = view.itemsize
 *     cdef char *resultp
 */
  __pyx_v_suboffset = -1L;

  /* "View.MemoryView":901
 *                           Py_ssize_t dim) except NULL:
 *     cdef Py_ssize_t shape, stride, suboffset = -1
 *     cdef Py_ssize_t itemsize = view.itemsize             # <<<<<<<<<<<<<<
 *     cdef char *resultp
 * 
 */
  __pyx_t_1 = __pyx_v_view->itemsize;
  __pyx_v_itemsize = __pyx_t_1;

  /* "View.MemoryView":904
 *     cdef char *resultp
 * 
 *     if view.ndim == 0:             # <<<<<<<<<<<<<<
 *         shape = view.len / itemsize
 *         stride = itemsize
 */
  __pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":905
 * 
 *     if view.ndim == 0:
 *         shape = view.len / itemsize             # <<<<<<<<<<<<<<
 *         stride = itemsize
 *     else:
 */
    if (unlikely(__pyx_v_itemsize == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(4, 905, __pyx_L1_error)
    }
    else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_view->len))) {
      PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
      __PYX_ERR(4, 905, __pyx_L1_error)
    }
    __pyx_v_shape = __Pyx_div_Py_ssize_t(__pyx_v_view->len, __pyx_v_itemsize);

    /* "View.MemoryView":906
 *     if view.ndim == 0:
 *         shape = view.len / itemsize
 *         stride = itemsize             # <<<<<<<<<<<<<<
 *     else:
 *         shape = view.shape[dim]
 */
    __pyx_v_stride = __pyx_v_itemsize;

    /* "View.MemoryView":904
 *     cdef char *resultp
 * 
 *     if view.ndim == 0:             # <<<<<<<<<<<<<<
 *         shape = view.len / itemsize
 *         stride = itemsize
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":908
 *         stride = itemsize
 *     else:
 *         shape = view.shape[dim]             # <<<<<<<<<<<<<<
 *         stride = view.strides[dim]
 *         if view.suboffsets != NULL:
 */
  /*else*/ {
    __pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]);

    /* "View.MemoryView":909
 *     else:
 *         shape = view.shape[dim]
 *         stride = view.strides[dim]             # <<<<<<<<<<<<<<
 *         if view.suboffsets != NULL:
 *             suboffset = view.suboffsets[dim]
 */
    __pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]);

    /* "View.MemoryView":910
 *         shape = view.shape[dim]
 *         stride = view.strides[dim]
 *         if view.suboffsets != NULL:             # <<<<<<<<<<<<<<
 *             suboffset = view.suboffsets[dim]
 * 
 */
    __pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":911
 *         stride = view.strides[dim]
 *         if view.suboffsets != NULL:
 *             suboffset = view.suboffsets[dim]             # <<<<<<<<<<<<<<
 * 
 *     if index < 0:
 */
      __pyx_v_suboffset = (__pyx_v_view->suboffsets[__pyx_v_dim]);

      /* "View.MemoryView":910
 *         shape = view.shape[dim]
 *         stride = view.strides[dim]
 *         if view.suboffsets != NULL:             # <<<<<<<<<<<<<<
 *             suboffset = view.suboffsets[dim]
 * 
 */
    }
  }
  __pyx_L3:;

  /* "View.MemoryView":913
 *             suboffset = view.suboffsets[dim]
 * 
 *     if index < 0:             # <<<<<<<<<<<<<<
 *         index += view.shape[dim]
 *         if index < 0:
 */
  __pyx_t_2 = ((__pyx_v_index < 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":914
 * 
 *     if index < 0:
 *         index += view.shape[dim]             # <<<<<<<<<<<<<<
 *         if index < 0:
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 */
    __pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim]));

    /* "View.MemoryView":915
 *     if index < 0:
 *         index += view.shape[dim]
 *         if index < 0:             # <<<<<<<<<<<<<<
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 */
    __pyx_t_2 = ((__pyx_v_index < 0) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":916
 *         index += view.shape[dim]
 *         if index < 0:
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)             # <<<<<<<<<<<<<<
 * 
 *     if index >= shape:
 */
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 916, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 916, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 916, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 916, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(4, 916, __pyx_L1_error)

      /* "View.MemoryView":915
 *     if index < 0:
 *         index += view.shape[dim]
 *         if index < 0:             # <<<<<<<<<<<<<<
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 */
    }

    /* "View.MemoryView":913
 *             suboffset = view.suboffsets[dim]
 * 
 *     if index < 0:             # <<<<<<<<<<<<<<
 *         index += view.shape[dim]
 *         if index < 0:
 */
  }

  /* "View.MemoryView":918
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 *     if index >= shape:             # <<<<<<<<<<<<<<
 *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 */
  __pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":919
 * 
 *     if index >= shape:
 *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)             # <<<<<<<<<<<<<<
 * 
 *     resultp = bufp + index * stride
 */
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 919, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 919, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 919, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 919, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 919, __pyx_L1_error)

    /* "View.MemoryView":918
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 *     if index >= shape:             # <<<<<<<<<<<<<<
 *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 */
  }

  /* "View.MemoryView":921
 *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 *     resultp = bufp + index * stride             # <<<<<<<<<<<<<<
 *     if suboffset >= 0:
 *         resultp = (<char **> resultp)[0] + suboffset
 */
  __pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride));

  /* "View.MemoryView":922
 * 
 *     resultp = bufp + index * stride
 *     if suboffset >= 0:             # <<<<<<<<<<<<<<
 *         resultp = (<char **> resultp)[0] + suboffset
 * 
 */
  __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":923
 *     resultp = bufp + index * stride
 *     if suboffset >= 0:
 *         resultp = (<char **> resultp)[0] + suboffset             # <<<<<<<<<<<<<<
 * 
 *     return resultp
 */
    __pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset);

    /* "View.MemoryView":922
 * 
 *     resultp = bufp + index * stride
 *     if suboffset >= 0:             # <<<<<<<<<<<<<<
 *         resultp = (<char **> resultp)[0] + suboffset
 * 
 */
  }

  /* "View.MemoryView":925
 *         resultp = (<char **> resultp)[0] + suboffset
 * 
 *     return resultp             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_resultp;
  goto __pyx_L0;

  /* "View.MemoryView":898
 * 
 * @cname('__pyx_pybuffer_index')
 * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,             # <<<<<<<<<<<<<<
 *                           Py_ssize_t dim) except NULL:
 *     cdef Py_ssize_t shape, stride, suboffset = -1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("View.MemoryView.pybuffer_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":931
 * 
 * @cname('__pyx_memslice_transpose')
 * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:             # <<<<<<<<<<<<<<
 *     cdef int ndim = memslice.memview.view.ndim
 * 
 */

static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) {
  int __pyx_v_ndim;
  Py_ssize_t *__pyx_v_shape;
  Py_ssize_t *__pyx_v_strides;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_r;
  int __pyx_t_1;
  Py_ssize_t *__pyx_t_2;
  long __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;

  /* "View.MemoryView":932
 * @cname('__pyx_memslice_transpose')
 * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:
 *     cdef int ndim = memslice.memview.view.ndim             # <<<<<<<<<<<<<<
 * 
 *     cdef Py_ssize_t *shape = memslice.shape
 */
  __pyx_t_1 = __pyx_v_memslice->memview->view.ndim;
  __pyx_v_ndim = __pyx_t_1;

  /* "View.MemoryView":934
 *     cdef int ndim = memslice.memview.view.ndim
 * 
 *     cdef Py_ssize_t *shape = memslice.shape             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t *strides = memslice.strides
 * 
 */
  __pyx_t_2 = __pyx_v_memslice->shape;
  __pyx_v_shape = __pyx_t_2;

  /* "View.MemoryView":935
 * 
 *     cdef Py_ssize_t *shape = memslice.shape
 *     cdef Py_ssize_t *strides = memslice.strides             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __pyx_v_memslice->strides;
  __pyx_v_strides = __pyx_t_2;

  /* "View.MemoryView":939
 * 
 *     cdef int i, j
 *     for i in range(ndim / 2):             # <<<<<<<<<<<<<<
 *         j = ndim - 1 - i
 *         strides[i], strides[j] = strides[j], strides[i]
 */
  __pyx_t_3 = __Pyx_div_long(__pyx_v_ndim, 2);
  for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "View.MemoryView":940
 *     cdef int i, j
 *     for i in range(ndim / 2):
 *         j = ndim - 1 - i             # <<<<<<<<<<<<<<
 *         strides[i], strides[j] = strides[j], strides[i]
 *         shape[i], shape[j] = shape[j], shape[i]
 */
    __pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i);

    /* "View.MemoryView":941
 *     for i in range(ndim / 2):
 *         j = ndim - 1 - i
 *         strides[i], strides[j] = strides[j], strides[i]             # <<<<<<<<<<<<<<
 *         shape[i], shape[j] = shape[j], shape[i]
 * 
 */
    __pyx_t_4 = (__pyx_v_strides[__pyx_v_j]);
    __pyx_t_5 = (__pyx_v_strides[__pyx_v_i]);
    (__pyx_v_strides[__pyx_v_i]) = __pyx_t_4;
    (__pyx_v_strides[__pyx_v_j]) = __pyx_t_5;

    /* "View.MemoryView":942
 *         j = ndim - 1 - i
 *         strides[i], strides[j] = strides[j], strides[i]
 *         shape[i], shape[j] = shape[j], shape[i]             # <<<<<<<<<<<<<<
 * 
 *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
 */
    __pyx_t_5 = (__pyx_v_shape[__pyx_v_j]);
    __pyx_t_4 = (__pyx_v_shape[__pyx_v_i]);
    (__pyx_v_shape[__pyx_v_i]) = __pyx_t_5;
    (__pyx_v_shape[__pyx_v_j]) = __pyx_t_4;

    /* "View.MemoryView":944
 *         shape[i], shape[j] = shape[j], shape[i]
 * 
 *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:             # <<<<<<<<<<<<<<
 *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
 * 
 */
    __pyx_t_7 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_7 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0);
    __pyx_t_6 = __pyx_t_7;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_6) {

      /* "View.MemoryView":945
 * 
 *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
 *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")             # <<<<<<<<<<<<<<
 * 
 *     return 1
 */
      __pyx_t_8 = __pyx_memoryview_err(__pyx_builtin_ValueError, ((char *)"Cannot transpose memoryview with indirect dimensions")); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(4, 945, __pyx_L1_error)

      /* "View.MemoryView":944
 *         shape[i], shape[j] = shape[j], shape[i]
 * 
 *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:             # <<<<<<<<<<<<<<
 *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
 * 
 */
    }
  }

  /* "View.MemoryView":947
 *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
 * 
 *     return 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "View.MemoryView":931
 * 
 * @cname('__pyx_memslice_transpose')
 * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:             # <<<<<<<<<<<<<<
 *     cdef int ndim = memslice.memview.view.ndim
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
    #endif
    __Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
    #ifdef WITH_THREAD
    __Pyx_PyGILState_Release(__pyx_gilstate_save);
    #endif
  }
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":964
 *     cdef int (*to_dtype_func)(char *, object) except 0
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
 * 
 */

/* Python wrapper */
static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "View.MemoryView":965
 * 
 *     def __dealloc__(self):
 *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)             # <<<<<<<<<<<<<<
 * 
 *     cdef convert_item_to_object(self, char *itemp):
 */
  __PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1);

  /* "View.MemoryView":964
 *     cdef int (*to_dtype_func)(char *, object) except 0
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
 * 
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "View.MemoryView":967
 *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
 * 
 *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
 *         if self.to_object_func != NULL:
 *             return self.to_object_func(itemp)
 */

static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("convert_item_to_object", 0);

  /* "View.MemoryView":968
 * 
 *     cdef convert_item_to_object(self, char *itemp):
 *         if self.to_object_func != NULL:             # <<<<<<<<<<<<<<
 *             return self.to_object_func(itemp)
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":969
 *     cdef convert_item_to_object(self, char *itemp):
 *         if self.to_object_func != NULL:
 *             return self.to_object_func(itemp)             # <<<<<<<<<<<<<<
 *         else:
 *             return memoryview.convert_item_to_object(self, itemp)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 969, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "View.MemoryView":968
 * 
 *     cdef convert_item_to_object(self, char *itemp):
 *         if self.to_object_func != NULL:             # <<<<<<<<<<<<<<
 *             return self.to_object_func(itemp)
 *         else:
 */
  }

  /* "View.MemoryView":971
 *             return self.to_object_func(itemp)
 *         else:
 *             return memoryview.convert_item_to_object(self, itemp)             # <<<<<<<<<<<<<<
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_memoryview_convert_item_to_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "View.MemoryView":967
 *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
 * 
 *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
 *         if self.to_object_func != NULL:
 *             return self.to_object_func(itemp)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView._memoryviewslice.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":973
 *             return memoryview.convert_item_to_object(self, itemp)
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
 *         if self.to_dtype_func != NULL:
 *             self.to_dtype_func(itemp, value)
 */

static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("assign_item_from_object", 0);

  /* "View.MemoryView":974
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):
 *         if self.to_dtype_func != NULL:             # <<<<<<<<<<<<<<
 *             self.to_dtype_func(itemp, value)
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":975
 *     cdef assign_item_from_object(self, char *itemp, object value):
 *         if self.to_dtype_func != NULL:
 *             self.to_dtype_func(itemp, value)             # <<<<<<<<<<<<<<
 *         else:
 *             memoryview.assign_item_from_object(self, itemp, value)
 */
    __pyx_t_2 = __pyx_v_self->to_dtype_func(__pyx_v_itemp, __pyx_v_value); if (unlikely(__pyx_t_2 == 0)) __PYX_ERR(4, 975, __pyx_L1_error)

    /* "View.MemoryView":974
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):
 *         if self.to_dtype_func != NULL:             # <<<<<<<<<<<<<<
 *             self.to_dtype_func(itemp, value)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":977
 *             self.to_dtype_func(itemp, value)
 *         else:
 *             memoryview.assign_item_from_object(self, itemp, value)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  /*else*/ {
    __pyx_t_3 = __pyx_memoryview_assign_item_from_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 977, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "View.MemoryView":973
 *             return memoryview.convert_item_to_object(self, itemp)
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
 *         if self.to_dtype_func != NULL:
 *             self.to_dtype_func(itemp, value)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView._memoryviewslice.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":980
 * 
 *     @property
 *     def base(self):             # <<<<<<<<<<<<<<
 *         return self.from_object
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":981
 *     @property
 *     def base(self):
 *         return self.from_object             # <<<<<<<<<<<<<<
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->from_object);
  __pyx_r = __pyx_v_self->from_object;
  goto __pyx_L0;

  /* "View.MemoryView":980
 * 
 *     @property
 *     def base(self):             # <<<<<<<<<<<<<<
 *         return self.from_object
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf___pyx_memoryviewslice___reduce_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__219, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(4, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf___pyx_memoryviewslice_2__setstate_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__220, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(4, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":987
 * 
 * @cname('__pyx_memoryview_fromslice')
 * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice,             # <<<<<<<<<<<<<<
 *                           int ndim,
 *                           object (*to_object_func)(char *),
 */

static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewslice, int __pyx_v_ndim, PyObject *(*__pyx_v_to_object_func)(char *), int (*__pyx_v_to_dtype_func)(char *, PyObject *), int __pyx_v_dtype_is_object) {
  struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
  Py_ssize_t __pyx_v_suboffset;
  PyObject *__pyx_v_length = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_TypeInfo *__pyx_t_4;
  Py_buffer __pyx_t_5;
  Py_ssize_t *__pyx_t_6;
  Py_ssize_t *__pyx_t_7;
  Py_ssize_t *__pyx_t_8;
  Py_ssize_t __pyx_t_9;
  __Pyx_RefNannySetupContext("memoryview_fromslice", 0);

  /* "View.MemoryView":995
 *     cdef _memoryviewslice result
 * 
 *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":996
 * 
 *     if <PyObject *> memviewslice.memview == Py_None:
 *         return None             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;

    /* "View.MemoryView":995
 *     cdef _memoryviewslice result
 * 
 *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  }

  /* "View.MemoryView":1001
 * 
 * 
 *     result = _memoryviewslice(None, 0, dtype_is_object)             # <<<<<<<<<<<<<<
 * 
 *     result.from_slice = memviewslice
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 1001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 1001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryviewslice_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 1001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "View.MemoryView":1003
 *     result = _memoryviewslice(None, 0, dtype_is_object)
 * 
 *     result.from_slice = memviewslice             # <<<<<<<<<<<<<<
 *     __PYX_INC_MEMVIEW(&memviewslice, 1)
 * 
 */
  __pyx_v_result->from_slice = __pyx_v_memviewslice;

  /* "View.MemoryView":1004
 * 
 *     result.from_slice = memviewslice
 *     __PYX_INC_MEMVIEW(&memviewslice, 1)             # <<<<<<<<<<<<<<
 * 
 *     result.from_object = (<memoryview> memviewslice.memview).base
 */
  __PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1);

  /* "View.MemoryView":1006
 *     __PYX_INC_MEMVIEW(&memviewslice, 1)
 * 
 *     result.from_object = (<memoryview> memviewslice.memview).base             # <<<<<<<<<<<<<<
 *     result.typeinfo = memviewslice.memview.typeinfo
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_memviewslice.memview), __pyx_n_s_base); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 1006, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_result->from_object);
  __Pyx_DECREF(__pyx_v_result->from_object);
  __pyx_v_result->from_object = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "View.MemoryView":1007
 * 
 *     result.from_object = (<memoryview> memviewslice.memview).base
 *     result.typeinfo = memviewslice.memview.typeinfo             # <<<<<<<<<<<<<<
 * 
 *     result.view = memviewslice.memview.view
 */
  __pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo;
  __pyx_v_result->__pyx_base.typeinfo = __pyx_t_4;

  /* "View.MemoryView":1009
 *     result.typeinfo = memviewslice.memview.typeinfo
 * 
 *     result.view = memviewslice.memview.view             # <<<<<<<<<<<<<<
 *     result.view.buf = <void *> memviewslice.data
 *     result.view.ndim = ndim
 */
  __pyx_t_5 = __pyx_v_memviewslice.memview->view;
  __pyx_v_result->__pyx_base.view = __pyx_t_5;

  /* "View.MemoryView":1010
 * 
 *     result.view = memviewslice.memview.view
 *     result.view.buf = <void *> memviewslice.data             # <<<<<<<<<<<<<<
 *     result.view.ndim = ndim
 *     (<__pyx_buffer *> &result.view).obj = Py_None
 */
  __pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data);

  /* "View.MemoryView":1011
 *     result.view = memviewslice.memview.view
 *     result.view.buf = <void *> memviewslice.data
 *     result.view.ndim = ndim             # <<<<<<<<<<<<<<
 *     (<__pyx_buffer *> &result.view).obj = Py_None
 *     Py_INCREF(Py_None)
 */
  __pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim;

  /* "View.MemoryView":1012
 *     result.view.buf = <void *> memviewslice.data
 *     result.view.ndim = ndim
 *     (<__pyx_buffer *> &result.view).obj = Py_None             # <<<<<<<<<<<<<<
 *     Py_INCREF(Py_None)
 * 
 */
  ((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None;

  /* "View.MemoryView":1013
 *     result.view.ndim = ndim
 *     (<__pyx_buffer *> &result.view).obj = Py_None
 *     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
 * 
 *     result.flags = PyBUF_RECORDS
 */
  Py_INCREF(Py_None);

  /* "View.MemoryView":1015
 *     Py_INCREF(Py_None)
 * 
 *     result.flags = PyBUF_RECORDS             # <<<<<<<<<<<<<<
 * 
 *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
 */
  __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS;

  /* "View.MemoryView":1017
 *     result.flags = PyBUF_RECORDS
 * 
 *     result.view.shape = <Py_ssize_t *> result.from_slice.shape             # <<<<<<<<<<<<<<
 *     result.view.strides = <Py_ssize_t *> result.from_slice.strides
 * 
 */
  __pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape);

  /* "View.MemoryView":1018
 * 
 *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
 *     result.view.strides = <Py_ssize_t *> result.from_slice.strides             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides);

  /* "View.MemoryView":1021
 * 
 * 
 *     result.view.suboffsets = NULL             # <<<<<<<<<<<<<<
 *     for suboffset in result.from_slice.suboffsets[:ndim]:
 *         if suboffset >= 0:
 */
  __pyx_v_result->__pyx_base.view.suboffsets = NULL;

  /* "View.MemoryView":1022
 * 
 *     result.view.suboffsets = NULL
 *     for suboffset in result.from_slice.suboffsets[:ndim]:             # <<<<<<<<<<<<<<
 *         if suboffset >= 0:
 *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
 */
  __pyx_t_7 = (__pyx_v_result->from_slice.suboffsets + __pyx_v_ndim);
  for (__pyx_t_8 = __pyx_v_result->from_slice.suboffsets; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
    __pyx_t_6 = __pyx_t_8;
    __pyx_v_suboffset = (__pyx_t_6[0]);

    /* "View.MemoryView":1023
 *     result.view.suboffsets = NULL
 *     for suboffset in result.from_slice.suboffsets[:ndim]:
 *         if suboffset >= 0:             # <<<<<<<<<<<<<<
 *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
 *             break
 */
    __pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":1024
 *     for suboffset in result.from_slice.suboffsets[:ndim]:
 *         if suboffset >= 0:
 *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets             # <<<<<<<<<<<<<<
 *             break
 * 
 */
      __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets);

      /* "View.MemoryView":1025
 *         if suboffset >= 0:
 *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
 *             break             # <<<<<<<<<<<<<<
 * 
 *     result.view.len = result.view.itemsize
 */
      goto __pyx_L5_break;

      /* "View.MemoryView":1023
 *     result.view.suboffsets = NULL
 *     for suboffset in result.from_slice.suboffsets[:ndim]:
 *         if suboffset >= 0:             # <<<<<<<<<<<<<<
 *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
 *             break
 */
    }
  }
  __pyx_L5_break:;

  /* "View.MemoryView":1027
 *             break
 * 
 *     result.view.len = result.view.itemsize             # <<<<<<<<<<<<<<
 *     for length in result.view.shape[:ndim]:
 *         result.view.len *= length
 */
  __pyx_t_9 = __pyx_v_result->__pyx_base.view.itemsize;
  __pyx_v_result->__pyx_base.view.len = __pyx_t_9;

  /* "View.MemoryView":1028
 * 
 *     result.view.len = result.view.itemsize
 *     for length in result.view.shape[:ndim]:             # <<<<<<<<<<<<<<
 *         result.view.len *= length
 * 
 */
  __pyx_t_7 = (__pyx_v_result->__pyx_base.view.shape + __pyx_v_ndim);
  for (__pyx_t_8 = __pyx_v_result->__pyx_base.view.shape; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
    __pyx_t_6 = __pyx_t_8;
    __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_6[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 1028, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "View.MemoryView":1029
 *     result.view.len = result.view.itemsize
 *     for length in result.view.shape[:ndim]:
 *         result.view.len *= length             # <<<<<<<<<<<<<<
 * 
 *     result.to_object_func = to_object_func
 */
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_result->__pyx_base.view.len); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 1029, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_2, __pyx_v_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 1029, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 1029, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_result->__pyx_base.view.len = __pyx_t_9;
  }

  /* "View.MemoryView":1031
 *         result.view.len *= length
 * 
 *     result.to_object_func = to_object_func             # <<<<<<<<<<<<<<
 *     result.to_dtype_func = to_dtype_func
 * 
 */
  __pyx_v_result->to_object_func = __pyx_v_to_object_func;

  /* "View.MemoryView":1032
 * 
 *     result.to_object_func = to_object_func
 *     result.to_dtype_func = to_dtype_func             # <<<<<<<<<<<<<<
 * 
 *     return result
 */
  __pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func;

  /* "View.MemoryView":1034
 *     result.to_dtype_func = to_dtype_func
 * 
 *     return result             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_get_slice_from_memoryview')
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "View.MemoryView":987
 * 
 * @cname('__pyx_memoryview_fromslice')
 * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice,             # <<<<<<<<<<<<<<
 *                           int ndim,
 *                           object (*to_object_func)(char *),
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.memoryview_fromslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_length);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":1037
 * 
 * @cname('__pyx_memoryview_get_slice_from_memoryview')
 * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
 *                                                    __Pyx_memviewslice *mslice):
 *     cdef _memoryviewslice obj
 */

static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_mslice) {
  struct __pyx_memoryviewslice_obj *__pyx_v_obj = 0;
  __Pyx_memviewslice *__pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("get_slice_from_memview", 0);

  /* "View.MemoryView":1040
 *                                                    __Pyx_memviewslice *mslice):
 *     cdef _memoryviewslice obj
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         obj = memview
 *         return &obj.from_slice
 */
  __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1041
 *     cdef _memoryviewslice obj
 *     if isinstance(memview, _memoryviewslice):
 *         obj = memview             # <<<<<<<<<<<<<<
 *         return &obj.from_slice
 *     else:
 */
    if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(4, 1041, __pyx_L1_error)
    __pyx_t_3 = ((PyObject *)__pyx_v_memview);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "View.MemoryView":1042
 *     if isinstance(memview, _memoryviewslice):
 *         obj = memview
 *         return &obj.from_slice             # <<<<<<<<<<<<<<
 *     else:
 *         slice_copy(memview, mslice)
 */
    __pyx_r = (&__pyx_v_obj->from_slice);
    goto __pyx_L0;

    /* "View.MemoryView":1040
 *                                                    __Pyx_memviewslice *mslice):
 *     cdef _memoryviewslice obj
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         obj = memview
 *         return &obj.from_slice
 */
  }

  /* "View.MemoryView":1044
 *         return &obj.from_slice
 *     else:
 *         slice_copy(memview, mslice)             # <<<<<<<<<<<<<<
 *         return mslice
 * 
 */
  /*else*/ {
    __pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice);

    /* "View.MemoryView":1045
 *     else:
 *         slice_copy(memview, mslice)
 *         return mslice             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_slice_copy')
 */
    __pyx_r = __pyx_v_mslice;
    goto __pyx_L0;
  }

  /* "View.MemoryView":1037
 * 
 * @cname('__pyx_memoryview_get_slice_from_memoryview')
 * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
 *                                                    __Pyx_memviewslice *mslice):
 *     cdef _memoryviewslice obj
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_obj);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":1048
 * 
 * @cname('__pyx_memoryview_slice_copy')
 * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst):             # <<<<<<<<<<<<<<
 *     cdef int dim
 *     cdef (Py_ssize_t*) shape, strides, suboffsets
 */

static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_dst) {
  int __pyx_v_dim;
  Py_ssize_t *__pyx_v_shape;
  Py_ssize_t *__pyx_v_strides;
  Py_ssize_t *__pyx_v_suboffsets;
  __Pyx_RefNannyDeclarations
  Py_ssize_t *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  __Pyx_RefNannySetupContext("slice_copy", 0);

  /* "View.MemoryView":1052
 *     cdef (Py_ssize_t*) shape, strides, suboffsets
 * 
 *     shape = memview.view.shape             # <<<<<<<<<<<<<<
 *     strides = memview.view.strides
 *     suboffsets = memview.view.suboffsets
 */
  __pyx_t_1 = __pyx_v_memview->view.shape;
  __pyx_v_shape = __pyx_t_1;

  /* "View.MemoryView":1053
 * 
 *     shape = memview.view.shape
 *     strides = memview.view.strides             # <<<<<<<<<<<<<<
 *     suboffsets = memview.view.suboffsets
 * 
 */
  __pyx_t_1 = __pyx_v_memview->view.strides;
  __pyx_v_strides = __pyx_t_1;

  /* "View.MemoryView":1054
 *     shape = memview.view.shape
 *     strides = memview.view.strides
 *     suboffsets = memview.view.suboffsets             # <<<<<<<<<<<<<<
 * 
 *     dst.memview = <__pyx_memoryview *> memview
 */
  __pyx_t_1 = __pyx_v_memview->view.suboffsets;
  __pyx_v_suboffsets = __pyx_t_1;

  /* "View.MemoryView":1056
 *     suboffsets = memview.view.suboffsets
 * 
 *     dst.memview = <__pyx_memoryview *> memview             # <<<<<<<<<<<<<<
 *     dst.data = <char *> memview.view.buf
 * 
 */
  __pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview);

  /* "View.MemoryView":1057
 * 
 *     dst.memview = <__pyx_memoryview *> memview
 *     dst.data = <char *> memview.view.buf             # <<<<<<<<<<<<<<
 * 
 *     for dim in range(memview.view.ndim):
 */
  __pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf);

  /* "View.MemoryView":1059
 *     dst.data = <char *> memview.view.buf
 * 
 *     for dim in range(memview.view.ndim):             # <<<<<<<<<<<<<<
 *         dst.shape[dim] = shape[dim]
 *         dst.strides[dim] = strides[dim]
 */
  __pyx_t_2 = __pyx_v_memview->view.ndim;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_dim = __pyx_t_3;

    /* "View.MemoryView":1060
 * 
 *     for dim in range(memview.view.ndim):
 *         dst.shape[dim] = shape[dim]             # <<<<<<<<<<<<<<
 *         dst.strides[dim] = strides[dim]
 *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
 */
    (__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]);

    /* "View.MemoryView":1061
 *     for dim in range(memview.view.ndim):
 *         dst.shape[dim] = shape[dim]
 *         dst.strides[dim] = strides[dim]             # <<<<<<<<<<<<<<
 *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
 * 
 */
    (__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]);

    /* "View.MemoryView":1062
 *         dst.shape[dim] = shape[dim]
 *         dst.strides[dim] = strides[dim]
 *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_copy_object')
 */
    if ((__pyx_v_suboffsets != 0)) {
      __pyx_t_4 = (__pyx_v_suboffsets[__pyx_v_dim]);
    } else {
      __pyx_t_4 = -1L;
    }
    (__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_4;
  }

  /* "View.MemoryView":1048
 * 
 * @cname('__pyx_memoryview_slice_copy')
 * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst):             # <<<<<<<<<<<<<<
 *     cdef int dim
 *     cdef (Py_ssize_t*) shape, strides, suboffsets
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "View.MemoryView":1065
 * 
 * @cname('__pyx_memoryview_copy_object')
 * cdef memoryview_copy(memoryview memview):             # <<<<<<<<<<<<<<
 *     "Create a new memoryview object"
 *     cdef __Pyx_memviewslice memviewslice
 */

static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx_v_memview) {
  __Pyx_memviewslice __pyx_v_memviewslice;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("memoryview_copy", 0);

  /* "View.MemoryView":1068
 *     "Create a new memoryview object"
 *     cdef __Pyx_memviewslice memviewslice
 *     slice_copy(memview, &memviewslice)             # <<<<<<<<<<<<<<
 *     return memoryview_copy_from_slice(memview, &memviewslice)
 * 
 */
  __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice));

  /* "View.MemoryView":1069
 *     cdef __Pyx_memviewslice memviewslice
 *     slice_copy(memview, &memviewslice)
 *     return memoryview_copy_from_slice(memview, &memviewslice)             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_copy_object_from_slice')
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_memoryview_copy_object_from_slice(__pyx_v_memview, (&__pyx_v_memviewslice)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 1069, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":1065
 * 
 * @cname('__pyx_memoryview_copy_object')
 * cdef memoryview_copy(memoryview memview):             # <<<<<<<<<<<<<<
 *     "Create a new memoryview object"
 *     cdef __Pyx_memviewslice memviewslice
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview_copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":1072
 * 
 * @cname('__pyx_memoryview_copy_object_from_slice')
 * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice):             # <<<<<<<<<<<<<<
 *     """
 *     Create a new memoryview object from a given memoryview object and slice.
 */

static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_memviewslice) {
  PyObject *(*__pyx_v_to_object_func)(char *);
  int (*__pyx_v_to_dtype_func)(char *, PyObject *);
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *(*__pyx_t_3)(char *);
  int (*__pyx_t_4)(char *, PyObject *);
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0);

  /* "View.MemoryView":1079
 *     cdef int (*to_dtype_func)(char *, object) except 0
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         to_object_func = (<_memoryviewslice> memview).to_object_func
 *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
 */
  __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1080
 * 
 *     if isinstance(memview, _memoryviewslice):
 *         to_object_func = (<_memoryviewslice> memview).to_object_func             # <<<<<<<<<<<<<<
 *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
 *     else:
 */
    __pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func;
    __pyx_v_to_object_func = __pyx_t_3;

    /* "View.MemoryView":1081
 *     if isinstance(memview, _memoryviewslice):
 *         to_object_func = (<_memoryviewslice> memview).to_object_func
 *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func             # <<<<<<<<<<<<<<
 *     else:
 *         to_object_func = NULL
 */
    __pyx_t_4 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_dtype_func;
    __pyx_v_to_dtype_func = __pyx_t_4;

    /* "View.MemoryView":1079
 *     cdef int (*to_dtype_func)(char *, object) except 0
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         to_object_func = (<_memoryviewslice> memview).to_object_func
 *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":1083
 *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
 *     else:
 *         to_object_func = NULL             # <<<<<<<<<<<<<<
 *         to_dtype_func = NULL
 * 
 */
  /*else*/ {
    __pyx_v_to_object_func = NULL;

    /* "View.MemoryView":1084
 *     else:
 *         to_object_func = NULL
 *         to_dtype_func = NULL             # <<<<<<<<<<<<<<
 * 
 *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,
 */
    __pyx_v_to_dtype_func = NULL;
  }
  __pyx_L3:;

  /* "View.MemoryView":1086
 *         to_dtype_func = NULL
 * 
 *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,             # <<<<<<<<<<<<<<
 *                                 to_object_func, to_dtype_func,
 *                                 memview.dtype_is_object)
 */
  __Pyx_XDECREF(__pyx_r);

  /* "View.MemoryView":1088
 *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,
 *                                 to_object_func, to_dtype_func,
 *                                 memview.dtype_is_object)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __pyx_memoryview_fromslice((__pyx_v_memviewslice[0]), __pyx_v_memview->view.ndim, __pyx_v_to_object_func, __pyx_v_to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":1072
 * 
 * @cname('__pyx_memoryview_copy_object_from_slice')
 * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice):             # <<<<<<<<<<<<<<
 *     """
 *     Create a new memoryview object from a given memoryview object and slice.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.memoryview_copy_from_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":1094
 * 
 * 
 * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:             # <<<<<<<<<<<<<<
 *     if arg < 0:
 *         return -arg
 */

static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) {
  Py_ssize_t __pyx_r;
  int __pyx_t_1;

  /* "View.MemoryView":1095
 * 
 * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
 *     if arg < 0:             # <<<<<<<<<<<<<<
 *         return -arg
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_arg < 0) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1096
 * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
 *     if arg < 0:
 *         return -arg             # <<<<<<<<<<<<<<
 *     else:
 *         return arg
 */
    __pyx_r = (-__pyx_v_arg);
    goto __pyx_L0;

    /* "View.MemoryView":1095
 * 
 * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
 *     if arg < 0:             # <<<<<<<<<<<<<<
 *         return -arg
 *     else:
 */
  }

  /* "View.MemoryView":1098
 *         return -arg
 *     else:
 *         return arg             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_get_best_slice_order')
 */
  /*else*/ {
    __pyx_r = __pyx_v_arg;
    goto __pyx_L0;
  }

  /* "View.MemoryView":1094
 * 
 * 
 * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:             # <<<<<<<<<<<<<<
 *     if arg < 0:
 *         return -arg
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1101
 * 
 * @cname('__pyx_get_best_slice_order')
 * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Figure out the best memory access order for a given slice.
 */

static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim) {
  int __pyx_v_i;
  Py_ssize_t __pyx_v_c_stride;
  Py_ssize_t __pyx_v_f_stride;
  char __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;

  /* "View.MemoryView":1106
 *     """
 *     cdef int i
 *     cdef Py_ssize_t c_stride = 0             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t f_stride = 0
 * 
 */
  __pyx_v_c_stride = 0;

  /* "View.MemoryView":1107
 *     cdef int i
 *     cdef Py_ssize_t c_stride = 0
 *     cdef Py_ssize_t f_stride = 0             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim - 1, -1, -1):
 */
  __pyx_v_f_stride = 0;

  /* "View.MemoryView":1109
 *     cdef Py_ssize_t f_stride = 0
 * 
 *     for i in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
 *         if mslice.shape[i] > 1:
 *             c_stride = mslice.strides[i]
 */
  for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1L; __pyx_t_1-=1) {
    __pyx_v_i = __pyx_t_1;

    /* "View.MemoryView":1110
 * 
 *     for i in range(ndim - 1, -1, -1):
 *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
 *             c_stride = mslice.strides[i]
 *             break
 */
    __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1111
 *     for i in range(ndim - 1, -1, -1):
 *         if mslice.shape[i] > 1:
 *             c_stride = mslice.strides[i]             # <<<<<<<<<<<<<<
 *             break
 * 
 */
      __pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]);

      /* "View.MemoryView":1112
 *         if mslice.shape[i] > 1:
 *             c_stride = mslice.strides[i]
 *             break             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim):
 */
      goto __pyx_L4_break;

      /* "View.MemoryView":1110
 * 
 *     for i in range(ndim - 1, -1, -1):
 *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
 *             c_stride = mslice.strides[i]
 *             break
 */
    }
  }
  __pyx_L4_break:;

  /* "View.MemoryView":1114
 *             break
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         if mslice.shape[i] > 1:
 *             f_stride = mslice.strides[i]
 */
  __pyx_t_1 = __pyx_v_ndim;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_1; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "View.MemoryView":1115
 * 
 *     for i in range(ndim):
 *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
 *             f_stride = mslice.strides[i]
 *             break
 */
    __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1116
 *     for i in range(ndim):
 *         if mslice.shape[i] > 1:
 *             f_stride = mslice.strides[i]             # <<<<<<<<<<<<<<
 *             break
 * 
 */
      __pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]);

      /* "View.MemoryView":1117
 *         if mslice.shape[i] > 1:
 *             f_stride = mslice.strides[i]
 *             break             # <<<<<<<<<<<<<<
 * 
 *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
 */
      goto __pyx_L7_break;

      /* "View.MemoryView":1115
 * 
 *     for i in range(ndim):
 *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
 *             f_stride = mslice.strides[i]
 *             break
 */
    }
  }
  __pyx_L7_break:;

  /* "View.MemoryView":1119
 *             break
 * 
 *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):             # <<<<<<<<<<<<<<
 *         return 'C'
 *     else:
 */
  __pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1120
 * 
 *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
 *         return 'C'             # <<<<<<<<<<<<<<
 *     else:
 *         return 'F'
 */
    __pyx_r = 'C';
    goto __pyx_L0;

    /* "View.MemoryView":1119
 *             break
 * 
 *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):             # <<<<<<<<<<<<<<
 *         return 'C'
 *     else:
 */
  }

  /* "View.MemoryView":1122
 *         return 'C'
 *     else:
 *         return 'F'             # <<<<<<<<<<<<<<
 * 
 * @cython.cdivision(True)
 */
  /*else*/ {
    __pyx_r = 'F';
    goto __pyx_L0;
  }

  /* "View.MemoryView":1101
 * 
 * @cname('__pyx_get_best_slice_order')
 * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Figure out the best memory access order for a given slice.
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1125
 * 
 * @cython.cdivision(True)
 * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides,             # <<<<<<<<<<<<<<
 *                                    char *dst_data, Py_ssize_t *dst_strides,
 *                                    Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
 */

static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v_src_strides, char *__pyx_v_dst_data, Py_ssize_t *__pyx_v_dst_strides, Py_ssize_t *__pyx_v_src_shape, Py_ssize_t *__pyx_v_dst_shape, int __pyx_v_ndim, size_t __pyx_v_itemsize) {
  CYTHON_UNUSED Py_ssize_t __pyx_v_i;
  CYTHON_UNUSED Py_ssize_t __pyx_v_src_extent;
  Py_ssize_t __pyx_v_dst_extent;
  Py_ssize_t __pyx_v_src_stride;
  Py_ssize_t __pyx_v_dst_stride;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;

  /* "View.MemoryView":1132
 * 
 *     cdef Py_ssize_t i
 *     cdef Py_ssize_t src_extent = src_shape[0]             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t dst_extent = dst_shape[0]
 *     cdef Py_ssize_t src_stride = src_strides[0]
 */
  __pyx_v_src_extent = (__pyx_v_src_shape[0]);

  /* "View.MemoryView":1133
 *     cdef Py_ssize_t i
 *     cdef Py_ssize_t src_extent = src_shape[0]
 *     cdef Py_ssize_t dst_extent = dst_shape[0]             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t src_stride = src_strides[0]
 *     cdef Py_ssize_t dst_stride = dst_strides[0]
 */
  __pyx_v_dst_extent = (__pyx_v_dst_shape[0]);

  /* "View.MemoryView":1134
 *     cdef Py_ssize_t src_extent = src_shape[0]
 *     cdef Py_ssize_t dst_extent = dst_shape[0]
 *     cdef Py_ssize_t src_stride = src_strides[0]             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t dst_stride = dst_strides[0]
 * 
 */
  __pyx_v_src_stride = (__pyx_v_src_strides[0]);

  /* "View.MemoryView":1135
 *     cdef Py_ssize_t dst_extent = dst_shape[0]
 *     cdef Py_ssize_t src_stride = src_strides[0]
 *     cdef Py_ssize_t dst_stride = dst_strides[0]             # <<<<<<<<<<<<<<
 * 
 *     if ndim == 1:
 */
  __pyx_v_dst_stride = (__pyx_v_dst_strides[0]);

  /* "View.MemoryView":1137
 *     cdef Py_ssize_t dst_stride = dst_strides[0]
 * 
 *     if ndim == 1:             # <<<<<<<<<<<<<<
 *        if (src_stride > 0 and dst_stride > 0 and
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 */
  __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1138
 * 
 *     if ndim == 1:
 *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 *            memcpy(dst_data, src_data, itemsize * dst_extent)
 */
    __pyx_t_2 = ((__pyx_v_src_stride > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }

    /* "View.MemoryView":1139
 *     if ndim == 1:
 *        if (src_stride > 0 and dst_stride > 0 and
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):             # <<<<<<<<<<<<<<
 *            memcpy(dst_data, src_data, itemsize * dst_extent)
 *        else:
 */
    __pyx_t_2 = (((size_t)__pyx_v_src_stride) == __pyx_v_itemsize);
    if (__pyx_t_2) {
      __pyx_t_2 = (__pyx_v_itemsize == ((size_t)__pyx_v_dst_stride));
    }
    __pyx_t_3 = (__pyx_t_2 != 0);
    __pyx_t_1 = __pyx_t_3;
    __pyx_L5_bool_binop_done:;

    /* "View.MemoryView":1138
 * 
 *     if ndim == 1:
 *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 *            memcpy(dst_data, src_data, itemsize * dst_extent)
 */
    if (__pyx_t_1) {

      /* "View.MemoryView":1140
 *        if (src_stride > 0 and dst_stride > 0 and
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 *            memcpy(dst_data, src_data, itemsize * dst_extent)             # <<<<<<<<<<<<<<
 *        else:
 *            for i in range(dst_extent):
 */
      memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent));

      /* "View.MemoryView":1138
 * 
 *     if ndim == 1:
 *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 *            memcpy(dst_data, src_data, itemsize * dst_extent)
 */
      goto __pyx_L4;
    }

    /* "View.MemoryView":1142
 *            memcpy(dst_data, src_data, itemsize * dst_extent)
 *        else:
 *            for i in range(dst_extent):             # <<<<<<<<<<<<<<
 *                memcpy(dst_data, src_data, itemsize)
 *                src_data += src_stride
 */
    /*else*/ {
      __pyx_t_4 = __pyx_v_dst_extent;
      for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
        __pyx_v_i = __pyx_t_5;

        /* "View.MemoryView":1143
 *        else:
 *            for i in range(dst_extent):
 *                memcpy(dst_data, src_data, itemsize)             # <<<<<<<<<<<<<<
 *                src_data += src_stride
 *                dst_data += dst_stride
 */
        memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize);

        /* "View.MemoryView":1144
 *            for i in range(dst_extent):
 *                memcpy(dst_data, src_data, itemsize)
 *                src_data += src_stride             # <<<<<<<<<<<<<<
 *                dst_data += dst_stride
 *     else:
 */
        __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);

        /* "View.MemoryView":1145
 *                memcpy(dst_data, src_data, itemsize)
 *                src_data += src_stride
 *                dst_data += dst_stride             # <<<<<<<<<<<<<<
 *     else:
 *         for i in range(dst_extent):
 */
        __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
      }
    }
    __pyx_L4:;

    /* "View.MemoryView":1137
 *     cdef Py_ssize_t dst_stride = dst_strides[0]
 * 
 *     if ndim == 1:             # <<<<<<<<<<<<<<
 *        if (src_stride > 0 and dst_stride > 0 and
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":1147
 *                dst_data += dst_stride
 *     else:
 *         for i in range(dst_extent):             # <<<<<<<<<<<<<<
 *             _copy_strided_to_strided(src_data, src_strides + 1,
 *                                      dst_data, dst_strides + 1,
 */
  /*else*/ {
    __pyx_t_4 = __pyx_v_dst_extent;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_i = __pyx_t_5;

      /* "View.MemoryView":1148
 *     else:
 *         for i in range(dst_extent):
 *             _copy_strided_to_strided(src_data, src_strides + 1,             # <<<<<<<<<<<<<<
 *                                      dst_data, dst_strides + 1,
 *                                      src_shape + 1, dst_shape + 1,
 */
      _copy_strided_to_strided(__pyx_v_src_data, (__pyx_v_src_strides + 1), __pyx_v_dst_data, (__pyx_v_dst_strides + 1), (__pyx_v_src_shape + 1), (__pyx_v_dst_shape + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize);

      /* "View.MemoryView":1152
 *                                      src_shape + 1, dst_shape + 1,
 *                                      ndim - 1, itemsize)
 *             src_data += src_stride             # <<<<<<<<<<<<<<
 *             dst_data += dst_stride
 * 
 */
      __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);

      /* "View.MemoryView":1153
 *                                      ndim - 1, itemsize)
 *             src_data += src_stride
 *             dst_data += dst_stride             # <<<<<<<<<<<<<<
 * 
 * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,
 */
      __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
    }
  }
  __pyx_L3:;

  /* "View.MemoryView":1125
 * 
 * @cython.cdivision(True)
 * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides,             # <<<<<<<<<<<<<<
 *                                    char *dst_data, Py_ssize_t *dst_strides,
 *                                    Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
 */

  /* function exit code */
}

/* "View.MemoryView":1155
 *             dst_data += dst_stride
 * 
 * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
 *                                   __Pyx_memviewslice *dst,
 *                                   int ndim, size_t itemsize) nogil:
 */

static void copy_strided_to_strided(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize) {

  /* "View.MemoryView":1158
 *                                   __Pyx_memviewslice *dst,
 *                                   int ndim, size_t itemsize) nogil:
 *     _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides,             # <<<<<<<<<<<<<<
 *                              src.shape, dst.shape, ndim, itemsize)
 * 
 */
  _copy_strided_to_strided(__pyx_v_src->data, __pyx_v_src->strides, __pyx_v_dst->data, __pyx_v_dst->strides, __pyx_v_src->shape, __pyx_v_dst->shape, __pyx_v_ndim, __pyx_v_itemsize);

  /* "View.MemoryView":1155
 *             dst_data += dst_stride
 * 
 * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
 *                                   __Pyx_memviewslice *dst,
 *                                   int ndim, size_t itemsize) nogil:
 */

  /* function exit code */
}

/* "View.MemoryView":1162
 * 
 * @cname('__pyx_memoryview_slice_get_size')
 * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:             # <<<<<<<<<<<<<<
 *     "Return the size of the memory occupied by the slice in number of bytes"
 *     cdef int i
 */

static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) {
  int __pyx_v_i;
  Py_ssize_t __pyx_v_size;
  Py_ssize_t __pyx_r;
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;

  /* "View.MemoryView":1165
 *     "Return the size of the memory occupied by the slice in number of bytes"
 *     cdef int i
 *     cdef Py_ssize_t size = src.memview.view.itemsize             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim):
 */
  __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
  __pyx_v_size = __pyx_t_1;

  /* "View.MemoryView":1167
 *     cdef Py_ssize_t size = src.memview.view.itemsize
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         size *= src.shape[i]
 * 
 */
  __pyx_t_2 = __pyx_v_ndim;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "View.MemoryView":1168
 * 
 *     for i in range(ndim):
 *         size *= src.shape[i]             # <<<<<<<<<<<<<<
 * 
 *     return size
 */
    __pyx_v_size = (__pyx_v_size * (__pyx_v_src->shape[__pyx_v_i]));
  }

  /* "View.MemoryView":1170
 *         size *= src.shape[i]
 * 
 *     return size             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_fill_contig_strides_array')
 */
  __pyx_r = __pyx_v_size;
  goto __pyx_L0;

  /* "View.MemoryView":1162
 * 
 * @cname('__pyx_memoryview_slice_get_size')
 * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:             # <<<<<<<<<<<<<<
 *     "Return the size of the memory occupied by the slice in number of bytes"
 *     cdef int i
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1173
 * 
 * @cname('__pyx_fill_contig_strides_array')
 * cdef Py_ssize_t fill_contig_strides_array(             # <<<<<<<<<<<<<<
 *                 Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
 *                 int ndim, char order) nogil:
 */

static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, Py_ssize_t __pyx_v_stride, int __pyx_v_ndim, char __pyx_v_order) {
  int __pyx_v_idx;
  Py_ssize_t __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;

  /* "View.MemoryView":1182
 *     cdef int idx
 * 
 *     if order == 'F':             # <<<<<<<<<<<<<<
 *         for idx in range(ndim):
 *             strides[idx] = stride
 */
  __pyx_t_1 = ((__pyx_v_order == 'F') != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1183
 * 
 *     if order == 'F':
 *         for idx in range(ndim):             # <<<<<<<<<<<<<<
 *             strides[idx] = stride
 *             stride = stride * shape[idx]
 */
    __pyx_t_2 = __pyx_v_ndim;
    for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
      __pyx_v_idx = __pyx_t_3;

      /* "View.MemoryView":1184
 *     if order == 'F':
 *         for idx in range(ndim):
 *             strides[idx] = stride             # <<<<<<<<<<<<<<
 *             stride = stride * shape[idx]
 *     else:
 */
      (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;

      /* "View.MemoryView":1185
 *         for idx in range(ndim):
 *             strides[idx] = stride
 *             stride = stride * shape[idx]             # <<<<<<<<<<<<<<
 *     else:
 *         for idx in range(ndim - 1, -1, -1):
 */
      __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
    }

    /* "View.MemoryView":1182
 *     cdef int idx
 * 
 *     if order == 'F':             # <<<<<<<<<<<<<<
 *         for idx in range(ndim):
 *             strides[idx] = stride
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":1187
 *             stride = stride * shape[idx]
 *     else:
 *         for idx in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
 *             strides[idx] = stride
 *             stride = stride * shape[idx]
 */
  /*else*/ {
    for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1L; __pyx_t_2-=1) {
      __pyx_v_idx = __pyx_t_2;

      /* "View.MemoryView":1188
 *     else:
 *         for idx in range(ndim - 1, -1, -1):
 *             strides[idx] = stride             # <<<<<<<<<<<<<<
 *             stride = stride * shape[idx]
 * 
 */
      (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;

      /* "View.MemoryView":1189
 *         for idx in range(ndim - 1, -1, -1):
 *             strides[idx] = stride
 *             stride = stride * shape[idx]             # <<<<<<<<<<<<<<
 * 
 *     return stride
 */
      __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
    }
  }
  __pyx_L3:;

  /* "View.MemoryView":1191
 *             stride = stride * shape[idx]
 * 
 *     return stride             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_copy_data_to_temp')
 */
  __pyx_r = __pyx_v_stride;
  goto __pyx_L0;

  /* "View.MemoryView":1173
 * 
 * @cname('__pyx_fill_contig_strides_array')
 * cdef Py_ssize_t fill_contig_strides_array(             # <<<<<<<<<<<<<<
 *                 Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
 *                 int ndim, char order) nogil:
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1194
 * 
 * @cname('__pyx_memoryview_copy_data_to_temp')
 * cdef void *copy_data_to_temp(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
 *                              __Pyx_memviewslice *tmpslice,
 *                              char order,
 */

static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_tmpslice, char __pyx_v_order, int __pyx_v_ndim) {
  int __pyx_v_i;
  void *__pyx_v_result;
  size_t __pyx_v_itemsize;
  size_t __pyx_v_size;
  void *__pyx_r;
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  struct __pyx_memoryview_obj *__pyx_t_4;
  int __pyx_t_5;

  /* "View.MemoryView":1205
 *     cdef void *result
 * 
 *     cdef size_t itemsize = src.memview.view.itemsize             # <<<<<<<<<<<<<<
 *     cdef size_t size = slice_get_size(src, ndim)
 * 
 */
  __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
  __pyx_v_itemsize = __pyx_t_1;

  /* "View.MemoryView":1206
 * 
 *     cdef size_t itemsize = src.memview.view.itemsize
 *     cdef size_t size = slice_get_size(src, ndim)             # <<<<<<<<<<<<<<
 * 
 *     result = malloc(size)
 */
  __pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim);

  /* "View.MemoryView":1208
 *     cdef size_t size = slice_get_size(src, ndim)
 * 
 *     result = malloc(size)             # <<<<<<<<<<<<<<
 *     if not result:
 *         _err(MemoryError, NULL)
 */
  __pyx_v_result = malloc(__pyx_v_size);

  /* "View.MemoryView":1209
 * 
 *     result = malloc(size)
 *     if not result:             # <<<<<<<<<<<<<<
 *         _err(MemoryError, NULL)
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_result != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1210
 *     result = malloc(size)
 *     if not result:
 *         _err(MemoryError, NULL)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(4, 1210, __pyx_L1_error)

    /* "View.MemoryView":1209
 * 
 *     result = malloc(size)
 *     if not result:             # <<<<<<<<<<<<<<
 *         _err(MemoryError, NULL)
 * 
 */
  }

  /* "View.MemoryView":1213
 * 
 * 
 *     tmpslice.data = <char *> result             # <<<<<<<<<<<<<<
 *     tmpslice.memview = src.memview
 *     for i in range(ndim):
 */
  __pyx_v_tmpslice->data = ((char *)__pyx_v_result);

  /* "View.MemoryView":1214
 * 
 *     tmpslice.data = <char *> result
 *     tmpslice.memview = src.memview             # <<<<<<<<<<<<<<
 *     for i in range(ndim):
 *         tmpslice.shape[i] = src.shape[i]
 */
  __pyx_t_4 = __pyx_v_src->memview;
  __pyx_v_tmpslice->memview = __pyx_t_4;

  /* "View.MemoryView":1215
 *     tmpslice.data = <char *> result
 *     tmpslice.memview = src.memview
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         tmpslice.shape[i] = src.shape[i]
 *         tmpslice.suboffsets[i] = -1
 */
  __pyx_t_3 = __pyx_v_ndim;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "View.MemoryView":1216
 *     tmpslice.memview = src.memview
 *     for i in range(ndim):
 *         tmpslice.shape[i] = src.shape[i]             # <<<<<<<<<<<<<<
 *         tmpslice.suboffsets[i] = -1
 * 
 */
    (__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]);

    /* "View.MemoryView":1217
 *     for i in range(ndim):
 *         tmpslice.shape[i] = src.shape[i]
 *         tmpslice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
 * 
 *     fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,
 */
    (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1L;
  }

  /* "View.MemoryView":1219
 *         tmpslice.suboffsets[i] = -1
 * 
 *     fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,             # <<<<<<<<<<<<<<
 *                               ndim, order)
 * 
 */
  __pyx_fill_contig_strides_array((&(__pyx_v_tmpslice->shape[0])), (&(__pyx_v_tmpslice->strides[0])), __pyx_v_itemsize, __pyx_v_ndim, __pyx_v_order);

  /* "View.MemoryView":1223
 * 
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         if tmpslice.shape[i] == 1:
 *             tmpslice.strides[i] = 0
 */
  __pyx_t_3 = __pyx_v_ndim;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "View.MemoryView":1224
 * 
 *     for i in range(ndim):
 *         if tmpslice.shape[i] == 1:             # <<<<<<<<<<<<<<
 *             tmpslice.strides[i] = 0
 * 
 */
    __pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1225
 *     for i in range(ndim):
 *         if tmpslice.shape[i] == 1:
 *             tmpslice.strides[i] = 0             # <<<<<<<<<<<<<<
 * 
 *     if slice_is_contig(src[0], order, ndim):
 */
      (__pyx_v_tmpslice->strides[__pyx_v_i]) = 0;

      /* "View.MemoryView":1224
 * 
 *     for i in range(ndim):
 *         if tmpslice.shape[i] == 1:             # <<<<<<<<<<<<<<
 *             tmpslice.strides[i] = 0
 * 
 */
    }
  }

  /* "View.MemoryView":1227
 *             tmpslice.strides[i] = 0
 * 
 *     if slice_is_contig(src[0], order, ndim):             # <<<<<<<<<<<<<<
 *         memcpy(result, src.data, size)
 *     else:
 */
  __pyx_t_2 = (__pyx_memviewslice_is_contig((__pyx_v_src[0]), __pyx_v_order, __pyx_v_ndim) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1228
 * 
 *     if slice_is_contig(src[0], order, ndim):
 *         memcpy(result, src.data, size)             # <<<<<<<<<<<<<<
 *     else:
 *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
 */
    memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size);

    /* "View.MemoryView":1227
 *             tmpslice.strides[i] = 0
 * 
 *     if slice_is_contig(src[0], order, ndim):             # <<<<<<<<<<<<<<
 *         memcpy(result, src.data, size)
 *     else:
 */
    goto __pyx_L9;
  }

  /* "View.MemoryView":1230
 *         memcpy(result, src.data, size)
 *     else:
 *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)             # <<<<<<<<<<<<<<
 * 
 *     return result
 */
  /*else*/ {
    copy_strided_to_strided(__pyx_v_src, __pyx_v_tmpslice, __pyx_v_ndim, __pyx_v_itemsize);
  }
  __pyx_L9:;

  /* "View.MemoryView":1232
 *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
 * 
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "View.MemoryView":1194
 * 
 * @cname('__pyx_memoryview_copy_data_to_temp')
 * cdef void *copy_data_to_temp(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
 *                              __Pyx_memviewslice *tmpslice,
 *                              char order,
 */

  /* function exit code */
  __pyx_L1_error:;
  {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
    #endif
    __Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename);
    #ifdef WITH_THREAD
    __Pyx_PyGILState_Release(__pyx_gilstate_save);
    #endif
  }
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1237
 * 
 * @cname('__pyx_memoryview_err_extents')
 * cdef int _err_extents(int i, Py_ssize_t extent1,             # <<<<<<<<<<<<<<
 *                              Py_ssize_t extent2) except -1 with gil:
 *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
 */

static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent1, Py_ssize_t __pyx_v_extent2) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_err_extents", 0);

  /* "View.MemoryView":1240
 *                              Py_ssize_t extent2) except -1 with gil:
 *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
 *                                                         (i, extent1, extent2))             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_err_dim')
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 1240, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 1240, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 1240, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 1240, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;

  /* "View.MemoryView":1239
 * cdef int _err_extents(int i, Py_ssize_t extent1,
 *                              Py_ssize_t extent2) except -1 with gil:
 *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %             # <<<<<<<<<<<<<<
 *                                                         (i, extent1, extent2))
 * 
 */
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 1239, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 1239, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 1239, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __PYX_ERR(4, 1239, __pyx_L1_error)

  /* "View.MemoryView":1237
 * 
 * @cname('__pyx_memoryview_err_extents')
 * cdef int _err_extents(int i, Py_ssize_t extent1,             # <<<<<<<<<<<<<<
 *                              Py_ssize_t extent2) except -1 with gil:
 *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("View.MemoryView._err_extents", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "View.MemoryView":1243
 * 
 * @cname('__pyx_memoryview_err_dim')
 * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:             # <<<<<<<<<<<<<<
 *     raise error(msg.decode('ascii') % dim)
 * 
 */

static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, int __pyx_v_dim) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_err_dim", 0);
  __Pyx_INCREF(__pyx_v_error);

  /* "View.MemoryView":1244
 * @cname('__pyx_memoryview_err_dim')
 * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:
 *     raise error(msg.decode('ascii') % dim)             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_err')
 */
  __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 1244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 1244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 1244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_error);
  __pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 1244, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 1244, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 1244, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 1244, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 1244, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(4, 1244, __pyx_L1_error)

  /* "View.MemoryView":1243
 * 
 * @cname('__pyx_memoryview_err_dim')
 * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:             # <<<<<<<<<<<<<<
 *     raise error(msg.decode('ascii') % dim)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_XDECREF(__pyx_v_error);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "View.MemoryView":1247
 * 
 * @cname('__pyx_memoryview_err')
 * cdef int _err(object error, char *msg) except -1 with gil:             # <<<<<<<<<<<<<<
 *     if msg != NULL:
 *         raise error(msg.decode('ascii'))
 */

static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_err", 0);
  __Pyx_INCREF(__pyx_v_error);

  /* "View.MemoryView":1248
 * @cname('__pyx_memoryview_err')
 * cdef int _err(object error, char *msg) except -1 with gil:
 *     if msg != NULL:             # <<<<<<<<<<<<<<
 *         raise error(msg.decode('ascii'))
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_msg != NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1249
 * cdef int _err(object error, char *msg) except -1 with gil:
 *     if msg != NULL:
 *         raise error(msg.decode('ascii'))             # <<<<<<<<<<<<<<
 *     else:
 *         raise error
 */
    __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 1249, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_error);
    __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 1249, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 1249, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 1249, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 1249, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 1249, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(4, 1249, __pyx_L1_error)

    /* "View.MemoryView":1248
 * @cname('__pyx_memoryview_err')
 * cdef int _err(object error, char *msg) except -1 with gil:
 *     if msg != NULL:             # <<<<<<<<<<<<<<
 *         raise error(msg.decode('ascii'))
 *     else:
 */
  }

  /* "View.MemoryView":1251
 *         raise error(msg.decode('ascii'))
 *     else:
 *         raise error             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_copy_contents')
 */
  /*else*/ {
    __Pyx_Raise(__pyx_v_error, 0, 0, 0);
    __PYX_ERR(4, 1251, __pyx_L1_error)
  }

  /* "View.MemoryView":1247
 * 
 * @cname('__pyx_memoryview_err')
 * cdef int _err(object error, char *msg) except -1 with gil:             # <<<<<<<<<<<<<<
 *     if msg != NULL:
 *         raise error(msg.decode('ascii'))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_XDECREF(__pyx_v_error);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "View.MemoryView":1254
 * 
 * @cname('__pyx_memoryview_copy_contents')
 * cdef int memoryview_copy_contents(__Pyx_memviewslice src,             # <<<<<<<<<<<<<<
 *                                   __Pyx_memviewslice dst,
 *                                   int src_ndim, int dst_ndim,
 */

static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_memviewslice __pyx_v_dst, int __pyx_v_src_ndim, int __pyx_v_dst_ndim, int __pyx_v_dtype_is_object) {
  void *__pyx_v_tmpdata;
  size_t __pyx_v_itemsize;
  int __pyx_v_i;
  char __pyx_v_order;
  int __pyx_v_broadcasting;
  int __pyx_v_direct_copy;
  __Pyx_memviewslice __pyx_v_tmp;
  int __pyx_v_ndim;
  int __pyx_r;
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  void *__pyx_t_6;
  int __pyx_t_7;

  /* "View.MemoryView":1262
 *     Check for overlapping memory and verify the shapes.
 *     """
 *     cdef void *tmpdata = NULL             # <<<<<<<<<<<<<<
 *     cdef size_t itemsize = src.memview.view.itemsize
 *     cdef int i
 */
  __pyx_v_tmpdata = NULL;

  /* "View.MemoryView":1263
 *     """
 *     cdef void *tmpdata = NULL
 *     cdef size_t itemsize = src.memview.view.itemsize             # <<<<<<<<<<<<<<
 *     cdef int i
 *     cdef char order = get_best_order(&src, src_ndim)
 */
  __pyx_t_1 = __pyx_v_src.memview->view.itemsize;
  __pyx_v_itemsize = __pyx_t_1;

  /* "View.MemoryView":1265
 *     cdef size_t itemsize = src.memview.view.itemsize
 *     cdef int i
 *     cdef char order = get_best_order(&src, src_ndim)             # <<<<<<<<<<<<<<
 *     cdef bint broadcasting = False
 *     cdef bint direct_copy = False
 */
  __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim);

  /* "View.MemoryView":1266
 *     cdef int i
 *     cdef char order = get_best_order(&src, src_ndim)
 *     cdef bint broadcasting = False             # <<<<<<<<<<<<<<
 *     cdef bint direct_copy = False
 *     cdef __Pyx_memviewslice tmp
 */
  __pyx_v_broadcasting = 0;

  /* "View.MemoryView":1267
 *     cdef char order = get_best_order(&src, src_ndim)
 *     cdef bint broadcasting = False
 *     cdef bint direct_copy = False             # <<<<<<<<<<<<<<
 *     cdef __Pyx_memviewslice tmp
 * 
 */
  __pyx_v_direct_copy = 0;

  /* "View.MemoryView":1270
 *     cdef __Pyx_memviewslice tmp
 * 
 *     if src_ndim < dst_ndim:             # <<<<<<<<<<<<<<
 *         broadcast_leading(&src, src_ndim, dst_ndim)
 *     elif dst_ndim < src_ndim:
 */
  __pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1271
 * 
 *     if src_ndim < dst_ndim:
 *         broadcast_leading(&src, src_ndim, dst_ndim)             # <<<<<<<<<<<<<<
 *     elif dst_ndim < src_ndim:
 *         broadcast_leading(&dst, dst_ndim, src_ndim)
 */
    __pyx_memoryview_broadcast_leading((&__pyx_v_src), __pyx_v_src_ndim, __pyx_v_dst_ndim);

    /* "View.MemoryView":1270
 *     cdef __Pyx_memviewslice tmp
 * 
 *     if src_ndim < dst_ndim:             # <<<<<<<<<<<<<<
 *         broadcast_leading(&src, src_ndim, dst_ndim)
 *     elif dst_ndim < src_ndim:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":1272
 *     if src_ndim < dst_ndim:
 *         broadcast_leading(&src, src_ndim, dst_ndim)
 *     elif dst_ndim < src_ndim:             # <<<<<<<<<<<<<<
 *         broadcast_leading(&dst, dst_ndim, src_ndim)
 * 
 */
  __pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1273
 *         broadcast_leading(&src, src_ndim, dst_ndim)
 *     elif dst_ndim < src_ndim:
 *         broadcast_leading(&dst, dst_ndim, src_ndim)             # <<<<<<<<<<<<<<
 * 
 *     cdef int ndim = max(src_ndim, dst_ndim)
 */
    __pyx_memoryview_broadcast_leading((&__pyx_v_dst), __pyx_v_dst_ndim, __pyx_v_src_ndim);

    /* "View.MemoryView":1272
 *     if src_ndim < dst_ndim:
 *         broadcast_leading(&src, src_ndim, dst_ndim)
 *     elif dst_ndim < src_ndim:             # <<<<<<<<<<<<<<
 *         broadcast_leading(&dst, dst_ndim, src_ndim)
 * 
 */
  }
  __pyx_L3:;

  /* "View.MemoryView":1275
 *         broadcast_leading(&dst, dst_ndim, src_ndim)
 * 
 *     cdef int ndim = max(src_ndim, dst_ndim)             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim):
 */
  __pyx_t_3 = __pyx_v_dst_ndim;
  __pyx_t_4 = __pyx_v_src_ndim;
  if (((__pyx_t_3 > __pyx_t_4) != 0)) {
    __pyx_t_5 = __pyx_t_3;
  } else {
    __pyx_t_5 = __pyx_t_4;
  }
  __pyx_v_ndim = __pyx_t_5;

  /* "View.MemoryView":1277
 *     cdef int ndim = max(src_ndim, dst_ndim)
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         if src.shape[i] != dst.shape[i]:
 *             if src.shape[i] == 1:
 */
  __pyx_t_5 = __pyx_v_ndim;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_5; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "View.MemoryView":1278
 * 
 *     for i in range(ndim):
 *         if src.shape[i] != dst.shape[i]:             # <<<<<<<<<<<<<<
 *             if src.shape[i] == 1:
 *                 broadcasting = True
 */
    __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1279
 *     for i in range(ndim):
 *         if src.shape[i] != dst.shape[i]:
 *             if src.shape[i] == 1:             # <<<<<<<<<<<<<<
 *                 broadcasting = True
 *                 src.strides[i] = 0
 */
      __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":1280
 *         if src.shape[i] != dst.shape[i]:
 *             if src.shape[i] == 1:
 *                 broadcasting = True             # <<<<<<<<<<<<<<
 *                 src.strides[i] = 0
 *             else:
 */
        __pyx_v_broadcasting = 1;

        /* "View.MemoryView":1281
 *             if src.shape[i] == 1:
 *                 broadcasting = True
 *                 src.strides[i] = 0             # <<<<<<<<<<<<<<
 *             else:
 *                 _err_extents(i, dst.shape[i], src.shape[i])
 */
        (__pyx_v_src.strides[__pyx_v_i]) = 0;

        /* "View.MemoryView":1279
 *     for i in range(ndim):
 *         if src.shape[i] != dst.shape[i]:
 *             if src.shape[i] == 1:             # <<<<<<<<<<<<<<
 *                 broadcasting = True
 *                 src.strides[i] = 0
 */
        goto __pyx_L7;
      }

      /* "View.MemoryView":1283
 *                 src.strides[i] = 0
 *             else:
 *                 _err_extents(i, dst.shape[i], src.shape[i])             # <<<<<<<<<<<<<<
 * 
 *         if src.suboffsets[i] >= 0:
 */
      /*else*/ {
        __pyx_t_4 = __pyx_memoryview_err_extents(__pyx_v_i, (__pyx_v_dst.shape[__pyx_v_i]), (__pyx_v_src.shape[__pyx_v_i])); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(4, 1283, __pyx_L1_error)
      }
      __pyx_L7:;

      /* "View.MemoryView":1278
 * 
 *     for i in range(ndim):
 *         if src.shape[i] != dst.shape[i]:             # <<<<<<<<<<<<<<
 *             if src.shape[i] == 1:
 *                 broadcasting = True
 */
    }

    /* "View.MemoryView":1285
 *                 _err_extents(i, dst.shape[i], src.shape[i])
 * 
 *         if src.suboffsets[i] >= 0:             # <<<<<<<<<<<<<<
 *             _err_dim(ValueError, "Dimension %d is not direct", i)
 * 
 */
    __pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1286
 * 
 *         if src.suboffsets[i] >= 0:
 *             _err_dim(ValueError, "Dimension %d is not direct", i)             # <<<<<<<<<<<<<<
 * 
 *     if slices_overlap(&src, &dst, ndim, itemsize):
 */
      __pyx_t_4 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Dimension %d is not direct"), __pyx_v_i); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(4, 1286, __pyx_L1_error)

      /* "View.MemoryView":1285
 *                 _err_extents(i, dst.shape[i], src.shape[i])
 * 
 *         if src.suboffsets[i] >= 0:             # <<<<<<<<<<<<<<
 *             _err_dim(ValueError, "Dimension %d is not direct", i)
 * 
 */
    }
  }

  /* "View.MemoryView":1288
 *             _err_dim(ValueError, "Dimension %d is not direct", i)
 * 
 *     if slices_overlap(&src, &dst, ndim, itemsize):             # <<<<<<<<<<<<<<
 * 
 *         if not slice_is_contig(src, order, ndim):
 */
  __pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1290
 *     if slices_overlap(&src, &dst, ndim, itemsize):
 * 
 *         if not slice_is_contig(src, order, ndim):             # <<<<<<<<<<<<<<
 *             order = get_best_order(&dst, ndim)
 * 
 */
    __pyx_t_2 = ((!(__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1291
 * 
 *         if not slice_is_contig(src, order, ndim):
 *             order = get_best_order(&dst, ndim)             # <<<<<<<<<<<<<<
 * 
 *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
 */
      __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim);

      /* "View.MemoryView":1290
 *     if slices_overlap(&src, &dst, ndim, itemsize):
 * 
 *         if not slice_is_contig(src, order, ndim):             # <<<<<<<<<<<<<<
 *             order = get_best_order(&dst, ndim)
 * 
 */
    }

    /* "View.MemoryView":1293
 *             order = get_best_order(&dst, ndim)
 * 
 *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)             # <<<<<<<<<<<<<<
 *         src = tmp
 * 
 */
    __pyx_t_6 = __pyx_memoryview_copy_data_to_temp((&__pyx_v_src), (&__pyx_v_tmp), __pyx_v_order, __pyx_v_ndim); if (unlikely(__pyx_t_6 == NULL)) __PYX_ERR(4, 1293, __pyx_L1_error)
    __pyx_v_tmpdata = __pyx_t_6;

    /* "View.MemoryView":1294
 * 
 *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
 *         src = tmp             # <<<<<<<<<<<<<<
 * 
 *     if not broadcasting:
 */
    __pyx_v_src = __pyx_v_tmp;

    /* "View.MemoryView":1288
 *             _err_dim(ValueError, "Dimension %d is not direct", i)
 * 
 *     if slices_overlap(&src, &dst, ndim, itemsize):             # <<<<<<<<<<<<<<
 * 
 *         if not slice_is_contig(src, order, ndim):
 */
  }

  /* "View.MemoryView":1296
 *         src = tmp
 * 
 *     if not broadcasting:             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1299
 * 
 * 
 *         if slice_is_contig(src, 'C', ndim):             # <<<<<<<<<<<<<<
 *             direct_copy = slice_is_contig(dst, 'C', ndim)
 *         elif slice_is_contig(src, 'F', ndim):
 */
    __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'C', __pyx_v_ndim) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1300
 * 
 *         if slice_is_contig(src, 'C', ndim):
 *             direct_copy = slice_is_contig(dst, 'C', ndim)             # <<<<<<<<<<<<<<
 *         elif slice_is_contig(src, 'F', ndim):
 *             direct_copy = slice_is_contig(dst, 'F', ndim)
 */
      __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'C', __pyx_v_ndim);

      /* "View.MemoryView":1299
 * 
 * 
 *         if slice_is_contig(src, 'C', ndim):             # <<<<<<<<<<<<<<
 *             direct_copy = slice_is_contig(dst, 'C', ndim)
 *         elif slice_is_contig(src, 'F', ndim):
 */
      goto __pyx_L12;
    }

    /* "View.MemoryView":1301
 *         if slice_is_contig(src, 'C', ndim):
 *             direct_copy = slice_is_contig(dst, 'C', ndim)
 *         elif slice_is_contig(src, 'F', ndim):             # <<<<<<<<<<<<<<
 *             direct_copy = slice_is_contig(dst, 'F', ndim)
 * 
 */
    __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'F', __pyx_v_ndim) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1302
 *             direct_copy = slice_is_contig(dst, 'C', ndim)
 *         elif slice_is_contig(src, 'F', ndim):
 *             direct_copy = slice_is_contig(dst, 'F', ndim)             # <<<<<<<<<<<<<<
 * 
 *         if direct_copy:
 */
      __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'F', __pyx_v_ndim);

      /* "View.MemoryView":1301
 *         if slice_is_contig(src, 'C', ndim):
 *             direct_copy = slice_is_contig(dst, 'C', ndim)
 *         elif slice_is_contig(src, 'F', ndim):             # <<<<<<<<<<<<<<
 *             direct_copy = slice_is_contig(dst, 'F', ndim)
 * 
 */
    }
    __pyx_L12:;

    /* "View.MemoryView":1304
 *             direct_copy = slice_is_contig(dst, 'F', ndim)
 * 
 *         if direct_copy:             # <<<<<<<<<<<<<<
 * 
 *             refcount_copying(&dst, dtype_is_object, ndim, False)
 */
    __pyx_t_2 = (__pyx_v_direct_copy != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1306
 *         if direct_copy:
 * 
 *             refcount_copying(&dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
 *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
 *             refcount_copying(&dst, dtype_is_object, ndim, True)
 */
      __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);

      /* "View.MemoryView":1307
 * 
 *             refcount_copying(&dst, dtype_is_object, ndim, False)
 *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))             # <<<<<<<<<<<<<<
 *             refcount_copying(&dst, dtype_is_object, ndim, True)
 *             free(tmpdata)
 */
      memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim));

      /* "View.MemoryView":1308
 *             refcount_copying(&dst, dtype_is_object, ndim, False)
 *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
 *             refcount_copying(&dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
 *             free(tmpdata)
 *             return 0
 */
      __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);

      /* "View.MemoryView":1309
 *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
 *             refcount_copying(&dst, dtype_is_object, ndim, True)
 *             free(tmpdata)             # <<<<<<<<<<<<<<
 *             return 0
 * 
 */
      free(__pyx_v_tmpdata);

      /* "View.MemoryView":1310
 *             refcount_copying(&dst, dtype_is_object, ndim, True)
 *             free(tmpdata)
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *     if order == 'F' == get_best_order(&dst, ndim):
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "View.MemoryView":1304
 *             direct_copy = slice_is_contig(dst, 'F', ndim)
 * 
 *         if direct_copy:             # <<<<<<<<<<<<<<
 * 
 *             refcount_copying(&dst, dtype_is_object, ndim, False)
 */
    }

    /* "View.MemoryView":1296
 *         src = tmp
 * 
 *     if not broadcasting:             # <<<<<<<<<<<<<<
 * 
 * 
 */
  }

  /* "View.MemoryView":1312
 *             return 0
 * 
 *     if order == 'F' == get_best_order(&dst, ndim):             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = (__pyx_v_order == 'F');
  if (__pyx_t_2) {
    __pyx_t_2 = ('F' == __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim));
  }
  __pyx_t_7 = (__pyx_t_2 != 0);
  if (__pyx_t_7) {

    /* "View.MemoryView":1315
 * 
 * 
 *         transpose_memslice(&src)             # <<<<<<<<<<<<<<
 *         transpose_memslice(&dst)
 * 
 */
    __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == 0)) __PYX_ERR(4, 1315, __pyx_L1_error)

    /* "View.MemoryView":1316
 * 
 *         transpose_memslice(&src)
 *         transpose_memslice(&dst)             # <<<<<<<<<<<<<<
 * 
 *     refcount_copying(&dst, dtype_is_object, ndim, False)
 */
    __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == 0)) __PYX_ERR(4, 1316, __pyx_L1_error)

    /* "View.MemoryView":1312
 *             return 0
 * 
 *     if order == 'F' == get_best_order(&dst, ndim):             # <<<<<<<<<<<<<<
 * 
 * 
 */
  }

  /* "View.MemoryView":1318
 *         transpose_memslice(&dst)
 * 
 *     refcount_copying(&dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
 *     copy_strided_to_strided(&src, &dst, ndim, itemsize)
 *     refcount_copying(&dst, dtype_is_object, ndim, True)
 */
  __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);

  /* "View.MemoryView":1319
 * 
 *     refcount_copying(&dst, dtype_is_object, ndim, False)
 *     copy_strided_to_strided(&src, &dst, ndim, itemsize)             # <<<<<<<<<<<<<<
 *     refcount_copying(&dst, dtype_is_object, ndim, True)
 * 
 */
  copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize);

  /* "View.MemoryView":1320
 *     refcount_copying(&dst, dtype_is_object, ndim, False)
 *     copy_strided_to_strided(&src, &dst, ndim, itemsize)
 *     refcount_copying(&dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
 * 
 *     free(tmpdata)
 */
  __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);

  /* "View.MemoryView":1322
 *     refcount_copying(&dst, dtype_is_object, ndim, True)
 * 
 *     free(tmpdata)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
  free(__pyx_v_tmpdata);

  /* "View.MemoryView":1323
 * 
 *     free(tmpdata)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_broadcast_leading')
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "View.MemoryView":1254
 * 
 * @cname('__pyx_memoryview_copy_contents')
 * cdef int memoryview_copy_contents(__Pyx_memviewslice src,             # <<<<<<<<<<<<<<
 *                                   __Pyx_memviewslice dst,
 *                                   int src_ndim, int dst_ndim,
 */

  /* function exit code */
  __pyx_L1_error:;
  {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
    #endif
    __Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename);
    #ifdef WITH_THREAD
    __Pyx_PyGILState_Release(__pyx_gilstate_save);
    #endif
  }
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1326
 * 
 * @cname('__pyx_memoryview_broadcast_leading')
 * cdef void broadcast_leading(__Pyx_memviewslice *mslice,             # <<<<<<<<<<<<<<
 *                             int ndim,
 *                             int ndim_other) nogil:
 */

static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim, int __pyx_v_ndim_other) {
  int __pyx_v_i;
  int __pyx_v_offset;
  int __pyx_t_1;
  int __pyx_t_2;

  /* "View.MemoryView":1330
 *                             int ndim_other) nogil:
 *     cdef int i
 *     cdef int offset = ndim_other - ndim             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim - 1, -1, -1):
 */
  __pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim);

  /* "View.MemoryView":1332
 *     cdef int offset = ndim_other - ndim
 * 
 *     for i in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
 *         mslice.shape[i + offset] = mslice.shape[i]
 *         mslice.strides[i + offset] = mslice.strides[i]
 */
  for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1L; __pyx_t_1-=1) {
    __pyx_v_i = __pyx_t_1;

    /* "View.MemoryView":1333
 * 
 *     for i in range(ndim - 1, -1, -1):
 *         mslice.shape[i + offset] = mslice.shape[i]             # <<<<<<<<<<<<<<
 *         mslice.strides[i + offset] = mslice.strides[i]
 *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
 */
    (__pyx_v_mslice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->shape[__pyx_v_i]);

    /* "View.MemoryView":1334
 *     for i in range(ndim - 1, -1, -1):
 *         mslice.shape[i + offset] = mslice.shape[i]
 *         mslice.strides[i + offset] = mslice.strides[i]             # <<<<<<<<<<<<<<
 *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
 * 
 */
    (__pyx_v_mslice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->strides[__pyx_v_i]);

    /* "View.MemoryView":1335
 *         mslice.shape[i + offset] = mslice.shape[i]
 *         mslice.strides[i + offset] = mslice.strides[i]
 *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]             # <<<<<<<<<<<<<<
 * 
 *     for i in range(offset):
 */
    (__pyx_v_mslice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->suboffsets[__pyx_v_i]);
  }

  /* "View.MemoryView":1337
 *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
 * 
 *     for i in range(offset):             # <<<<<<<<<<<<<<
 *         mslice.shape[i] = 1
 *         mslice.strides[i] = mslice.strides[0]
 */
  __pyx_t_1 = __pyx_v_offset;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "View.MemoryView":1338
 * 
 *     for i in range(offset):
 *         mslice.shape[i] = 1             # <<<<<<<<<<<<<<
 *         mslice.strides[i] = mslice.strides[0]
 *         mslice.suboffsets[i] = -1
 */
    (__pyx_v_mslice->shape[__pyx_v_i]) = 1;

    /* "View.MemoryView":1339
 *     for i in range(offset):
 *         mslice.shape[i] = 1
 *         mslice.strides[i] = mslice.strides[0]             # <<<<<<<<<<<<<<
 *         mslice.suboffsets[i] = -1
 * 
 */
    (__pyx_v_mslice->strides[__pyx_v_i]) = (__pyx_v_mslice->strides[0]);

    /* "View.MemoryView":1340
 *         mslice.shape[i] = 1
 *         mslice.strides[i] = mslice.strides[0]
 *         mslice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
 * 
 * 
 */
    (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L;
  }

  /* "View.MemoryView":1326
 * 
 * @cname('__pyx_memoryview_broadcast_leading')
 * cdef void broadcast_leading(__Pyx_memviewslice *mslice,             # <<<<<<<<<<<<<<
 *                             int ndim,
 *                             int ndim_other) nogil:
 */

  /* function exit code */
}

/* "View.MemoryView":1348
 * 
 * @cname('__pyx_memoryview_refcount_copying')
 * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object,             # <<<<<<<<<<<<<<
 *                            int ndim, bint inc) nogil:
 * 
 */

static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_dtype_is_object, int __pyx_v_ndim, int __pyx_v_inc) {
  int __pyx_t_1;

  /* "View.MemoryView":1352
 * 
 * 
 *     if dtype_is_object:             # <<<<<<<<<<<<<<
 *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,
 *                                            dst.strides, ndim, inc)
 */
  __pyx_t_1 = (__pyx_v_dtype_is_object != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1353
 * 
 *     if dtype_is_object:
 *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,             # <<<<<<<<<<<<<<
 *                                            dst.strides, ndim, inc)
 * 
 */
    __pyx_memoryview_refcount_objects_in_slice_with_gil(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_inc);

    /* "View.MemoryView":1352
 * 
 * 
 *     if dtype_is_object:             # <<<<<<<<<<<<<<
 *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,
 *                                            dst.strides, ndim, inc)
 */
  }

  /* "View.MemoryView":1348
 * 
 * @cname('__pyx_memoryview_refcount_copying')
 * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object,             # <<<<<<<<<<<<<<
 *                            int ndim, bint inc) nogil:
 * 
 */

  /* function exit code */
}

/* "View.MemoryView":1357
 * 
 * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
 * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                                              Py_ssize_t *strides, int ndim,
 *                                              bint inc) with gil:
 */

static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) {
  __Pyx_RefNannyDeclarations
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0);

  /* "View.MemoryView":1360
 *                                              Py_ssize_t *strides, int ndim,
 *                                              bint inc) with gil:
 *     refcount_objects_in_slice(data, shape, strides, ndim, inc)             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_refcount_objects_in_slice')
 */
  __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc);

  /* "View.MemoryView":1357
 * 
 * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
 * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                                              Py_ssize_t *strides, int ndim,
 *                                              bint inc) with gil:
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
}

/* "View.MemoryView":1363
 * 
 * @cname('__pyx_memoryview_refcount_objects_in_slice')
 * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                                     Py_ssize_t *strides, int ndim, bint inc):
 *     cdef Py_ssize_t i
 */

static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) {
  CYTHON_UNUSED Py_ssize_t __pyx_v_i;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("refcount_objects_in_slice", 0);

  /* "View.MemoryView":1367
 *     cdef Py_ssize_t i
 * 
 *     for i in range(shape[0]):             # <<<<<<<<<<<<<<
 *         if ndim == 1:
 *             if inc:
 */
  __pyx_t_1 = (__pyx_v_shape[0]);
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "View.MemoryView":1368
 * 
 *     for i in range(shape[0]):
 *         if ndim == 1:             # <<<<<<<<<<<<<<
 *             if inc:
 *                 Py_INCREF((<PyObject **> data)[0])
 */
    __pyx_t_3 = ((__pyx_v_ndim == 1) != 0);
    if (__pyx_t_3) {

      /* "View.MemoryView":1369
 *     for i in range(shape[0]):
 *         if ndim == 1:
 *             if inc:             # <<<<<<<<<<<<<<
 *                 Py_INCREF((<PyObject **> data)[0])
 *             else:
 */
      __pyx_t_3 = (__pyx_v_inc != 0);
      if (__pyx_t_3) {

        /* "View.MemoryView":1370
 *         if ndim == 1:
 *             if inc:
 *                 Py_INCREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
 *             else:
 *                 Py_DECREF((<PyObject **> data)[0])
 */
        Py_INCREF((((PyObject **)__pyx_v_data)[0]));

        /* "View.MemoryView":1369
 *     for i in range(shape[0]):
 *         if ndim == 1:
 *             if inc:             # <<<<<<<<<<<<<<
 *                 Py_INCREF((<PyObject **> data)[0])
 *             else:
 */
        goto __pyx_L6;
      }

      /* "View.MemoryView":1372
 *                 Py_INCREF((<PyObject **> data)[0])
 *             else:
 *                 Py_DECREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
 *         else:
 *             refcount_objects_in_slice(data, shape + 1, strides + 1,
 */
      /*else*/ {
        Py_DECREF((((PyObject **)__pyx_v_data)[0]));
      }
      __pyx_L6:;

      /* "View.MemoryView":1368
 * 
 *     for i in range(shape[0]):
 *         if ndim == 1:             # <<<<<<<<<<<<<<
 *             if inc:
 *                 Py_INCREF((<PyObject **> data)[0])
 */
      goto __pyx_L5;
    }

    /* "View.MemoryView":1374
 *                 Py_DECREF((<PyObject **> data)[0])
 *         else:
 *             refcount_objects_in_slice(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
 *                                       ndim - 1, inc)
 * 
 */
    /*else*/ {

      /* "View.MemoryView":1375
 *         else:
 *             refcount_objects_in_slice(data, shape + 1, strides + 1,
 *                                       ndim - 1, inc)             # <<<<<<<<<<<<<<
 * 
 *         data += strides[0]
 */
      __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_inc);
    }
    __pyx_L5:;

    /* "View.MemoryView":1377
 *                                       ndim - 1, inc)
 * 
 *         data += strides[0]             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0]));
  }

  /* "View.MemoryView":1363
 * 
 * @cname('__pyx_memoryview_refcount_objects_in_slice')
 * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                                     Py_ssize_t *strides, int ndim, bint inc):
 *     cdef Py_ssize_t i
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "View.MemoryView":1383
 * 
 * @cname('__pyx_memoryview_slice_assign_scalar')
 * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim,             # <<<<<<<<<<<<<<
 *                               size_t itemsize, void *item,
 *                               bint dtype_is_object) nogil:
 */

static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item, int __pyx_v_dtype_is_object) {

  /* "View.MemoryView":1386
 *                               size_t itemsize, void *item,
 *                               bint dtype_is_object) nogil:
 *     refcount_copying(dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
 *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
 *                          itemsize, item)
 */
  __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0);

  /* "View.MemoryView":1387
 *                               bint dtype_is_object) nogil:
 *     refcount_copying(dst, dtype_is_object, ndim, False)
 *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,             # <<<<<<<<<<<<<<
 *                          itemsize, item)
 *     refcount_copying(dst, dtype_is_object, ndim, True)
 */
  __pyx_memoryview__slice_assign_scalar(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_itemsize, __pyx_v_item);

  /* "View.MemoryView":1389
 *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
 *                          itemsize, item)
 *     refcount_copying(dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1);

  /* "View.MemoryView":1383
 * 
 * @cname('__pyx_memoryview_slice_assign_scalar')
 * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim,             # <<<<<<<<<<<<<<
 *                               size_t itemsize, void *item,
 *                               bint dtype_is_object) nogil:
 */

  /* function exit code */
}

/* "View.MemoryView":1393
 * 
 * @cname('__pyx_memoryview__slice_assign_scalar')
 * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                               Py_ssize_t *strides, int ndim,
 *                               size_t itemsize, void *item) nogil:
 */

static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item) {
  CYTHON_UNUSED Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_stride;
  Py_ssize_t __pyx_v_extent;
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;

  /* "View.MemoryView":1397
 *                               size_t itemsize, void *item) nogil:
 *     cdef Py_ssize_t i
 *     cdef Py_ssize_t stride = strides[0]             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t extent = shape[0]
 * 
 */
  __pyx_v_stride = (__pyx_v_strides[0]);

  /* "View.MemoryView":1398
 *     cdef Py_ssize_t i
 *     cdef Py_ssize_t stride = strides[0]
 *     cdef Py_ssize_t extent = shape[0]             # <<<<<<<<<<<<<<
 * 
 *     if ndim == 1:
 */
  __pyx_v_extent = (__pyx_v_shape[0]);

  /* "View.MemoryView":1400
 *     cdef Py_ssize_t extent = shape[0]
 * 
 *     if ndim == 1:             # <<<<<<<<<<<<<<
 *         for i in range(extent):
 *             memcpy(data, item, itemsize)
 */
  __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1401
 * 
 *     if ndim == 1:
 *         for i in range(extent):             # <<<<<<<<<<<<<<
 *             memcpy(data, item, itemsize)
 *             data += stride
 */
    __pyx_t_2 = __pyx_v_extent;
    for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
      __pyx_v_i = __pyx_t_3;

      /* "View.MemoryView":1402
 *     if ndim == 1:
 *         for i in range(extent):
 *             memcpy(data, item, itemsize)             # <<<<<<<<<<<<<<
 *             data += stride
 *     else:
 */
      memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize);

      /* "View.MemoryView":1403
 *         for i in range(extent):
 *             memcpy(data, item, itemsize)
 *             data += stride             # <<<<<<<<<<<<<<
 *     else:
 *         for i in range(extent):
 */
      __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
    }

    /* "View.MemoryView":1400
 *     cdef Py_ssize_t extent = shape[0]
 * 
 *     if ndim == 1:             # <<<<<<<<<<<<<<
 *         for i in range(extent):
 *             memcpy(data, item, itemsize)
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":1405
 *             data += stride
 *     else:
 *         for i in range(extent):             # <<<<<<<<<<<<<<
 *             _slice_assign_scalar(data, shape + 1, strides + 1,
 *                                 ndim - 1, itemsize, item)
 */
  /*else*/ {
    __pyx_t_2 = __pyx_v_extent;
    for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
      __pyx_v_i = __pyx_t_3;

      /* "View.MemoryView":1406
 *     else:
 *         for i in range(extent):
 *             _slice_assign_scalar(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
 *                                 ndim - 1, itemsize, item)
 *             data += stride
 */
      __pyx_memoryview__slice_assign_scalar(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize, __pyx_v_item);

      /* "View.MemoryView":1408
 *             _slice_assign_scalar(data, shape + 1, strides + 1,
 *                                 ndim - 1, itemsize, item)
 *             data += stride             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
    }
  }
  __pyx_L3:;

  /* "View.MemoryView":1393
 * 
 * @cname('__pyx_memoryview__slice_assign_scalar')
 * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                               Py_ssize_t *strides, int ndim,
 *                               size_t itemsize, void *item) nogil:
 */

  /* function exit code */
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xb068931:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum = {"__pyx_unpickle_Enum", (PyCFunction)__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Enum (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 1); __PYX_ERR(4, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 2); __PYX_ERR(4, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Enum") < 0)) __PYX_ERR(4, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(4, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Enum", 0);

  /* "(tree fragment)":2
 * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xb068931:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xb068931) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xb068931:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
 *     __pyx_result = Enum.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0xb068931:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Enum.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xb0, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xb068931:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
 *     __pyx_result = Enum.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_MemviewEnum_type), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
 *     __pyx_result = Enum.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = Enum.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(4, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_unpickle_Enum__set_state(((struct __pyx_MemviewEnum_obj *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
 *     __pyx_result = Enum.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
 *     __pyx_result.name = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xb068931:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":9
 *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.name = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Enum__set_state", 0);

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
 *     __pyx_result.name = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->name);
  __Pyx_DECREF(__pyx_v___pyx_result->name);
  __pyx_v___pyx_result->name = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
 *     __pyx_result.name = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(4, 11, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(4, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(4, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":12
 *     __pyx_result.name = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(4, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
 *     __pyx_result.name = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.name = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_4cupy_4core_4core_ndarray __pyx_vtable_4cupy_4core_4core_ndarray;

static PyObject *__pyx_tp_new_4cupy_4core_4core_ndarray(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)o);
  p->__pyx_vtab = __pyx_vtabptr_4cupy_4core_4core_ndarray;
  new((void*)&(p->_shape)) std::vector<Py_ssize_t> ();
  new((void*)&(p->_strides)) std::vector<Py_ssize_t> ();
  p->dtype = Py_None; Py_INCREF(Py_None);
  p->data = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)Py_None); Py_INCREF(Py_None);
  p->base = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core_ndarray(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *p = (struct __pyx_obj_4cupy_4core_4core_ndarray *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  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);
  __Pyx_call_destructor(p->_shape);
  __Pyx_call_destructor(p->_strides);
  Py_CLEAR(p->dtype);
  Py_CLEAR(p->data);
  Py_CLEAR(p->base);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4cupy_4core_4core_ndarray(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core_ndarray *p = (struct __pyx_obj_4cupy_4core_4core_ndarray *)o;
  if (p->dtype) {
    e = (*v)(p->dtype, a); if (e) return e;
  }
  if (p->data) {
    e = (*v)(((PyObject *)p->data), a); if (e) return e;
  }
  if (p->base) {
    e = (*v)(((PyObject *)p->base), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core_ndarray(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core_ndarray *p = (struct __pyx_obj_4cupy_4core_4core_ndarray *)o;
  tmp = ((PyObject*)p->dtype);
  p->dtype = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->data);
  p->data = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->base);
  p->base = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_4cupy_4core_4core_ndarray(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_4cupy_4core_4core_ndarray(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_pw_4cupy_4core_4core_7ndarray_161__setitem__(o, i, v);
  }
  else {
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
    return -1;
  }
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_flags(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_5flags_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_shape(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_5shape_1__get__(o);
}

static int __pyx_setprop_4cupy_4core_4core_7ndarray_shape(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4cupy_4core_4core_7ndarray_5shape_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_strides(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_7strides_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_ndim(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_4ndim_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_itemsize(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_8itemsize_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_nbytes(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_6nbytes_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_T(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_1T_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_cstruct(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_7cstruct_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_real(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_4real_1__get__(o);
}

static int __pyx_setprop_4cupy_4core_4core_7ndarray_real(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4cupy_4core_4core_7ndarray_4real_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_imag(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_4imag_1__get__(o);
}

static int __pyx_setprop_4cupy_4core_4core_7ndarray_imag(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4cupy_4core_4core_7ndarray_4imag_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_device(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_6device_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_size(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_4size_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray__shape(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_6_shape_1__get__(o);
}

static int __pyx_setprop_4cupy_4core_4core_7ndarray__shape(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4cupy_4core_4core_7ndarray_6_shape_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray__strides(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_8_strides_1__get__(o);
}

static int __pyx_setprop_4cupy_4core_4core_7ndarray__strides(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4cupy_4core_4core_7ndarray_8_strides_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray__c_contiguous(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_13_c_contiguous_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray__f_contiguous(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_13_f_contiguous_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_dtype(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_5dtype_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_data(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_4data_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_base(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_4base_1__get__(o);
}

static PyMethodDef __pyx_methods_4cupy_4core_4core_ndarray[] = {
  {"tolist", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_3tolist, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_2tolist},
  {"tofile", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_5tofile, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_4tofile},
  {"dump", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_7dump, METH_O, __pyx_doc_4cupy_4core_4core_7ndarray_6dump},
  {"dumps", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_9dumps, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_8dumps},
  {"astype", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_11astype, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_10astype},
  {"copy", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_13copy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_12copy},
  {"view", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_15view, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_14view},
  {"fill", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_17fill, METH_O, __pyx_doc_4cupy_4core_4core_7ndarray_16fill},
  {"_reshape", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_19_reshape, METH_O, __pyx_doc_4cupy_4core_4core_7ndarray_18_reshape},
  {"reshape", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_21reshape, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_20reshape},
  {"_transpose", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_23_transpose, METH_O, __pyx_doc_4cupy_4core_4core_7ndarray_22_transpose},
  {"transpose", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_25transpose, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_24transpose},
  {"swapaxes", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_27swapaxes, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_26swapaxes},
  {"flatten", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_29flatten, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_28flatten},
  {"ravel", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_31ravel, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_30ravel},
  {"squeeze", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_33squeeze, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_32squeeze},
  {"take", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_35take, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_34take},
  {"repeat", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_37repeat, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_36repeat},
  {"choose", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_39choose, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_38choose},
  {"sort", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_41sort, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_40sort},
  {"argsort", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_43argsort, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_42argsort},
  {"partition", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_45partition, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_44partition},
  {"argpartition", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_47argpartition, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_46argpartition},
  {"nonzero", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_49nonzero, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_48nonzero},
  {"diagonal", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_51diagonal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_50diagonal},
  {"max", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_53max, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_52max},
  {"argmax", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_55argmax, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_54argmax},
  {"min", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_57min, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_56min},
  {"argmin", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_59argmin, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_58argmin},
  {"clip", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_61clip, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_60clip},
  {"trace", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_63trace, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_62trace},
  {"sum", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_65sum, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_64sum},
  {"mean", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_67mean, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_66mean},
  {"var", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_69var, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_68var},
  {"std", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_71std, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_70std},
  {"prod", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_73prod, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_72prod},
  {"all", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_75all, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_74all},
  {"any", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_77any, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_76any},
  {"conj", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_147conj, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_146conj},
  {"__copy__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_149__copy__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_148__copy__},
  {"__deepcopy__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_151__deepcopy__, METH_O, __pyx_doc_4cupy_4core_4core_7ndarray_150__deepcopy__},
  {"__reduce__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_153__reduce__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_152__reduce__},
  {"__array__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_155__array__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_154__array__},
  {"scatter_add", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_163scatter_add, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_162scatter_add},
  {"__complex__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_171__complex__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_170__complex__},
  {"dot", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_181dot, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_180dot},
  {"get", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_183get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_182get},
  {"set", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_185set, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_184set},
  {"reduced_view", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_187reduced_view, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_186reduced_view},
  {"_update_c_contiguity", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_189_update_c_contiguity, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_188_update_c_contiguity},
  {"_update_f_contiguity", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_191_update_f_contiguity, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_190_update_f_contiguity},
  {"_update_contiguity", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_193_update_contiguity, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_192_update_contiguity},
  {"_set_shape_and_strides", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_195_set_shape_and_strides, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_194_set_shape_and_strides},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4cupy_4core_4core_ndarray[] = {
  {(char *)"flags", __pyx_getprop_4cupy_4core_4core_7ndarray_flags, 0, (char *)"Object containing memory-layout information.\n\n        It only contains ``c_contiguous``, ``f_contiguous``, and ``owndata``\n        attributes. All of these are read-only. Accessing by indexes is also\n        supported.\n\n        .. seealso:: :attr:`numpy.ndarray.flags`\n\n        ", 0},
  {(char *)"shape", __pyx_getprop_4cupy_4core_4core_7ndarray_shape, __pyx_setprop_4cupy_4core_4core_7ndarray_shape, (char *)"Lengths of axes.\n\n        Setter of this property involves reshaping without copy. If the array\n        cannot be reshaped without copy, it raises an exception.\n\n        .. seealso: :attr:`numpy.ndarray.shape`\n\n        ", 0},
  {(char *)"strides", __pyx_getprop_4cupy_4core_4core_7ndarray_strides, 0, (char *)"Strides of axes in bytes.\n\n        .. seealso:: :attr:`numpy.ndarray.strides`\n\n        ", 0},
  {(char *)"ndim", __pyx_getprop_4cupy_4core_4core_7ndarray_ndim, 0, (char *)"Number of dimensions.\n\n        ``a.ndim`` is equivalent to ``len(a.shape)``.\n\n        .. seealso:: :attr:`numpy.ndarray.ndim`\n\n        ", 0},
  {(char *)"itemsize", __pyx_getprop_4cupy_4core_4core_7ndarray_itemsize, 0, (char *)"Size of each element in bytes.\n\n        .. seealso:: :attr:`numpy.ndarray.itemsize`\n\n        ", 0},
  {(char *)"nbytes", __pyx_getprop_4cupy_4core_4core_7ndarray_nbytes, 0, (char *)"Size of whole elements in bytes.\n\n        It does not count skips between elements.\n\n        .. seealso:: :attr:`numpy.ndarray.nbytes`\n\n        ", 0},
  {(char *)"T", __pyx_getprop_4cupy_4core_4core_7ndarray_T, 0, (char *)"Shape-reversed view of the array.\n\n        If ndim < 2, then this is just a reference to the array itself.\n\n        ", 0},
  {(char *)"cstruct", __pyx_getprop_4cupy_4core_4core_7ndarray_cstruct, 0, (char *)"C representation of the array.\n\n        This property is used for sending an array to CUDA kernels. The type of\n        returned C structure is different for different dtypes and ndims. The\n        definition of C type is written in ``cupy/carray.cuh``.\n\n        ", 0},
  {(char *)"real", __pyx_getprop_4cupy_4core_4core_7ndarray_real, __pyx_setprop_4cupy_4core_4core_7ndarray_real, (char *)0, 0},
  {(char *)"imag", __pyx_getprop_4cupy_4core_4core_7ndarray_imag, __pyx_setprop_4cupy_4core_4core_7ndarray_imag, (char *)0, 0},
  {(char *)"device", __pyx_getprop_4cupy_4core_4core_7ndarray_device, 0, (char *)"CUDA device on which this array resides.", 0},
  {(char *)"size", __pyx_getprop_4cupy_4core_4core_7ndarray_size, 0, (char *)0, 0},
  {(char *)"_shape", __pyx_getprop_4cupy_4core_4core_7ndarray__shape, __pyx_setprop_4cupy_4core_4core_7ndarray__shape, (char *)"_shape: 'vector[Py_ssize_t]'", 0},
  {(char *)"_strides", __pyx_getprop_4cupy_4core_4core_7ndarray__strides, __pyx_setprop_4cupy_4core_4core_7ndarray__strides, (char *)"_strides: 'vector[Py_ssize_t]'", 0},
  {(char *)"_c_contiguous", __pyx_getprop_4cupy_4core_4core_7ndarray__c_contiguous, 0, (char *)0, 0},
  {(char *)"_f_contiguous", __pyx_getprop_4cupy_4core_4core_7ndarray__f_contiguous, 0, (char *)0, 0},
  {(char *)"dtype", __pyx_getprop_4cupy_4core_4core_7ndarray_dtype, 0, (char *)0, 0},
  {(char *)"data", __pyx_getprop_4cupy_4core_4core_7ndarray_data, 0, (char *)0, 0},
  {(char *)"base", __pyx_getprop_4cupy_4core_4core_7ndarray_base, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ndarray = {
  __pyx_pw_4cupy_4core_4core_7ndarray_91__add__, /*nb_add*/
  __pyx_pw_4cupy_4core_4core_7ndarray_93__sub__, /*nb_subtract*/
  __pyx_pw_4cupy_4core_4core_7ndarray_95__mul__, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  __pyx_pw_4cupy_4core_4core_7ndarray_99__div__, /*nb_divide*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_105__mod__, /*nb_remainder*/
  __pyx_pw_4cupy_4core_4core_7ndarray_107__divmod__, /*nb_divmod*/
  __pyx_pw_4cupy_4core_4core_7ndarray_109__pow__, /*nb_power*/
  __pyx_pw_4cupy_4core_4core_7ndarray_83__neg__, /*nb_negative*/
  __pyx_pw_4cupy_4core_4core_7ndarray_85__pos__, /*nb_positive*/
  __pyx_pw_4cupy_4core_4core_7ndarray_87__abs__, /*nb_absolute*/
  __pyx_pw_4cupy_4core_4core_7ndarray_81__nonzero__, /*nb_nonzero*/
  __pyx_pw_4cupy_4core_4core_7ndarray_89__invert__, /*nb_invert*/
  __pyx_pw_4cupy_4core_4core_7ndarray_111__lshift__, /*nb_lshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_113__rshift__, /*nb_rshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_115__and__, /*nb_and*/
  __pyx_pw_4cupy_4core_4core_7ndarray_119__xor__, /*nb_xor*/
  __pyx_pw_4cupy_4core_4core_7ndarray_117__or__, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_165__int__, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  __pyx_pw_4cupy_4core_4core_7ndarray_167__long__, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_169__float__, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  __pyx_pw_4cupy_4core_4core_7ndarray_173__oct__, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  __pyx_pw_4cupy_4core_4core_7ndarray_175__hex__, /*nb_hex*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_121__iadd__, /*nb_inplace_add*/
  __pyx_pw_4cupy_4core_4core_7ndarray_123__isub__, /*nb_inplace_subtract*/
  __pyx_pw_4cupy_4core_4core_7ndarray_125__imul__, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  __pyx_pw_4cupy_4core_4core_7ndarray_127__idiv__, /*nb_inplace_divide*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_133__imod__, /*nb_inplace_remainder*/
  __pyx_pw_4cupy_4core_4core_7ndarray_135__ipow__, /*nb_inplace_power*/
  __pyx_pw_4cupy_4core_4core_7ndarray_137__ilshift__, /*nb_inplace_lshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_139__irshift__, /*nb_inplace_rshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_141__iand__, /*nb_inplace_and*/
  __pyx_pw_4cupy_4core_4core_7ndarray_145__ixor__, /*nb_inplace_xor*/
  __pyx_pw_4cupy_4core_4core_7ndarray_143__ior__, /*nb_inplace_or*/
  __pyx_pw_4cupy_4core_4core_7ndarray_103__floordiv__, /*nb_floor_divide*/
  __pyx_pw_4cupy_4core_4core_7ndarray_101__truediv__, /*nb_true_divide*/
  __pyx_pw_4cupy_4core_4core_7ndarray_131__ifloordiv__, /*nb_inplace_floor_divide*/
  __pyx_pw_4cupy_4core_4core_7ndarray_129__itruediv__, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  __pyx_pw_4cupy_4core_4core_7ndarray_97__matmul__, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_ndarray = {
  __pyx_pw_4cupy_4core_4core_7ndarray_157__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_4cupy_4core_4core_ndarray, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_ndarray = {
  __pyx_pw_4cupy_4core_4core_7ndarray_157__len__, /*mp_length*/
  __pyx_pw_4cupy_4core_4core_7ndarray_159__getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_4cupy_4core_4core_ndarray, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_4cupy_4core_4core_ndarray = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.ndarray", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core_ndarray), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core_ndarray, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_177__repr__, /*tp_repr*/
  &__pyx_tp_as_number_ndarray, /*tp_as_number*/
  &__pyx_tp_as_sequence_ndarray, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ndarray, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_4cupy_4core_4core_7ndarray_179__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "ndarray(shape, dtype=float, memptr=None, order='C')\nMulti-dimensional array on a CUDA device.\n\n    This class implements a subset of methods of :class:`numpy.ndarray`.\n    The difference is that this class allocates the array content on the\n    current GPU device.\n\n    Args:\n        shape (tuple of ints): Length of axes.\n        dtype: Data type. It must be an argument of :class:`numpy.dtype`.\n        memptr (cupy.cuda.MemoryPointer): Pointer to the array content head.\n        order ({'C', 'F'}): Row-major (C-style) or column-major\n            (Fortran-style) order.\n\n    Attributes:\n        base (None or cupy.ndarray): Base array from which this array is\n            created as a view.\n        data (cupy.cuda.MemoryPointer): Pointer to the array content head.\n        ~ndarray.dtype(numpy.dtype): Dtype object of element type.\n\n            .. seealso::\n               `Data type objects (dtype)                <http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html>`_\n        ~ndarray.size (int): Number of elements this array holds.\n\n            This is equivalent to product over the shape tuple.\n\n            .. seealso:: :attr:`numpy.ndarray.size`\n\n\n    ", /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core_ndarray, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core_ndarray, /*tp_clear*/
  __pyx_pw_4cupy_4core_4core_7ndarray_79__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_4core_4core_ndarray, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4cupy_4core_4core_ndarray, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4cupy_4core_4core_7ndarray_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core_ndarray, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_4cupy_4core_4core_Indexer __pyx_vtable_4cupy_4core_4core_Indexer;

static PyObject *__pyx_tp_new_4cupy_4core_4core_Indexer(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4cupy_4core_4core_Indexer *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)o);
  p->__pyx_vtab = __pyx_vtabptr_4cupy_4core_4core_Indexer;
  p->shape = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core_Indexer(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core_Indexer *p = (struct __pyx_obj_4cupy_4core_4core_Indexer *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->shape);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4cupy_4core_4core_Indexer(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core_Indexer *p = (struct __pyx_obj_4cupy_4core_4core_Indexer *)o;
  if (p->shape) {
    e = (*v)(p->shape, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core_Indexer(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core_Indexer *p = (struct __pyx_obj_4cupy_4core_4core_Indexer *)o;
  tmp = ((PyObject*)p->shape);
  p->shape = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7Indexer_ndim(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7Indexer_4ndim_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7Indexer_size(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7Indexer_4size_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7Indexer_shape(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7Indexer_5shape_1__get__(o);
}

static PyMethodDef __pyx_methods_4cupy_4core_4core_Indexer[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7Indexer_3__reduce_cython__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7Indexer_2__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7Indexer_5__setstate_cython__, METH_O, __pyx_doc_4cupy_4core_4core_7Indexer_4__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4cupy_4core_4core_Indexer[] = {
  {(char *)"ndim", __pyx_getprop_4cupy_4core_4core_7Indexer_ndim, 0, (char *)0, 0},
  {(char *)"size", __pyx_getprop_4cupy_4core_4core_7Indexer_size, 0, (char *)0, 0},
  {(char *)"shape", __pyx_getprop_4cupy_4core_4core_7Indexer_shape, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4cupy_4core_4core_Indexer = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.Indexer", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core_Indexer), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core_Indexer, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Indexer(tuple shape)", /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core_Indexer, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core_Indexer, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_4core_4core_Indexer, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4cupy_4core_4core_Indexer, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4cupy_4core_4core_7Indexer_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core_Indexer, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_4cupy_4core_4core_CArray(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_4cupy_4cuda_8function_CPointer->tp_new(t, a, k);
  if (unlikely(!o)) return 0;
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core_CArray(PyObject *o) {
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  if (likely(__pyx_ptype_4cupy_4cuda_8function_CPointer)) __pyx_ptype_4cupy_4cuda_8function_CPointer->tp_dealloc(o); else __Pyx_call_next_tp_dealloc(o, __pyx_tp_dealloc_4cupy_4core_4core_CArray);
}

static PyMethodDef __pyx_methods_4cupy_4core_4core_CArray[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_6CArray_3__reduce_cython__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_6CArray_2__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_6CArray_5__setstate_cython__, METH_O, __pyx_doc_4cupy_4core_4core_6CArray_4__setstate_cython__},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4cupy_4core_4core_CArray = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.CArray", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core_CArray), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core_CArray, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "CArray(ndarray arr)", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_4core_4core_CArray, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4cupy_4core_4core_6CArray_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core_CArray, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_4cupy_4core_4core_CIndexer(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_4cupy_4cuda_8function_CPointer->tp_new(t, a, k);
  if (unlikely(!o)) return 0;
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core_CIndexer(PyObject *o) {
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  if (likely(__pyx_ptype_4cupy_4cuda_8function_CPointer)) __pyx_ptype_4cupy_4cuda_8function_CPointer->tp_dealloc(o); else __Pyx_call_next_tp_dealloc(o, __pyx_tp_dealloc_4cupy_4core_4core_CIndexer);
}

static PyMethodDef __pyx_methods_4cupy_4core_4core_CIndexer[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_8CIndexer_3__reduce_cython__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_8CIndexer_2__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_8CIndexer_5__setstate_cython__, METH_O, __pyx_doc_4cupy_4core_4core_8CIndexer_4__setstate_cython__},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4cupy_4core_4core_CIndexer = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.CIndexer", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core_CIndexer), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core_CIndexer, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "CIndexer(Py_ssize_t size, tuple shape)", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_4core_4core_CIndexer, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4cupy_4core_4core_8CIndexer_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core_CIndexer, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_4cupy_4core_4core_ParameterInfo(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)o);
  p->name = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->dtype = Py_None; Py_INCREF(Py_None);
  p->ctype = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core_ParameterInfo(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *p = (struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->name);
  Py_CLEAR(p->dtype);
  Py_CLEAR(p->ctype);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4cupy_4core_4core_ParameterInfo(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *p = (struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)o;
  if (p->dtype) {
    e = (*v)(p->dtype, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core_ParameterInfo(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *p = (struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)o;
  tmp = ((PyObject*)p->dtype);
  p->dtype = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4cupy_4core_4core_13ParameterInfo_name(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_13ParameterInfo_4name_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_13ParameterInfo_dtype(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_13ParameterInfo_5dtype_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_13ParameterInfo_ctype(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_13ParameterInfo_5ctype_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_13ParameterInfo_raw(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_13ParameterInfo_3raw_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_13ParameterInfo_is_const(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_13ParameterInfo_8is_const_1__get__(o);
}

static PyMethodDef __pyx_methods_4cupy_4core_4core_ParameterInfo[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_13ParameterInfo_3__reduce_cython__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_13ParameterInfo_2__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_13ParameterInfo_5__setstate_cython__, METH_O, __pyx_doc_4cupy_4core_4core_13ParameterInfo_4__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4cupy_4core_4core_ParameterInfo[] = {
  {(char *)"name", __pyx_getprop_4cupy_4core_4core_13ParameterInfo_name, 0, (char *)0, 0},
  {(char *)"dtype", __pyx_getprop_4cupy_4core_4core_13ParameterInfo_dtype, 0, (char *)0, 0},
  {(char *)"ctype", __pyx_getprop_4cupy_4core_4core_13ParameterInfo_ctype, 0, (char *)0, 0},
  {(char *)"raw", __pyx_getprop_4cupy_4core_4core_13ParameterInfo_raw, 0, (char *)0, 0},
  {(char *)"is_const", __pyx_getprop_4cupy_4core_4core_13ParameterInfo_is_const, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4cupy_4core_4core_ParameterInfo = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.ParameterInfo", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core_ParameterInfo), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core_ParameterInfo, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "ParameterInfo(str param, bool is_const)", /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core_ParameterInfo, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core_ParameterInfo, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_4core_4core_ParameterInfo, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4cupy_4core_4core_ParameterInfo, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4cupy_4core_4core_13ParameterInfo_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core_ParameterInfo, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_4cupy_4core_4core_ElementwiseKernel(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)o);
  p->in_params = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->out_params = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->params = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->operation = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->name = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->preamble = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->kwargs = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core_ElementwiseKernel(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *p = (struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->in_params);
  Py_CLEAR(p->out_params);
  Py_CLEAR(p->params);
  Py_CLEAR(p->operation);
  Py_CLEAR(p->name);
  Py_CLEAR(p->preamble);
  Py_CLEAR(p->kwargs);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4cupy_4core_4core_ElementwiseKernel(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *p = (struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)o;
  if (p->in_params) {
    e = (*v)(p->in_params, a); if (e) return e;
  }
  if (p->out_params) {
    e = (*v)(p->out_params, a); if (e) return e;
  }
  if (p->params) {
    e = (*v)(p->params, a); if (e) return e;
  }
  if (p->kwargs) {
    e = (*v)(p->kwargs, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core_ElementwiseKernel(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *p = (struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)o;
  tmp = ((PyObject*)p->in_params);
  p->in_params = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->out_params);
  p->out_params = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->params);
  p->params = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->kwargs);
  p->kwargs = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_in_params(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_9in_params_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_out_params(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_10out_params_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_nin(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_3nin_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_nout(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_4nout_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_nargs(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_5nargs_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_params(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_6params_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_operation(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_9operation_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_name(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_4name_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_reduce_dims(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_11reduce_dims_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_preamble(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_8preamble_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_kwargs(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_6kwargs_1__get__(o);
}

static PyMethodDef __pyx_methods_4cupy_4core_4core_ElementwiseKernel[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_5__reduce_cython__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_17ElementwiseKernel_4__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_7__setstate_cython__, METH_O, __pyx_doc_4cupy_4core_4core_17ElementwiseKernel_6__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4cupy_4core_4core_ElementwiseKernel[] = {
  {(char *)"in_params", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_in_params, 0, (char *)0, 0},
  {(char *)"out_params", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_out_params, 0, (char *)0, 0},
  {(char *)"nin", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_nin, 0, (char *)0, 0},
  {(char *)"nout", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_nout, 0, (char *)0, 0},
  {(char *)"nargs", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_nargs, 0, (char *)0, 0},
  {(char *)"params", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_params, 0, (char *)0, 0},
  {(char *)"operation", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_operation, 0, (char *)0, 0},
  {(char *)"name", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_name, 0, (char *)0, 0},
  {(char *)"reduce_dims", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_reduce_dims, 0, (char *)0, 0},
  {(char *)"preamble", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_preamble, 0, (char *)0, 0},
  {(char *)"kwargs", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_kwargs, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4cupy_4core_4core_ElementwiseKernel = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.ElementwiseKernel", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core_ElementwiseKernel, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_3__call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "ElementwiseKernel(in_params, out_params, operation, name='kernel', reduce_dims=True, preamble='', **kwargs)\nUser-defined elementwise kernel.\n\n    This class can be used to define an elementwise kernel with or without\n    broadcasting.\n\n    The kernel is compiled at an invocation of the\n    :meth:`~ElementwiseKernel.__call__` method,\n    which is cached for each device.\n    The compiled binary is also cached into a file under the\n    ``$HOME/.cupy/kernel_cache/`` directory with a hashed file name. The cached\n    binary is reused by other processes.\n\n    Args:\n        in_params (str): Input argument list.\n        out_params (str): Output argument list.\n        operation (str): The body in the loop written in CUDA-C/C++.\n        name (str): Name of the kernel function. It should be set for\n            readability of the performance profiling.\n        reduce_dims (bool): If ``False``, the shapes of array arguments are\n            kept within the kernel invocation. The shapes are reduced\n            (i.e., the arrays are reshaped without copy to the minimum\n            dimension) by default. It may make the kernel fast by reducing the\n            index calculations.\n        options (list): Options passed to the ``nvcc`` command.\n        preamble (str): Fragment of the CUDA-C/C++ code that is inserted at the\n            top of the cu file.\n        loop_prep (str): Fragment of the CUDA-C/C++ code that is inserted at\n            the top of the kernel function definition and above the ``for``\n            loop.\n        after_loop (str): Fragment of the CUDA-C/C++ code that is inserted at\n            the bottom of the kernel function definition.\n\n    ", /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core_ElementwiseKernel, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core_ElementwiseKernel, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_4core_4core_ElementwiseKernel, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4cupy_4core_4core_ElementwiseKernel, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core_ElementwiseKernel, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_4cupy_4core_4core_broadcast(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4cupy_4core_4core_broadcast *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4cupy_4core_4core_broadcast *)o);
  p->values = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->shape = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core_broadcast(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core_broadcast *p = (struct __pyx_obj_4cupy_4core_4core_broadcast *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->values);
  Py_CLEAR(p->shape);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4cupy_4core_4core_broadcast(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core_broadcast *p = (struct __pyx_obj_4cupy_4core_4core_broadcast *)o;
  if (p->values) {
    e = (*v)(p->values, a); if (e) return e;
  }
  if (p->shape) {
    e = (*v)(p->shape, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core_broadcast(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core_broadcast *p = (struct __pyx_obj_4cupy_4core_4core_broadcast *)o;
  tmp = ((PyObject*)p->values);
  p->values = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->shape);
  p->shape = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4cupy_4core_4core_9broadcast_values(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_9broadcast_6values_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_9broadcast_shape(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_9broadcast_5shape_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_9broadcast_size(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_9broadcast_4size_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_9broadcast_nd(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_9broadcast_2nd_1__get__(o);
}

static PyMethodDef __pyx_methods_4cupy_4core_4core_broadcast[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_9broadcast_3__reduce_cython__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_9broadcast_2__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_9broadcast_5__setstate_cython__, METH_O, __pyx_doc_4cupy_4core_4core_9broadcast_4__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4cupy_4core_4core_broadcast[] = {
  {(char *)"values", __pyx_getprop_4cupy_4core_4core_9broadcast_values, 0, (char *)0, 0},
  {(char *)"shape", __pyx_getprop_4cupy_4core_4core_9broadcast_shape, 0, (char *)0, 0},
  {(char *)"size", __pyx_getprop_4cupy_4core_4core_9broadcast_size, 0, (char *)0, 0},
  {(char *)"nd", __pyx_getprop_4cupy_4core_4core_9broadcast_nd, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4cupy_4core_4core_broadcast = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.broadcast", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core_broadcast), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core_broadcast, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "broadcast(*arrays)\nObject that performs broadcasting.\n\n    CuPy actually uses this class to support broadcasting in various\n    operations. Note that this class does not provide an iterator.\n\n    Args:\n        arrays (tuple of arrays): Arrays to be broadcasted.\n\n    Attributes:\n        ~broadcast.shape (tuple of ints): The broadcasted shape.\n        nd (int): Number of dimensions of the broadcasted shape.\n        ~broadcast.size (int): Total size of the broadcasted shape.\n        values (list of arrays): The broadcasted arrays.\n\n    .. seealso:: :class:`numpy.broadcast`\n\n    ", /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core_broadcast, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core_broadcast, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_4core_4core_broadcast, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4cupy_4core_4core_broadcast, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4cupy_4core_4core_9broadcast_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core_broadcast, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *__pyx_freelist_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel[8];
static int __pyx_freecount_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel = 0;

static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel)))) {
    o = (PyObject*)__pyx_freelist_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel[--__pyx_freecount_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel];
    memset(o, 0, sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_types);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel)))) {
    __pyx_freelist_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel[__pyx_freecount_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel++] = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *)o;
  if (p->__pyx_v_types) {
    e = (*v)(p->__pyx_v_types, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *)o;
  tmp = ((PyObject*)p->__pyx_v_types);
  p->__pyx_v_types = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.__pyx_scope_struct___get_elementwise_kernel", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_1_genexpr[8];
static int __pyx_freecount_4cupy_4core_4core___pyx_scope_struct_1_genexpr = 0;

static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_1_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_1_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr)))) {
    o = (PyObject*)__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_1_genexpr[--__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_1_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_1_genexpr(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_k);
  Py_CLEAR(p->__pyx_v_v);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_1_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr)))) {
    __pyx_freelist_4cupy_4core_4core___pyx_scope_struct_1_genexpr[__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_1_genexpr++] = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_1_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_k) {
    e = (*v)(p->__pyx_v_k, a); if (e) return e;
  }
  if (p->__pyx_v_v) {
    e = (*v)(p->__pyx_v_v, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct_1_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_k);
  p->__pyx_v_k = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_v);
  p->__pyx_v_v = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_t_0);
  p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  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*/
  __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct_1_genexpr, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_1_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_2___init__[8];
static int __pyx_freecount_4cupy_4core_4core___pyx_scope_struct_2___init__ = 0;

static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_2___init__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_2___init__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__)))) {
    o = (PyObject*)__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_2___init__[--__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_2___init__];
    memset(o, 0, sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_2___init__(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_nin);
  Py_CLEAR(p->__pyx_v_nout);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_2___init__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__)))) {
    __pyx_freelist_4cupy_4core_4core___pyx_scope_struct_2___init__[__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_2___init__++] = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_2___init__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *)o;
  if (p->__pyx_v_nin) {
    e = (*v)(p->__pyx_v_nin, a); if (e) return e;
  }
  if (p->__pyx_v_nout) {
    e = (*v)(p->__pyx_v_nout, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct_2___init__(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *)o;
  tmp = ((PyObject*)p->__pyx_v_nin);
  p->__pyx_v_nin = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_nout);
  p->__pyx_v_nout = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4cupy_4core_4core___pyx_scope_struct_2___init__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.__pyx_scope_struct_2___init__", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_2___init__, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_2___init__, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct_2___init__, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_2___init__, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_3_genexpr[8];
static int __pyx_freecount_4cupy_4core_4core___pyx_scope_struct_3_genexpr = 0;

static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_3_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_3_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr)))) {
    o = (PyObject*)__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_3_genexpr[--__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_3_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_3_genexpr(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_i);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_3_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr)))) {
    __pyx_freelist_4cupy_4core_4core___pyx_scope_struct_3_genexpr[__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_3_genexpr++] = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_3_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_i) {
    e = (*v)(p->__pyx_v_i, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct_3_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_i);
  p->__pyx_v_i = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_t_0);
  p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4cupy_4core_4core___pyx_scope_struct_3_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.__pyx_scope_struct_3_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_3_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_3_genexpr, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct_3_genexpr, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_3_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_4_genexpr[8];
static int __pyx_freecount_4cupy_4core_4core___pyx_scope_struct_4_genexpr = 0;

static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_4_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_4_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr)))) {
    o = (PyObject*)__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_4_genexpr[--__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_4_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_4_genexpr(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_i);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_4_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr)))) {
    __pyx_freelist_4cupy_4core_4core___pyx_scope_struct_4_genexpr[__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_4_genexpr++] = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_4_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_i) {
    e = (*v)(p->__pyx_v_i, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct_4_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_i);
  p->__pyx_v_i = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_t_0);
  p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4cupy_4core_4core___pyx_scope_struct_4_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.__pyx_scope_struct_4_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_4_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_4_genexpr, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct_4_genexpr, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_4_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel[8];
static int __pyx_freecount_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel = 0;

static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel)))) {
    o = (PyObject*)__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel[--__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel];
    memset(o, 0, sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_types);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel)))) {
    __pyx_freelist_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel[__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel++] = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *)o;
  if (p->__pyx_v_types) {
    e = (*v)(p->__pyx_v_types, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *)o;
  tmp = ((PyObject*)p->__pyx_v_types);
  p->__pyx_v_types = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.__pyx_scope_struct_5__get_reduction_kernel", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_6_genexpr[8];
static int __pyx_freecount_4cupy_4core_4core___pyx_scope_struct_6_genexpr = 0;

static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_6_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_6_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr)))) {
    o = (PyObject*)__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_6_genexpr[--__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_6_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_6_genexpr(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_k);
  Py_CLEAR(p->__pyx_v_v);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_6_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr)))) {
    __pyx_freelist_4cupy_4core_4core___pyx_scope_struct_6_genexpr[__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_6_genexpr++] = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_6_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_k) {
    e = (*v)(p->__pyx_v_k, a); if (e) return e;
  }
  if (p->__pyx_v_v) {
    e = (*v)(p->__pyx_v_v, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct_6_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_k);
  p->__pyx_v_k = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_v);
  p->__pyx_v_v = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_t_0);
  p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4cupy_4core_4core___pyx_scope_struct_6_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.__pyx_scope_struct_6_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_6_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_6_genexpr, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct_6_genexpr, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_6_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_array __pyx_vtable_array;

static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_array_obj *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_array_obj *)o);
  p->__pyx_vtab = __pyx_vtabptr_array;
  p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_array(PyObject *o) {
  struct __pyx_array_obj *p = (struct __pyx_array_obj *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_array___dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->mode);
  Py_CLEAR(p->_format);
  (*Py_TYPE(o)->tp_free)(o);
}
static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_array(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_array___setitem__(o, i, v);
  }
  else {
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
    return -1;
  }
}

static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) {
  PyObject *v = PyObject_GenericGetAttr(o, n);
  if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
    PyErr_Clear();
    v = __pyx_array___getattr__(o, n);
  }
  return v;
}

static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(o);
}

static PyMethodDef __pyx_methods_array[] = {
  {"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_array_1__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_array_3__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_array[] = {
  {(char *)"memview", __pyx_getprop___pyx_array_memview, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PySequenceMethods __pyx_tp_as_sequence_array = {
  __pyx_array___len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_array, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_array = {
  __pyx_array___len__, /*mp_length*/
  __pyx_array___getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_array, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_array = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  __pyx_array_getbuffer, /*bf_getbuffer*/
  0, /*bf_releasebuffer*/
};

static PyTypeObject __pyx_type___pyx_array = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.array", /*tp_name*/
  sizeof(struct __pyx_array_obj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_array, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  &__pyx_tp_as_sequence_array, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_array, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  __pyx_tp_getattro_array, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_array, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_array, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_array, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_array, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_MemviewEnum_obj *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_MemviewEnum_obj *)o);
  p->name = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_Enum(PyObject *o) {
  struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->name);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
  if (p->name) {
    e = (*v)(p->name, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_Enum(PyObject *o) {
  PyObject* tmp;
  struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
  tmp = ((PyObject*)p->name);
  p->name = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_Enum[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_1__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_3__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type___pyx_MemviewEnum = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.Enum", /*tp_name*/
  sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_Enum, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  __pyx_MemviewEnum___repr__, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_Enum, /*tp_traverse*/
  __pyx_tp_clear_Enum, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_Enum, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_MemviewEnum___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_Enum, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_memoryview __pyx_vtable_memoryview;

static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_memoryview_obj *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_memoryview_obj *)o);
  p->__pyx_vtab = __pyx_vtabptr_memoryview;
  p->obj = Py_None; Py_INCREF(Py_None);
  p->_size = Py_None; Py_INCREF(Py_None);
  p->_array_interface = Py_None; Py_INCREF(Py_None);
  p->view.obj = NULL;
  if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_memoryview(PyObject *o) {
  struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_memoryview___dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->obj);
  Py_CLEAR(p->_size);
  Py_CLEAR(p->_array_interface);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
  if (p->obj) {
    e = (*v)(p->obj, a); if (e) return e;
  }
  if (p->_size) {
    e = (*v)(p->_size, a); if (e) return e;
  }
  if (p->_array_interface) {
    e = (*v)(p->_array_interface, a); if (e) return e;
  }
  if (p->view.obj) {
    e = (*v)(p->view.obj, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_memoryview(PyObject *o) {
  PyObject* tmp;
  struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
  tmp = ((PyObject*)p->obj);
  p->obj = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_size);
  p->_size = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_array_interface);
  p->_array_interface = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  Py_CLEAR(p->view.obj);
  return 0;
}
static PyObject *__pyx_sq_item_memoryview(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_memoryview___setitem__(o, i, v);
  }
  else {
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
    return -1;
  }
}

static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(o);
}

static PyMethodDef __pyx_methods_memoryview[] = {
  {"is_c_contig", (PyCFunction)__pyx_memoryview_is_c_contig, METH_NOARGS, 0},
  {"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0},
  {"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0},
  {"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_1__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_3__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_memoryview[] = {
  {(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, (char *)0, 0},
  {(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, (char *)0, 0},
  {(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, (char *)0, 0},
  {(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, (char *)0, 0},
  {(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, (char *)0, 0},
  {(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, (char *)0, 0},
  {(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, (char *)0, 0},
  {(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, (char *)0, 0},
  {(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PySequenceMethods __pyx_tp_as_sequence_memoryview = {
  __pyx_memoryview___len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_memoryview, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_memoryview = {
  __pyx_memoryview___len__, /*mp_length*/
  __pyx_memoryview___getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_memoryview, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_memoryview = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  __pyx_memoryview_getbuffer, /*bf_getbuffer*/
  0, /*bf_releasebuffer*/
};

static PyTypeObject __pyx_type___pyx_memoryview = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.memoryview", /*tp_name*/
  sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_memoryview, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  __pyx_memoryview___repr__, /*tp_repr*/
  0, /*tp_as_number*/
  &__pyx_tp_as_sequence_memoryview, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_memoryview, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_memoryview___str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_memoryview, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_memoryview, /*tp_traverse*/
  __pyx_tp_clear_memoryview, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_memoryview, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_memoryview, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_memoryview, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct__memoryviewslice __pyx_vtable__memoryviewslice;

static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_memoryviewslice_obj *p;
  PyObject *o = __pyx_tp_new_memoryview(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_memoryviewslice_obj *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_memoryview*)__pyx_vtabptr__memoryviewslice;
  p->from_object = Py_None; Py_INCREF(Py_None);
  p->from_slice.memview = NULL;
  return o;
}

static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) {
  struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_memoryviewslice___dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->from_object);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_memoryview(o);
}

static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
  e = __pyx_tp_traverse_memoryview(o, v, a); if (e) return e;
  if (p->from_object) {
    e = (*v)(p->from_object, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear__memoryviewslice(PyObject *o) {
  PyObject* tmp;
  struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
  __pyx_tp_clear_memoryview(o);
  tmp = ((PyObject*)p->from_object);
  p->from_object = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  __PYX_XDEC_MEMVIEW(&p->from_slice, 1);
  return 0;
}

static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(o);
}

static PyMethodDef __pyx_methods__memoryviewslice[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_1__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_3__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = {
  {(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type___pyx_memoryviewslice = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core._memoryviewslice", /*tp_name*/
  sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_memoryview___repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_memoryview___str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Internal class for passing memoryview slices to Python", /*tp_doc*/
  __pyx_tp_traverse__memoryviewslice, /*tp_traverse*/
  __pyx_tp_clear__memoryviewslice, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods__memoryviewslice, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets__memoryviewslice, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new__memoryviewslice, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {"_get_strides_for_nocopy_reshape", (PyCFunction)__pyx_pw_4cupy_4core_4core_1_get_strides_for_nocopy_reshape, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core__get_strides_for_nocopy_reshape},
  {"_get_header_dir_path", (PyCFunction)__pyx_pw_4cupy_4core_4core_3_get_header_dir_path, METH_NOARGS, __pyx_doc_4cupy_4core_4core_2_get_header_dir_path},
  {"_get_header_source", (PyCFunction)__pyx_pw_4cupy_4core_4core_5_get_header_source, METH_NOARGS, __pyx_doc_4cupy_4core_4core_4_get_header_source},
  {"_get_cuda_path", (PyCFunction)__pyx_pw_4cupy_4core_4core_7_get_cuda_path, METH_NOARGS, __pyx_doc_4cupy_4core_4core_6_get_cuda_path},
  {"compile_with_cache", (PyCFunction)__pyx_pw_4cupy_4core_4core_9compile_with_cache, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_8compile_with_cache},
  {"_get_simple_elementwise_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_11_get_simple_elementwise_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_10_get_simple_elementwise_kernel},
  {"_python_scalar_to_numpy_scalar", (PyCFunction)__pyx_pw_4cupy_4core_4core_13_python_scalar_to_numpy_scalar, METH_O, __pyx_doc_4cupy_4core_4core_12_python_scalar_to_numpy_scalar},
  {"_get_typename", (PyCFunction)__pyx_pw_4cupy_4core_4core_15_get_typename, METH_O, __pyx_doc_4cupy_4core_4core_14_get_typename},
  {"_preprocess_args", (PyCFunction)__pyx_pw_4cupy_4core_4core_17_preprocess_args, METH_O, __pyx_doc_4cupy_4core_4core_16_preprocess_args},
  {"_get_args_info", (PyCFunction)__pyx_pw_4cupy_4core_4core_19_get_args_info, METH_O, __pyx_doc_4cupy_4core_4core_18_get_args_info},
  {"_get_kernel_params", (PyCFunction)__pyx_pw_4cupy_4core_4core_21_get_kernel_params, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_20_get_kernel_params},
  {"_reduce_dims", (PyCFunction)__pyx_pw_4cupy_4core_4core_23_reduce_dims, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_22_reduce_dims},
  {"create_ufunc", (PyCFunction)__pyx_pw_4cupy_4core_4core_33create_ufunc, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_32create_ufunc},
  {"_get_simple_reduction_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_35_get_simple_reduction_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_34_get_simple_reduction_kernel},
  {"_get_axis", (PyCFunction)__pyx_pw_4cupy_4core_4core_37_get_axis, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_36_get_axis},
  {"_get_out_shape", (PyCFunction)__pyx_pw_4cupy_4core_4core_39_get_out_shape, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_38_get_out_shape},
  {"_get_trans_args", (PyCFunction)__pyx_pw_4cupy_4core_4core_41_get_trans_args, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_40_get_trans_args},
  {"_get_inout_args", (PyCFunction)__pyx_pw_4cupy_4core_4core_43_get_inout_args, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_42_get_inout_args},
  {"create_reduction_func", (PyCFunction)__pyx_pw_4cupy_4core_4core_49create_reduction_func, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_48create_reduction_func},
  {"array", (PyCFunction)__pyx_pw_4cupy_4core_4core_51array, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_50array},
  {"ascontiguousarray", (PyCFunction)__pyx_pw_4cupy_4core_4core_53ascontiguousarray, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_52ascontiguousarray},
  {"asfortranarray", (PyCFunction)__pyx_pw_4cupy_4core_4core_55asfortranarray, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_54asfortranarray},
  {"normalize_axis_tuple", (PyCFunction)__pyx_pw_4cupy_4core_4core_59normalize_axis_tuple, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_58normalize_axis_tuple},
  {"moveaxis", (PyCFunction)__pyx_pw_4cupy_4core_4core_61moveaxis, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_60moveaxis},
  {"rollaxis", (PyCFunction)__pyx_pw_4cupy_4core_4core_63rollaxis, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_62rollaxis},
  {"broadcast_to", (PyCFunction)__pyx_pw_4cupy_4core_4core_67broadcast_to, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_66broadcast_to},
  {"_repeat", (PyCFunction)__pyx_pw_4cupy_4core_4core_69_repeat, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_68_repeat},
  {"concatenate_method", (PyCFunction)__pyx_pw_4cupy_4core_4core_71concatenate_method, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_70concatenate_method},
  {"concatenate", (PyCFunction)__pyx_pw_4cupy_4core_4core_73concatenate, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_72concatenate},
  {"size", (PyCFunction)__pyx_pw_4cupy_4core_4core_75size, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_74size},
  {"_create_bit_op", (PyCFunction)__pyx_pw_4cupy_4core_4core_77_create_bit_op, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_76_create_bit_op},
  {"_prepare_mask_indexing_single", (PyCFunction)__pyx_pw_4cupy_4core_4core_79_prepare_mask_indexing_single, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_78_prepare_mask_indexing_single},
  {"_getitem_mask_single", (PyCFunction)__pyx_pw_4cupy_4core_4core_81_getitem_mask_single, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_80_getitem_mask_single},
  {"_take", (PyCFunction)__pyx_pw_4cupy_4core_4core_83_take, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_82_take},
  {"_scatter_op_single", (PyCFunction)__pyx_pw_4cupy_4core_4core_85_scatter_op_single, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_84_scatter_op_single},
  {"_scatter_op_mask_single", (PyCFunction)__pyx_pw_4cupy_4core_4core_87_scatter_op_mask_single, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_86_scatter_op_mask_single},
  {"_scatter_op", (PyCFunction)__pyx_pw_4cupy_4core_4core_89_scatter_op, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_88_scatter_op},
  {"_diagonal", (PyCFunction)__pyx_pw_4cupy_4core_4core_91_diagonal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_90_diagonal},
  {"_prepare_multiple_array_indexing", (PyCFunction)__pyx_pw_4cupy_4core_4core_93_prepare_multiple_array_indexing, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_92_prepare_multiple_array_indexing},
  {"_getitem_multiple", (PyCFunction)__pyx_pw_4cupy_4core_4core_95_getitem_multiple, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_94_getitem_multiple},
  {"dot", (PyCFunction)__pyx_pw_4cupy_4core_4core_97dot, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_96dot},
  {"_get_all_addresses", (PyCFunction)__pyx_pw_4cupy_4core_4core_99_get_all_addresses, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_98_get_all_addresses},
  {"matmul", (PyCFunction)__pyx_pw_4cupy_4core_4core_101matmul, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_100matmul},
  {"tensordot_core", (PyCFunction)__pyx_pw_4cupy_4core_4core_103tensordot_core, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_102tensordot_core},
  {"_mat_to_cublas_contiguous", (PyCFunction)__pyx_pw_4cupy_4core_4core_105_mat_to_cublas_contiguous, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_104_mat_to_cublas_contiguous},
  {"_to_cublas_vector", (PyCFunction)__pyx_pw_4cupy_4core_4core_107_to_cublas_vector, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_106_to_cublas_vector},
  {"create_comparison", (PyCFunction)__pyx_pw_4cupy_4core_4core_109create_comparison, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_108create_comparison},
  {"_var", (PyCFunction)__pyx_pw_4cupy_4core_4core_111_var, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_110_var},
  {"_std", (PyCFunction)__pyx_pw_4cupy_4core_4core_113_std, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_112_std},
  {"scan", (PyCFunction)__pyx_pw_4cupy_4core_4core_123scan, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_122scan},
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
  #if PY_VERSION_HEX < 0x03020000
    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  #else
    PyModuleDef_HEAD_INIT,
  #endif
    "core",
    0, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_0, __pyx_k_0, sizeof(__pyx_k_0), 0, 0, 1, 0},
  {&__pyx_kp_s_0_1__raw__1__i, __pyx_k_0_1__raw__1__i, sizeof(__pyx_k_0_1__raw__1__i), 0, 0, 1, 0},
  {&__pyx_n_s_A, __pyx_k_A, sizeof(__pyx_k_A), 0, 0, 1, 1},
  {&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 0, 0, 1, 1},
  {&__pyx_kp_s_Adds_two_arrays_elementwise_seea, __pyx_k_Adds_two_arrays_elementwise_seea, sizeof(__pyx_k_Adds_two_arrays_elementwise_seea), 0, 0, 1, 0},
  {&__pyx_kp_s_All_arrays_must_have_same_shape, __pyx_k_All_arrays_must_have_same_shape, sizeof(__pyx_k_All_arrays_must_have_same_shape), 0, 0, 1, 0},
  {&__pyx_kp_s_All_arrays_to_concatenate_must_h, __pyx_k_All_arrays_to_concatenate_must_h, sizeof(__pyx_k_All_arrays_to_concatenate_must_h), 0, 0, 1, 0},
  {&__pyx_kp_s_Array_device_must_be_same_as_the, __pyx_k_Array_device_must_be_same_as_the, sizeof(__pyx_k_Array_device_must_be_same_as_the), 0, 0, 1, 0},
  {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
  {&__pyx_kp_s_Axes_overrun, __pyx_k_Axes_overrun, sizeof(__pyx_k_Axes_overrun), 0, 0, 1, 0},
  {&__pyx_n_s_AxisError, __pyx_k_AxisError, sizeof(__pyx_k_AxisError), 0, 0, 1, 1},
  {&__pyx_n_s_AxisError_2, __pyx_k_AxisError_2, sizeof(__pyx_k_AxisError_2), 0, 0, 1, 1},
  {&__pyx_kp_s_Axis_dimension_mismatch, __pyx_k_Axis_dimension_mismatch, sizeof(__pyx_k_Axis_dimension_mismatch), 0, 0, 1, 0},
  {&__pyx_kp_s_Axis_exceeds_ndim, __pyx_k_Axis_exceeds_ndim, sizeof(__pyx_k_Axis_exceeds_ndim), 0, 0, 1, 0},
  {&__pyx_kp_s_Axis_out_of_range, __pyx_k_Axis_out_of_range, sizeof(__pyx_k_Axis_out_of_range), 0, 0, 1, 0},
  {&__pyx_kp_s_Axis_overrun, __pyx_k_Axis_overrun, sizeof(__pyx_k_Axis_overrun), 0, 0, 1, 0},
  {&__pyx_kp_s_B, __pyx_k_B, sizeof(__pyx_k_B), 0, 0, 1, 0},
  {&__pyx_kp_s_BB, __pyx_k_BB, sizeof(__pyx_k_BB), 0, 0, 1, 0},
  {&__pyx_kp_s_BBB_B, __pyx_k_BBB_B, sizeof(__pyx_k_BBB_B), 0, 0, 1, 0},
  {&__pyx_kp_s_BB_B, __pyx_k_BB_B, sizeof(__pyx_k_BB_B), 0, 0, 1, 0},
  {&__pyx_kp_s_BB_BB, __pyx_k_BB_BB, sizeof(__pyx_k_BB_BB), 0, 0, 1, 0},
  {&__pyx_kp_s_BB_d, __pyx_k_BB_d, sizeof(__pyx_k_BB_d), 0, 0, 1, 0},
  {&__pyx_kp_s_B_B, __pyx_k_B_B, sizeof(__pyx_k_B_B), 0, 0, 1, 0},
  {&__pyx_kp_s_B_B_2, __pyx_k_B_B_2, sizeof(__pyx_k_B_B_2), 0, 0, 1, 0},
  {&__pyx_kp_s_B_L, __pyx_k_B_L, sizeof(__pyx_k_B_L), 0, 0, 1, 0},
  {&__pyx_kp_s_B_d, __pyx_k_B_d, sizeof(__pyx_k_B_d), 0, 0, 1, 0},
  {&__pyx_kp_s_B_q, __pyx_k_B_q, sizeof(__pyx_k_B_q), 0, 0, 1, 0},
  {&__pyx_kp_s_Broadcasting_failed, __pyx_k_Broadcasting_failed, sizeof(__pyx_k_Broadcasting_failed), 0, 0, 1, 0},
  {&__pyx_kp_s_Buffer_view_does_not_expose_stri, __pyx_k_Buffer_view_does_not_expose_stri, sizeof(__pyx_k_Buffer_view_does_not_expose_stri), 0, 0, 1, 0},
  {&__pyx_n_s_C, __pyx_k_C, sizeof(__pyx_k_C), 0, 0, 1, 1},
  {&__pyx_kp_s_CArray_s_d, __pyx_k_CArray_s_d, sizeof(__pyx_k_CArray_s_d), 0, 0, 1, 0},
  {&__pyx_n_s_CIndexer, __pyx_k_CIndexer, sizeof(__pyx_k_CIndexer), 0, 0, 1, 1},
  {&__pyx_kp_s_CIndexer__in_ind_CIndexer__out_i, __pyx_k_CIndexer__in_ind_CIndexer__out_i, sizeof(__pyx_k_CIndexer__in_ind_CIndexer__out_i), 0, 0, 1, 0},
  {&__pyx_kp_s_CIndexer__ind, __pyx_k_CIndexer__ind, sizeof(__pyx_k_CIndexer__ind), 0, 0, 1, 0},
  {&__pyx_kp_s_CIndexer_d, __pyx_k_CIndexer_d, sizeof(__pyx_k_CIndexer_d), 0, 0, 1, 0},
  {&__pyx_n_s_CUDA_PATH, __pyx_k_CUDA_PATH, sizeof(__pyx_k_CUDA_PATH), 0, 0, 1, 1},
  {&__pyx_kp_s_Can_not_use_i_as_a_parameter_nam, __pyx_k_Can_not_use_i_as_a_parameter_nam, sizeof(__pyx_k_Can_not_use_i_as_a_parameter_nam), 0, 0, 1, 0},
  {&__pyx_kp_s_Can_only_create_a_buffer_that_is, __pyx_k_Can_only_create_a_buffer_that_is, sizeof(__pyx_k_Can_only_create_a_buffer_that_is), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_concatenate_from_empty_tu, __pyx_k_Cannot_concatenate_from_empty_tu, sizeof(__pyx_k_Cannot_concatenate_from_empty_tu), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_index_with_type_s, __pyx_k_Cannot_index_with_type_s, sizeof(__pyx_k_Cannot_index_with_type_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_set_to_non_contiguous_arr, __pyx_k_Cannot_set_to_non_contiguous_arr, sizeof(__pyx_k_Cannot_set_to_non_contiguous_arr), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_specify_out_as_both_a_pos, __pyx_k_Cannot_specify_out_as_both_a_pos, sizeof(__pyx_k_Cannot_specify_out_as_both_a_pos), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_use_out_in_s, __pyx_k_Cannot_use_out_in_s, sizeof(__pyx_k_Cannot_use_out_in_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Computes_the_bitwise_AND_of_two, __pyx_k_Computes_the_bitwise_AND_of_two, sizeof(__pyx_k_Computes_the_bitwise_AND_of_two), 0, 0, 1, 0},
  {&__pyx_kp_s_Computes_the_bitwise_NOT_of_an_a, __pyx_k_Computes_the_bitwise_NOT_of_an_a, sizeof(__pyx_k_Computes_the_bitwise_NOT_of_an_a), 0, 0, 1, 0},
  {&__pyx_kp_s_Computes_the_bitwise_OR_of_two_a, __pyx_k_Computes_the_bitwise_OR_of_two_a, sizeof(__pyx_k_Computes_the_bitwise_OR_of_two_a), 0, 0, 1, 0},
  {&__pyx_kp_s_Computes_the_bitwise_XOR_of_two, __pyx_k_Computes_the_bitwise_XOR_of_two, sizeof(__pyx_k_Computes_the_bitwise_XOR_of_two), 0, 0, 1, 0},
  {&__pyx_kp_s_Computes_the_remainder_of_Python, __pyx_k_Computes_the_remainder_of_Python, sizeof(__pyx_k_Computes_the_remainder_of_Python), 0, 0, 1, 0},
  {&__pyx_kp_s_Computes_x1_x2_elementwise_seeal, __pyx_k_Computes_x1_x2_elementwise_seeal, sizeof(__pyx_k_Computes_x1_x2_elementwise_seeal), 0, 0, 1, 0},
  {&__pyx_n_s_D, __pyx_k_D, sizeof(__pyx_k_D), 0, 0, 1, 1},
  {&__pyx_kp_s_DD, __pyx_k_DD, sizeof(__pyx_k_DD), 0, 0, 1, 0},
  {&__pyx_kp_s_DD_D, __pyx_k_DD_D, sizeof(__pyx_k_DD_D), 0, 0, 1, 0},
  {&__pyx_kp_s_D_2, __pyx_k_D_2, sizeof(__pyx_k_D_2), 0, 0, 1, 0},
  {&__pyx_kp_s_D_D, __pyx_k_D_D, sizeof(__pyx_k_D_D), 0, 0, 1, 0},
  {&__pyx_kp_s_D_D_2, __pyx_k_D_D_2, sizeof(__pyx_k_D_D_2), 0, 0, 1, 0},
  {&__pyx_kp_s_D_d, __pyx_k_D_d, sizeof(__pyx_k_D_d), 0, 0, 1, 0},
  {&__pyx_n_s_Device, __pyx_k_Device, sizeof(__pyx_k_Device), 0, 0, 1, 1},
  {&__pyx_kp_s_Divides_arguments_elementwise_se, __pyx_k_Divides_arguments_elementwise_se, sizeof(__pyx_k_Divides_arguments_elementwise_se), 0, 0, 1, 0},
  {&__pyx_kp_s_Elementwise_absolute_value_funct, __pyx_k_Elementwise_absolute_value_funct, sizeof(__pyx_k_Elementwise_absolute_value_funct), 0, 0, 1, 0},
  {&__pyx_kp_s_Elementwise_floor_division_i_e_i, __pyx_k_Elementwise_floor_division_i_e_i, sizeof(__pyx_k_Elementwise_floor_division_i_e_i), 0, 0, 1, 0},
  {&__pyx_kp_s_Elementwise_true_division_i_e_di, __pyx_k_Elementwise_true_division_i_e_di, sizeof(__pyx_k_Elementwise_true_division_i_e_di), 0, 0, 1, 0},
  {&__pyx_n_s_Ellipsis, __pyx_k_Ellipsis, sizeof(__pyx_k_Ellipsis), 0, 0, 1, 1},
  {&__pyx_kp_s_Empty_shape_tuple_for_cython_arr, __pyx_k_Empty_shape_tuple_for_cython_arr, sizeof(__pyx_k_Empty_shape_tuple_for_cython_arr), 0, 0, 1, 0},
  {&__pyx_n_s_F, __pyx_k_F, sizeof(__pyx_k_F), 0, 0, 1, 1},
  {&__pyx_kp_s_FF, __pyx_k_FF, sizeof(__pyx_k_FF), 0, 0, 1, 0},
  {&__pyx_kp_s_FF_F, __pyx_k_FF_F, sizeof(__pyx_k_FF_F), 0, 0, 1, 0},
  {&__pyx_kp_s_F_2, __pyx_k_F_2, sizeof(__pyx_k_F_2), 0, 0, 1, 0},
  {&__pyx_kp_s_F_F, __pyx_k_F_F, sizeof(__pyx_k_F_F), 0, 0, 1, 0},
  {&__pyx_kp_s_F_F_2, __pyx_k_F_F_2, sizeof(__pyx_k_F_F_2), 0, 0, 1, 0},
  {&__pyx_kp_s_F_f, __pyx_k_F_f, sizeof(__pyx_k_F_f), 0, 0, 1, 0},
  {&__pyx_n_s_Flags, __pyx_k_Flags, sizeof(__pyx_k_Flags), 0, 0, 1, 1},
  {&__pyx_kp_s_H, __pyx_k_H, sizeof(__pyx_k_H), 0, 0, 1, 0},
  {&__pyx_kp_s_HH, __pyx_k_HH, sizeof(__pyx_k_HH), 0, 0, 1, 0},
  {&__pyx_kp_s_HHH_H, __pyx_k_HHH_H, sizeof(__pyx_k_HHH_H), 0, 0, 1, 0},
  {&__pyx_kp_s_HH_H, __pyx_k_HH_H, sizeof(__pyx_k_HH_H), 0, 0, 1, 0},
  {&__pyx_kp_s_HH_HH, __pyx_k_HH_HH, sizeof(__pyx_k_HH_HH), 0, 0, 1, 0},
  {&__pyx_kp_s_HH_d, __pyx_k_HH_d, sizeof(__pyx_k_HH_d), 0, 0, 1, 0},
  {&__pyx_kp_s_H_H, __pyx_k_H_H, sizeof(__pyx_k_H_H), 0, 0, 1, 0},
  {&__pyx_kp_s_H_H_2, __pyx_k_H_H_2, sizeof(__pyx_k_H_H_2), 0, 0, 1, 0},
  {&__pyx_kp_s_H_L, __pyx_k_H_L, sizeof(__pyx_k_H_L), 0, 0, 1, 0},
  {&__pyx_kp_s_H_d, __pyx_k_H_d, sizeof(__pyx_k_H_d), 0, 0, 1, 0},
  {&__pyx_kp_s_H_q, __pyx_k_H_q, sizeof(__pyx_k_H_q), 0, 0, 1, 0},
  {&__pyx_kp_s_I, __pyx_k_I, sizeof(__pyx_k_I), 0, 0, 1, 0},
  {&__pyx_kp_s_II, __pyx_k_II, sizeof(__pyx_k_II), 0, 0, 1, 0},
  {&__pyx_kp_s_III_I, __pyx_k_III_I, sizeof(__pyx_k_III_I), 0, 0, 1, 0},
  {&__pyx_kp_s_II_I, __pyx_k_II_I, sizeof(__pyx_k_II_I), 0, 0, 1, 0},
  {&__pyx_kp_s_II_II, __pyx_k_II_II, sizeof(__pyx_k_II_II), 0, 0, 1, 0},
  {&__pyx_kp_s_II_d, __pyx_k_II_d, sizeof(__pyx_k_II_d), 0, 0, 1, 0},
  {&__pyx_kp_s_I_2, __pyx_k_I_2, sizeof(__pyx_k_I_2), 0, 0, 1, 0},
  {&__pyx_kp_s_I_I, __pyx_k_I_I, sizeof(__pyx_k_I_I), 0, 0, 1, 0},
  {&__pyx_kp_s_I_I_2, __pyx_k_I_I_2, sizeof(__pyx_k_I_I_2), 0, 0, 1, 0},
  {&__pyx_kp_s_I_L, __pyx_k_I_L, sizeof(__pyx_k_I_L), 0, 0, 1, 0},
  {&__pyx_kp_s_I_d, __pyx_k_I_d, sizeof(__pyx_k_I_d), 0, 0, 1, 0},
  {&__pyx_kp_s_I_q, __pyx_k_I_q, sizeof(__pyx_k_I_q), 0, 0, 1, 0},
  {&__pyx_kp_s_I_s, __pyx_k_I_s, sizeof(__pyx_k_I_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Illegal_conditions, __pyx_k_Illegal_conditions, sizeof(__pyx_k_Illegal_conditions), 0, 0, 1, 0},
  {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x05, __pyx_k_Incompatible_checksums_s_vs_0x05, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x05), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x6d, __pyx_k_Incompatible_checksums_s_vs_0x6d, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x6d), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x73, __pyx_k_Incompatible_checksums_s_vs_0x73, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x73), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x7d, __pyx_k_Incompatible_checksums_s_vs_0x7d, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x7d), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xb0, __pyx_k_Incompatible_checksums_s_vs_0xb0, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xb0), 0, 0, 1, 0},
  {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
  {&__pyx_n_s_IndexOrValueError, __pyx_k_IndexOrValueError, sizeof(__pyx_k_IndexOrValueError), 0, 0, 1, 1},
  {&__pyx_n_s_IndexOrValueError___init, __pyx_k_IndexOrValueError___init, sizeof(__pyx_k_IndexOrValueError___init), 0, 0, 1, 1},
  {&__pyx_kp_s_Index_s_is_out_of_bounds_for_axi, __pyx_k_Index_s_is_out_of_bounds_for_axi, sizeof(__pyx_k_Index_s_is_out_of_bounds_for_axi), 0, 0, 1, 0},
  {&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0},
  {&__pyx_kp_s_Input_array_should_be_1D_array, __pyx_k_Input_array_should_be_1D_array, sizeof(__pyx_k_Input_array_should_be_1D_array), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_axes_value_s, __pyx_k_Invalid_axes_value_s, sizeof(__pyx_k_Invalid_axes_value_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_dtype_s, __pyx_k_Invalid_dtype_s, sizeof(__pyx_k_Invalid_dtype_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_index_type_s, __pyx_k_Invalid_index_type_s, sizeof(__pyx_k_Invalid_index_type_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_kernel_name_s, __pyx_k_Invalid_kernel_name_s, sizeof(__pyx_k_Invalid_kernel_name_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_k_Invalid_mode_expected_c_or_fortr, sizeof(__pyx_k_Invalid_mode_expected_c_or_fortr), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_k_Invalid_shape_in_axis_d_d, sizeof(__pyx_k_Invalid_shape_in_axis_d_d), 0, 0, 1, 0},
  {&__pyx_n_s_K, __pyx_k_K, sizeof(__pyx_k_K), 0, 0, 1, 1},
  {&__pyx_kp_s_L, __pyx_k_L, sizeof(__pyx_k_L), 0, 0, 1, 0},
  {&__pyx_kp_s_LL, __pyx_k_LL, sizeof(__pyx_k_LL), 0, 0, 1, 0},
  {&__pyx_kp_s_LLL_L, __pyx_k_LLL_L, sizeof(__pyx_k_LLL_L), 0, 0, 1, 0},
  {&__pyx_kp_s_LL_L, __pyx_k_LL_L, sizeof(__pyx_k_LL_L), 0, 0, 1, 0},
  {&__pyx_kp_s_LL_LL, __pyx_k_LL_LL, sizeof(__pyx_k_LL_LL), 0, 0, 1, 0},
  {&__pyx_kp_s_LL_d, __pyx_k_LL_d, sizeof(__pyx_k_LL_d), 0, 0, 1, 0},
  {&__pyx_kp_s_L_L, __pyx_k_L_L, sizeof(__pyx_k_L_L), 0, 0, 1, 0},
  {&__pyx_kp_s_L_L_2, __pyx_k_L_L_2, sizeof(__pyx_k_L_L_2), 0, 0, 1, 0},
  {&__pyx_kp_s_L_d, __pyx_k_L_d, sizeof(__pyx_k_L_d), 0, 0, 1, 0},
  {&__pyx_kp_s_L_q, __pyx_k_L_q, sizeof(__pyx_k_L_q), 0, 0, 1, 0},
  {&__pyx_kp_s_Loop_size_is_Undecided, __pyx_k_Loop_size_is_Undecided, sizeof(__pyx_k_Loop_size_is_Undecided), 0, 0, 1, 0},
  {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
  {&__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_k_MemoryView_of_r_at_0x_x, sizeof(__pyx_k_MemoryView_of_r_at_0x_x), 0, 0, 1, 0},
  {&__pyx_kp_s_MemoryView_of_r_object, __pyx_k_MemoryView_of_r_object, sizeof(__pyx_k_MemoryView_of_r_object), 0, 0, 1, 0},
  {&__pyx_kp_s_Multiplies_two_arrays_elementwis, __pyx_k_Multiplies_two_arrays_elementwis, sizeof(__pyx_k_Multiplies_two_arrays_elementwis), 0, 0, 1, 0},
  {&__pyx_kp_s_Negative_dimensions_are_not_allo, __pyx_k_Negative_dimensions_are_not_allo, sizeof(__pyx_k_Negative_dimensions_are_not_allo), 0, 0, 1, 0},
  {&__pyx_n_s_NotImplemented, __pyx_k_NotImplemented, sizeof(__pyx_k_NotImplemented), 0, 0, 1, 1},
  {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1},
  {&__pyx_kp_s_Not_supported_dtype_combination, __pyx_k_Not_supported_dtype_combination, sizeof(__pyx_k_Not_supported_dtype_combination), 0, 0, 1, 0},
  {&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1},
  {&__pyx_kp_s_Only_cupy_arrays_can_be_concaten, __pyx_k_Only_cupy_arrays_can_be_concaten, sizeof(__pyx_k_Only_cupy_arrays_can_be_concaten), 0, 0, 1, 0},
  {&__pyx_kp_s_Only_numpy_ndarray_can_be_set_to, __pyx_k_Only_numpy_ndarray_can_be_set_to, sizeof(__pyx_k_Only_numpy_ndarray_can_be_set_to), 0, 0, 1, 0},
  {&__pyx_kp_s_Only_one_Ellipsis_is_allowed_in, __pyx_k_Only_one_Ellipsis_is_allowed_in, sizeof(__pyx_k_Only_one_Ellipsis_is_allowed_in), 0, 0, 1, 0},
  {&__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_k_Out_of_bounds_on_buffer_access_a, sizeof(__pyx_k_Out_of_bounds_on_buffer_access_a), 0, 0, 1, 0},
  {&__pyx_kp_s_Out_shape_is_mismatched, __pyx_k_Out_shape_is_mismatched, sizeof(__pyx_k_Out_shape_is_mismatched), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_arguments_must_be_cupy_nd, __pyx_k_Output_arguments_must_be_cupy_nd, sizeof(__pyx_k_Output_arguments_must_be_cupy_nd), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_arguments_type_must_be_cu, __pyx_k_Output_arguments_type_must_be_cu, sizeof(__pyx_k_Output_arguments_type_must_be_cu), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_array_has_an_invalid_size, __pyx_k_Output_array_has_an_invalid_size, sizeof(__pyx_k_Output_array_has_an_invalid_size), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_array_must_be_C_contiguou, __pyx_k_Output_array_must_be_C_contiguou, sizeof(__pyx_k_Output_array_must_be_C_contiguou), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_array_size_is_Undecided, __pyx_k_Output_array_size_is_Undecided, sizeof(__pyx_k_Output_array_size_is_Undecided), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_dtype_mismatch, __pyx_k_Output_dtype_mismatch, sizeof(__pyx_k_Output_dtype_mismatch), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_shape_mismatch, __pyx_k_Output_shape_mismatch, sizeof(__pyx_k_Output_shape_mismatch), 0, 0, 1, 0},
  {&__pyx_n_s_PATH, __pyx_k_PATH, sizeof(__pyx_k_PATH), 0, 0, 1, 1},
  {&__pyx_n_s_PY3, __pyx_k_PY3, sizeof(__pyx_k_PY3), 0, 0, 1, 1},
  {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
  {&__pyx_kp_s_Please_set_the_CUDA_path, __pyx_k_Please_set_the_CUDA_path, sizeof(__pyx_k_Please_set_the_CUDA_path), 0, 0, 1, 0},
  {&__pyx_kp_s_Provided_out_is_the_wrong_size, __pyx_k_Provided_out_is_the_wrong_size, sizeof(__pyx_k_Provided_out_is_the_wrong_size), 0, 0, 1, 0},
  {&__pyx_kp_s_Q, __pyx_k_Q, sizeof(__pyx_k_Q), 0, 0, 1, 0},
  {&__pyx_kp_s_QQ, __pyx_k_QQ, sizeof(__pyx_k_QQ), 0, 0, 1, 0},
  {&__pyx_kp_s_QQQ_Q, __pyx_k_QQQ_Q, sizeof(__pyx_k_QQQ_Q), 0, 0, 1, 0},
  {&__pyx_kp_s_QQ_Q, __pyx_k_QQ_Q, sizeof(__pyx_k_QQ_Q), 0, 0, 1, 0},
  {&__pyx_kp_s_QQ_QQ, __pyx_k_QQ_QQ, sizeof(__pyx_k_QQ_QQ), 0, 0, 1, 0},
  {&__pyx_kp_s_QQ_d, __pyx_k_QQ_d, sizeof(__pyx_k_QQ_d), 0, 0, 1, 0},
  {&__pyx_kp_s_Q_Q, __pyx_k_Q_Q, sizeof(__pyx_k_Q_Q), 0, 0, 1, 0},
  {&__pyx_kp_s_Q_Q_2, __pyx_k_Q_Q_2, sizeof(__pyx_k_Q_Q_2), 0, 0, 1, 0},
  {&__pyx_kp_s_Q_d, __pyx_k_Q_d, sizeof(__pyx_k_Q_d), 0, 0, 1, 0},
  {&__pyx_kp_s_Q_q, __pyx_k_Q_q, sizeof(__pyx_k_Q_q), 0, 0, 1, 0},
  {&__pyx_n_s_ReductionKernel, __pyx_k_ReductionKernel, sizeof(__pyx_k_ReductionKernel), 0, 0, 1, 1},
  {&__pyx_n_s_ReductionKernel___call, __pyx_k_ReductionKernel___call, sizeof(__pyx_k_ReductionKernel___call), 0, 0, 1, 1},
  {&__pyx_n_s_ReductionKernel___init, __pyx_k_ReductionKernel___init, sizeof(__pyx_k_ReductionKernel___init), 0, 0, 1, 1},
  {&__pyx_kp_s_Returns_the_angle_of_the_complex, __pyx_k_Returns_the_angle_of_the_complex, sizeof(__pyx_k_Returns_the_angle_of_the_complex), 0, 0, 1, 0},
  {&__pyx_kp_s_Returns_the_complex_conjugate_el, __pyx_k_Returns_the_complex_conjugate_el, sizeof(__pyx_k_Returns_the_complex_conjugate_el), 0, 0, 1, 0},
  {&__pyx_kp_s_Returns_the_imaginary_part_of_th, __pyx_k_Returns_the_imaginary_part_of_th, sizeof(__pyx_k_Returns_the_imaginary_part_of_th), 0, 0, 1, 0},
  {&__pyx_kp_s_Returns_the_real_part_of_the_ele, __pyx_k_Returns_the_real_part_of_the_ele, sizeof(__pyx_k_Returns_the_real_part_of_the_ele), 0, 0, 1, 0},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_kp_s_S_a_raw_T_choices_int32_n_channe, __pyx_k_S_a_raw_T_choices_int32_n_channe, sizeof(__pyx_k_S_a_raw_T_choices_int32_n_channe), 0, 0, 1, 0},
  {&__pyx_kp_s_S_a_raw_T_choices_int32_n_channe_2, __pyx_k_S_a_raw_T_choices_int32_n_channe_2, sizeof(__pyx_k_S_a_raw_T_choices_int32_n_channe_2), 0, 0, 1, 0},
  {&__pyx_kp_s_S_wrap_indices_indices_adim_if, __pyx_k_S_wrap_indices_indices_adim_if, sizeof(__pyx_k_S_wrap_indices_indices_adim_if), 0, 0, 1, 0},
  {&__pyx_kp_s_S_wrap_indices_indices_adim_if_2, __pyx_k_S_wrap_indices_indices_adim_if_2, sizeof(__pyx_k_S_wrap_indices_indices_adim_if_2), 0, 0, 1, 0},
  {&__pyx_kp_s_S_wrap_indices_indices_index_ra, __pyx_k_S_wrap_indices_indices_index_ra, sizeof(__pyx_k_S_wrap_indices_indices_index_ra), 0, 0, 1, 0},
  {&__pyx_kp_s_S_wrap_indices_indices_index_ra_2, __pyx_k_S_wrap_indices_indices_index_ra_2, sizeof(__pyx_k_S_wrap_indices_indices_index_ra_2), 0, 0, 1, 0},
  {&__pyx_kp_s_S_x_T_mean_T_alpha, __pyx_k_S_x_T_mean_T_alpha, sizeof(__pyx_k_S_x_T_mean_T_alpha), 0, 0, 1, 0},
  {&__pyx_kp_s_S_x_T_y, __pyx_k_S_x_T_y, sizeof(__pyx_k_S_x_T_y), 0, 0, 1, 0},
  {&__pyx_kp_s_S_x_a_if_a_0_x_0_else_if_a_n_x, __pyx_k_S_x_a_if_a_0_x_0_else_if_a_n_x, sizeof(__pyx_k_S_x_a_if_a_0_x_0_else_if_a_n_x), 0, 0, 1, 0},
  {&__pyx_kp_s_Scalar_operands_are_not_allowed, __pyx_k_Scalar_operands_are_not_allowed, sizeof(__pyx_k_Scalar_operands_are_not_allowed), 0, 0, 1, 0},
  {&__pyx_n_s_Sequence, __pyx_k_Sequence, sizeof(__pyx_k_Sequence), 0, 0, 1, 1},
  {&__pyx_kp_s_Sets_the_imaginary_part_of_the_e, __pyx_k_Sets_the_imaginary_part_of_the_e, sizeof(__pyx_k_Sets_the_imaginary_part_of_the_e), 0, 0, 1, 0},
  {&__pyx_kp_s_Sets_the_real_part_of_the_elemen, __pyx_k_Sets_the_real_part_of_the_elemen, sizeof(__pyx_k_Sets_the_real_part_of_the_elemen), 0, 0, 1, 0},
  {&__pyx_kp_s_Shape_mismatch_Old_shape_new_sha, __pyx_k_Shape_mismatch_Old_shape_new_sha, sizeof(__pyx_k_Shape_mismatch_Old_shape_new_sha), 0, 0, 1, 0},
  {&__pyx_kp_s_Shifts_the_bits_of_each_integer, __pyx_k_Shifts_the_bits_of_each_integer, sizeof(__pyx_k_Shifts_the_bits_of_each_integer), 0, 0, 1, 0},
  {&__pyx_kp_s_Shifts_the_bits_of_each_integer_2, __pyx_k_Shifts_the_bits_of_each_integer_2, sizeof(__pyx_k_Shifts_the_bits_of_each_integer_2), 0, 0, 1, 0},
  {&__pyx_kp_s_Sorting_arrays_with_the_rank_of, __pyx_k_Sorting_arrays_with_the_rank_of, sizeof(__pyx_k_Sorting_arrays_with_the_rank_of), 0, 0, 1, 0},
  {&__pyx_kp_s_Sorting_non_contiguous_array_is, __pyx_k_Sorting_non_contiguous_array_is, sizeof(__pyx_k_Sorting_non_contiguous_array_is), 0, 0, 1, 0},
  {&__pyx_kp_s_Specified_size_can_be_used_only, __pyx_k_Specified_size_can_be_used_only, sizeof(__pyx_k_Specified_size_can_be_used_only), 0, 0, 1, 0},
  {&__pyx_n_s_Stream, __pyx_k_Stream, sizeof(__pyx_k_Stream), 0, 0, 1, 1},
  {&__pyx_kp_s_Subtracts_arguments_elementwise, __pyx_k_Subtracts_arguments_elementwise, sizeof(__pyx_k_Subtracts_arguments_elementwise), 0, 0, 1, 0},
  {&__pyx_kp_s_Syntax_error_s, __pyx_k_Syntax_error_s, sizeof(__pyx_k_Syntax_error_s), 0, 0, 1, 0},
  {&__pyx_kp_s_T_a, __pyx_k_T_a, sizeof(__pyx_k_T_a), 0, 0, 1, 0},
  {&__pyx_kp_s_T_a_bool_mask_S_mask_scanned, __pyx_k_T_a_bool_mask_S_mask_scanned, sizeof(__pyx_k_T_a_bool_mask_S_mask_scanned), 0, 0, 1, 0},
  {&__pyx_kp_s_T_in0, __pyx_k_T_in0, sizeof(__pyx_k_T_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_T_in_d, __pyx_k_T_in_d, sizeof(__pyx_k_T_in_d), 0, 0, 1, 0},
  {&__pyx_kp_s_T_out, __pyx_k_T_out, sizeof(__pyx_k_T_out), 0, 0, 1, 0},
  {&__pyx_kp_s_T_out0, __pyx_k_T_out0, sizeof(__pyx_k_T_out0), 0, 0, 1, 0},
  {&__pyx_kp_s_T_out_d, __pyx_k_T_out_d, sizeof(__pyx_k_T_out_d), 0, 0, 1, 0},
  {&__pyx_kp_s_T_v_S_indices_int32_cdim_int32_r, __pyx_k_T_v_S_indices_int32_cdim_int32_r, sizeof(__pyx_k_T_v_S_indices_int32_cdim_int32_r), 0, 0, 1, 0},
  {&__pyx_kp_s_T_y, __pyx_k_T_y, sizeof(__pyx_k_T_y), 0, 0, 1, 0},
  {&__pyx_kp_s_Takes_numerical_negative_element, __pyx_k_Takes_numerical_negative_element, sizeof(__pyx_k_Takes_numerical_negative_element), 0, 0, 1, 0},
  {&__pyx_n_s_Template, __pyx_k_Template, sizeof(__pyx_k_Template), 0, 0, 1, 1},
  {&__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal, __pyx_k_Tests_elementwise_if_x1_x2_seeal, sizeof(__pyx_k_Tests_elementwise_if_x1_x2_seeal), 0, 0, 1, 0},
  {&__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_2, __pyx_k_Tests_elementwise_if_x1_x2_seeal_2, sizeof(__pyx_k_Tests_elementwise_if_x1_x2_seeal_2), 0, 0, 1, 0},
  {&__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_3, __pyx_k_Tests_elementwise_if_x1_x2_seeal_3, sizeof(__pyx_k_Tests_elementwise_if_x1_x2_seeal_3), 0, 0, 1, 0},
  {&__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_4, __pyx_k_Tests_elementwise_if_x1_x2_seeal_4, sizeof(__pyx_k_Tests_elementwise_if_x1_x2_seeal_4), 0, 0, 1, 0},
  {&__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_5, __pyx_k_Tests_elementwise_if_x1_x2_seeal_5, sizeof(__pyx_k_Tests_elementwise_if_x1_x2_seeal_5), 0, 0, 1, 0},
  {&__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_6, __pyx_k_Tests_elementwise_if_x1_x2_seeal_6, sizeof(__pyx_k_Tests_elementwise_if_x1_x2_seeal_6), 0, 0, 1, 0},
  {&__pyx_kp_s_The_out_array_as_input_is_curren, __pyx_k_The_out_array_as_input_is_curren, sizeof(__pyx_k_The_out_array_as_input_is_curren), 0, 0, 1, 0},
  {&__pyx_kp_s_The_truth_value_of_an_array_with, __pyx_k_The_truth_value_of_an_array_with, sizeof(__pyx_k_The_truth_value_of_an_array_with), 0, 0, 1, 0},
  {&__pyx_kp_s_Thrust_is_needed_to_use_cupy_arg, __pyx_k_Thrust_is_needed_to_use_cupy_arg, sizeof(__pyx_k_Thrust_is_needed_to_use_cupy_arg), 0, 0, 1, 0},
  {&__pyx_kp_s_Thrust_is_needed_to_use_cupy_sor, __pyx_k_Thrust_is_needed_to_use_cupy_sor, sizeof(__pyx_k_Thrust_is_needed_to_use_cupy_sor), 0, 0, 1, 0},
  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  {&__pyx_kp_s_Type_is_mismatched_s_s_s, __pyx_k_Type_is_mismatched_s_s_s, sizeof(__pyx_k_Type_is_mismatched_s_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Type_is_mismatched_s_s_s_s, __pyx_k_Type_is_mismatched_s_s_s_s, sizeof(__pyx_k_Type_is_mismatched_s_s_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_U_out, __pyx_k_U_out, sizeof(__pyx_k_U_out), 0, 0, 1, 0},
  {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0},
  {&__pyx_kp_s_Universal_function_Attributes_uf, __pyx_k_Universal_function_Attributes_uf, sizeof(__pyx_k_Universal_function_Attributes_uf), 0, 0, 1, 0},
  {&__pyx_kp_s_Unknown_keyword_s, __pyx_k_Unknown_keyword_s, sizeof(__pyx_k_Unknown_keyword_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Unsupported_dtype_s, __pyx_k_Unsupported_dtype_s, sizeof(__pyx_k_Unsupported_dtype_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Unsupported_type_s, __pyx_k_Unsupported_type_s, sizeof(__pyx_k_Unsupported_type_s), 0, 0, 1, 0},
  {&__pyx_kp_s_User_defined_reduction_kernel_Th, __pyx_k_User_defined_reduction_kernel_Th, sizeof(__pyx_k_User_defined_reduction_kernel_Th), 0, 0, 1, 0},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_kp_s_Variance_for_complex_numbers_is, __pyx_k_Variance_for_complex_numbers_is, sizeof(__pyx_k_Variance_for_complex_numbers_is), 0, 0, 1, 0},
  {&__pyx_n_s_View_MemoryView, __pyx_k_View_MemoryView, sizeof(__pyx_k_View_MemoryView), 0, 0, 1, 1},
  {&__pyx_kp_s_Wrong_arguments_s, __pyx_k_Wrong_arguments_s, sizeof(__pyx_k_Wrong_arguments_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Wrong_number_of_arguments_for_s, __pyx_k_Wrong_number_of_arguments_for_s, sizeof(__pyx_k_Wrong_number_of_arguments_for_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Wrong_type_s, __pyx_k_Wrong_type_s, sizeof(__pyx_k_Wrong_type_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Wrong_type_s_of_arguments_for_s, __pyx_k_Wrong_type_s_of_arguments_for_s, sizeof(__pyx_k_Wrong_type_s_of_arguments_for_s), 0, 0, 1, 0},
  {&__pyx_kp_s__128, __pyx_k__128, sizeof(__pyx_k__128), 0, 0, 1, 0},
  {&__pyx_n_s__251, __pyx_k__251, sizeof(__pyx_k__251), 0, 0, 1, 1},
  {&__pyx_kp_s__269, __pyx_k__269, sizeof(__pyx_k__269), 0, 0, 1, 0},
  {&__pyx_kp_s__316, __pyx_k__316, sizeof(__pyx_k__316), 0, 0, 1, 0},
  {&__pyx_kp_s__317, __pyx_k__317, sizeof(__pyx_k__317), 0, 0, 1, 0},
  {&__pyx_kp_s__318, __pyx_k__318, sizeof(__pyx_k__318), 0, 0, 1, 0},
  {&__pyx_kp_s__322, __pyx_k__322, sizeof(__pyx_k__322), 0, 0, 1, 0},
  {&__pyx_kp_s__323, __pyx_k__323, sizeof(__pyx_k__323), 0, 0, 1, 0},
  {&__pyx_kp_s__334, __pyx_k__334, sizeof(__pyx_k__334), 0, 0, 1, 0},
  {&__pyx_kp_s__335, __pyx_k__335, sizeof(__pyx_k__335), 0, 0, 1, 0},
  {&__pyx_kp_s__336, __pyx_k__336, sizeof(__pyx_k__336), 0, 0, 1, 0},
  {&__pyx_kp_s__337, __pyx_k__337, sizeof(__pyx_k__337), 0, 0, 1, 0},
  {&__pyx_kp_s__338, __pyx_k__338, sizeof(__pyx_k__338), 0, 0, 1, 0},
  {&__pyx_kp_s__339, __pyx_k__339, sizeof(__pyx_k__339), 0, 0, 1, 0},
  {&__pyx_kp_s__351, __pyx_k__351, sizeof(__pyx_k__351), 0, 0, 1, 0},
  {&__pyx_kp_s__375, __pyx_k__375, sizeof(__pyx_k__375), 0, 0, 1, 0},
  {&__pyx_kp_s__390, __pyx_k__390, sizeof(__pyx_k__390), 0, 0, 1, 0},
  {&__pyx_kp_s__414, __pyx_k__414, sizeof(__pyx_k__414), 0, 0, 1, 0},
  {&__pyx_kp_s__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 0, 1, 0},
  {&__pyx_kp_s__63, __pyx_k__63, sizeof(__pyx_k__63), 0, 0, 1, 0},
  {&__pyx_kp_s__67, __pyx_k__67, sizeof(__pyx_k__67), 0, 0, 1, 0},
  {&__pyx_kp_s__71, __pyx_k__71, sizeof(__pyx_k__71), 0, 0, 1, 0},
  {&__pyx_kp_s__72, __pyx_k__72, sizeof(__pyx_k__72), 0, 0, 1, 0},
  {&__pyx_kp_s__90, __pyx_k__90, sizeof(__pyx_k__90), 0, 0, 1, 0},
  {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
  {&__pyx_kp_s_a_b, __pyx_k_a_b, sizeof(__pyx_k_a_b), 0, 0, 1, 0},
  {&__pyx_kp_s_a_b_2, __pyx_k_a_b_2, sizeof(__pyx_k_a_b_2), 0, 0, 1, 0},
  {&__pyx_kp_s_a_b_3, __pyx_k_a_b_3, sizeof(__pyx_k_a_b_3), 0, 0, 1, 0},
  {&__pyx_kp_s_a_b_4, __pyx_k_a_b_4, sizeof(__pyx_k_a_b_4), 0, 0, 1, 0},
  {&__pyx_n_s_a_max, __pyx_k_a_max, sizeof(__pyx_k_a_max), 0, 0, 1, 1},
  {&__pyx_n_s_a_min, __pyx_k_a_min, sizeof(__pyx_k_a_min), 0, 0, 1, 1},
  {&__pyx_n_s_a_shape, __pyx_k_a_shape, sizeof(__pyx_k_a_shape), 0, 0, 1, 1},
  {&__pyx_n_s_absolute, __pyx_k_absolute, sizeof(__pyx_k_absolute), 0, 0, 1, 1},
  {&__pyx_n_s_abspath, __pyx_k_abspath, sizeof(__pyx_k_abspath), 0, 0, 1, 1},
  {&__pyx_n_s_add, __pyx_k_add, sizeof(__pyx_k_add), 0, 0, 1, 1},
  {&__pyx_n_s_add_scan_blocked_sum_kernel, __pyx_k_add_scan_blocked_sum_kernel, sizeof(__pyx_k_add_scan_blocked_sum_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_add_scan_blocked_sum_kernel_2, __pyx_k_add_scan_blocked_sum_kernel_2, sizeof(__pyx_k_add_scan_blocked_sum_kernel_2), 0, 0, 1, 1},
  {&__pyx_n_s_after_loop, __pyx_k_after_loop, sizeof(__pyx_k_after_loop), 0, 0, 1, 1},
  {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
  {&__pyx_n_s_all_2, __pyx_k_all_2, sizeof(__pyx_k_all_2), 0, 0, 1, 1},
  {&__pyx_kp_s_all_elements_of_repeats_should_n, __pyx_k_all_elements_of_repeats_should_n, sizeof(__pyx_k_all_elements_of_repeats_should_n), 0, 0, 1, 0},
  {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1},
  {&__pyx_n_s_amax, __pyx_k_amax, sizeof(__pyx_k_amax), 0, 0, 1, 1},
  {&__pyx_n_s_amin, __pyx_k_amin, sizeof(__pyx_k_amin), 0, 0, 1, 1},
  {&__pyx_n_s_angle, __pyx_k_angle, sizeof(__pyx_k_angle), 0, 0, 1, 1},
  {&__pyx_n_s_any, __pyx_k_any, sizeof(__pyx_k_any), 0, 0, 1, 1},
  {&__pyx_n_s_any_2, __pyx_k_any_2, sizeof(__pyx_k_any_2), 0, 0, 1, 1},
  {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
  {&__pyx_n_s_arange, __pyx_k_arange, sizeof(__pyx_k_arange), 0, 0, 1, 1},
  {&__pyx_n_s_arch, __pyx_k_arch, sizeof(__pyx_k_arch), 0, 0, 1, 1},
  {&__pyx_n_s_argmax, __pyx_k_argmax, sizeof(__pyx_k_argmax), 0, 0, 1, 1},
  {&__pyx_n_s_argmin, __pyx_k_argmin, sizeof(__pyx_k_argmin), 0, 0, 1, 1},
  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  {&__pyx_n_s_args_info, __pyx_k_args_info, sizeof(__pyx_k_args_info), 0, 0, 1, 1},
  {&__pyx_n_s_argsort, __pyx_k_argsort, sizeof(__pyx_k_argsort), 0, 0, 1, 1},
  {&__pyx_n_s_arr, __pyx_k_arr, sizeof(__pyx_k_arr), 0, 0, 1, 1},
  {&__pyx_n_s_array, __pyx_k_array, sizeof(__pyx_k_array), 0, 0, 1, 1},
  {&__pyx_kp_s_array_cannot_be_set_to_array, __pyx_k_array_cannot_be_set_to_array, sizeof(__pyx_k_array_cannot_be_set_to_array), 0, 0, 1, 0},
  {&__pyx_kp_s_array_clip_must_set_either_max_o, __pyx_k_array_clip_must_set_either_max_o, sizeof(__pyx_k_array_clip_must_set_either_max_o), 0, 0, 1, 0},
  {&__pyx_n_s_array_priority, __pyx_k_array_priority, sizeof(__pyx_k_array_priority), 0, 0, 1, 1},
  {&__pyx_n_s_array_split, __pyx_k_array_split, sizeof(__pyx_k_array_split), 0, 0, 1, 1},
  {&__pyx_n_s_arrays, __pyx_k_arrays, sizeof(__pyx_k_arrays), 0, 0, 1, 1},
  {&__pyx_kp_s_arrays_used_as_indices_must_be_o, __pyx_k_arrays_used_as_indices_must_be_o, sizeof(__pyx_k_arrays_used_as_indices_must_be_o), 0, 0, 1, 0},
  {&__pyx_n_s_ary, __pyx_k_ary, sizeof(__pyx_k_ary), 0, 0, 1, 1},
  {&__pyx_n_s_ascontiguousarray, __pyx_k_ascontiguousarray, sizeof(__pyx_k_ascontiguousarray), 0, 0, 1, 1},
  {&__pyx_n_s_asfortranarray, __pyx_k_asfortranarray, sizeof(__pyx_k_asfortranarray), 0, 0, 1, 1},
  {&__pyx_n_s_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 0, 0, 1, 1},
  {&__pyx_n_s_axis, __pyx_k_axis, sizeof(__pyx_k_axis), 0, 0, 1, 1},
  {&__pyx_n_s_axis1, __pyx_k_axis1, sizeof(__pyx_k_axis1), 0, 0, 1, 1},
  {&__pyx_kp_s_axis1_0_and_axis2_1_must_be_with, __pyx_k_axis1_0_and_axis2_1_must_be_with, sizeof(__pyx_k_axis1_0_and_axis2_1_must_be_with), 0, 0, 1, 0},
  {&__pyx_n_s_axis2, __pyx_k_axis2, sizeof(__pyx_k_axis2), 0, 0, 1, 1},
  {&__pyx_kp_s_axis_entry_d_is_out_of_bounds_d, __pyx_k_axis_entry_d_is_out_of_bounds_d, sizeof(__pyx_k_axis_entry_d_is_out_of_bounds_d), 0, 0, 1, 0},
  {&__pyx_kp_s_axis_is_out_of_bounds_for_array, __pyx_k_axis_is_out_of_bounds_for_array, sizeof(__pyx_k_axis_is_out_of_bounds_for_array), 0, 0, 1, 0},
  {&__pyx_kp_s_axis_out_of_bounds_0, __pyx_k_axis_out_of_bounds_0, sizeof(__pyx_k_axis_out_of_bounds_0), 0, 0, 1, 0},
  {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1},
  {&__pyx_kp_s_b_b, __pyx_k_b_b, sizeof(__pyx_k_b_b), 0, 0, 1, 0},
  {&__pyx_kp_s_b_b_2, __pyx_k_b_b_2, sizeof(__pyx_k_b_b_2), 0, 0, 1, 0},
  {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
  {&__pyx_kp_s_bb, __pyx_k_bb, sizeof(__pyx_k_bb), 0, 0, 1, 0},
  {&__pyx_kp_s_bb_b, __pyx_k_bb_b, sizeof(__pyx_k_bb_b), 0, 0, 1, 0},
  {&__pyx_kp_s_bb_bb, __pyx_k_bb_bb, sizeof(__pyx_k_bb_bb), 0, 0, 1, 0},
  {&__pyx_kp_s_bb_d, __pyx_k_bb_d, sizeof(__pyx_k_bb_d), 0, 0, 1, 0},
  {&__pyx_kp_s_bbb_b, __pyx_k_bbb_b, sizeof(__pyx_k_bbb_b), 0, 0, 1, 0},
  {&__pyx_kp_s_bhilqBHILQefdFD, __pyx_k_bhilqBHILQefdFD, sizeof(__pyx_k_bhilqBHILQefdFD), 0, 0, 1, 0},
  {&__pyx_n_s_bit_length, __pyx_k_bit_length, sizeof(__pyx_k_bit_length), 0, 0, 1, 1},
  {&__pyx_n_s_bitwise_and, __pyx_k_bitwise_and, sizeof(__pyx_k_bitwise_and), 0, 0, 1, 1},
  {&__pyx_n_s_bitwise_or, __pyx_k_bitwise_or, sizeof(__pyx_k_bitwise_or), 0, 0, 1, 1},
  {&__pyx_n_s_bitwise_xor, __pyx_k_bitwise_xor, sizeof(__pyx_k_bitwise_xor), 0, 0, 1, 1},
  {&__pyx_n_s_block, __pyx_k_block, sizeof(__pyx_k_block), 0, 0, 1, 1},
  {&__pyx_n_s_block_size, __pyx_k_block_size, sizeof(__pyx_k_block_size), 0, 0, 1, 1},
  {&__pyx_n_s_block_size_2, __pyx_k_block_size_2, sizeof(__pyx_k_block_size_2), 0, 0, 1, 1},
  {&__pyx_n_s_block_stride, __pyx_k_block_stride, sizeof(__pyx_k_block_stride), 0, 0, 1, 1},
  {&__pyx_n_s_bool, __pyx_k_bool, sizeof(__pyx_k_bool), 0, 0, 1, 1},
  {&__pyx_n_s_bool_2, __pyx_k_bool_2, sizeof(__pyx_k_bool_2), 0, 0, 1, 1},
  {&__pyx_n_s_broad, __pyx_k_broad, sizeof(__pyx_k_broad), 0, 0, 1, 1},
  {&__pyx_n_s_broad_shape, __pyx_k_broad_shape, sizeof(__pyx_k_broad_shape), 0, 0, 1, 1},
  {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
  {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1},
  {&__pyx_n_s_cPickle, __pyx_k_cPickle, sizeof(__pyx_k_cPickle), 0, 0, 1, 1},
  {&__pyx_n_s_c_contiguous, __pyx_k_c_contiguous, sizeof(__pyx_k_c_contiguous), 0, 0, 1, 1},
  {&__pyx_n_s_cachd_dir, __pyx_k_cachd_dir, sizeof(__pyx_k_cachd_dir), 0, 0, 1, 1},
  {&__pyx_n_s_call, __pyx_k_call, sizeof(__pyx_k_call), 0, 0, 1, 1},
  {&__pyx_n_s_can_cast, __pyx_k_can_cast, sizeof(__pyx_k_can_cast), 0, 0, 1, 1},
  {&__pyx_kp_s_cannot_select_an_axis_to_squeeze, __pyx_k_cannot_select_an_axis_to_squeeze, sizeof(__pyx_k_cannot_select_an_axis_to_squeeze), 0, 0, 1, 0},
  {&__pyx_kp_s_cannot_specify_out_as_both_a_pos, __pyx_k_cannot_specify_out_as_both_a_pos, sizeof(__pyx_k_cannot_specify_out_as_both_a_pos), 0, 0, 1, 0},
  {&__pyx_n_s_casting, __pyx_k_casting, sizeof(__pyx_k_casting), 0, 0, 1, 1},
  {&__pyx_kp_s_casting_is_not_supported_yet, __pyx_k_casting_is_not_supported_yet, sizeof(__pyx_k_casting_is_not_supported_yet), 0, 0, 1, 0},
  {&__pyx_n_s_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_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_clip, __pyx_k_clip, sizeof(__pyx_k_clip), 0, 0, 1, 1},
  {&__pyx_n_s_clip_2, __pyx_k_clip_2, sizeof(__pyx_k_clip_2), 0, 0, 1, 1},
  {&__pyx_kp_s_clipmode_not_understood, __pyx_k_clipmode_not_understood, sizeof(__pyx_k_clipmode_not_understood), 0, 0, 1, 0},
  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_n_s_clp2_count, __pyx_k_clp2_count, sizeof(__pyx_k_clp2_count), 0, 0, 1, 1},
  {&__pyx_n_s_collections, __pyx_k_collections, sizeof(__pyx_k_collections), 0, 0, 1, 1},
  {&__pyx_n_s_compile_with_cache, __pyx_k_compile_with_cache, sizeof(__pyx_k_compile_with_cache), 0, 0, 1, 1},
  {&__pyx_n_s_compiler, __pyx_k_compiler, sizeof(__pyx_k_compiler), 0, 0, 1, 1},
  {&__pyx_n_s_complex128, __pyx_k_complex128, sizeof(__pyx_k_complex128), 0, 0, 1, 1},
  {&__pyx_n_s_complex64, __pyx_k_complex64, sizeof(__pyx_k_complex64), 0, 0, 1, 1},
  {&__pyx_kp_s_complex_double, __pyx_k_complex_double, sizeof(__pyx_k_complex_double), 0, 0, 1, 0},
  {&__pyx_kp_s_complex_float, __pyx_k_complex_float, sizeof(__pyx_k_complex_float), 0, 0, 1, 0},
  {&__pyx_n_s_conj, __pyx_k_conj, sizeof(__pyx_k_conj), 0, 0, 1, 1},
  {&__pyx_kp_s_const_0_1__raw__1__j, __pyx_k_const_0_1__raw__1__j, sizeof(__pyx_k_const_0_1__raw__1__j), 0, 0, 1, 0},
  {&__pyx_kp_s_const_in_0__type_in_0__raw_in_0, __pyx_k_const_in_0__type_in_0__raw_in_0, sizeof(__pyx_k_const_in_0__type_in_0__raw_in_0), 0, 0, 1, 0},
  {&__pyx_kp_s_const_type_in0_raw_in0__raw_in0, __pyx_k_const_type_in0_raw_in0__raw_in0, sizeof(__pyx_k_const_type_in0_raw_in0__raw_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0},
  {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0},
  {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1},
  {&__pyx_n_s_create_ufunc, __pyx_k_create_ufunc, sizeof(__pyx_k_create_ufunc), 0, 0, 1, 1},
  {&__pyx_n_s_ctype, __pyx_k_ctype, sizeof(__pyx_k_ctype), 0, 0, 1, 1},
  {&__pyx_n_s_ctypes, __pyx_k_ctypes, sizeof(__pyx_k_ctypes), 0, 0, 1, 1},
  {&__pyx_n_s_cublas, __pyx_k_cublas, sizeof(__pyx_k_cublas), 0, 0, 1, 1},
  {&__pyx_n_s_cublas_handle, __pyx_k_cublas_handle, sizeof(__pyx_k_cublas_handle), 0, 0, 1, 1},
  {&__pyx_n_s_cuda, __pyx_k_cuda, sizeof(__pyx_k_cuda), 0, 0, 1, 1},
  {&__pyx_n_s_cupy, __pyx_k_cupy, sizeof(__pyx_k_cupy), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_2, __pyx_k_cupy_2, sizeof(__pyx_k_cupy_2), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_absolute, __pyx_k_cupy_absolute, sizeof(__pyx_k_cupy_absolute), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_all, __pyx_k_cupy_all, sizeof(__pyx_k_cupy_all), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_angle, __pyx_k_cupy_angle, sizeof(__pyx_k_cupy_angle), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_any, __pyx_k_cupy_any, sizeof(__pyx_k_cupy_any), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_argmax, __pyx_k_cupy_argmax, sizeof(__pyx_k_cupy_argmax), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_argmin, __pyx_k_cupy_argmin, sizeof(__pyx_k_cupy_argmin), 0, 0, 1, 1},
  {&__pyx_kp_s_cupy_carray_cuh, __pyx_k_cupy_carray_cuh, sizeof(__pyx_k_cupy_carray_cuh), 0, 0, 1, 0},
  {&__pyx_n_s_cupy_choose, __pyx_k_cupy_choose, sizeof(__pyx_k_cupy_choose), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_choose_clip, __pyx_k_cupy_choose_clip, sizeof(__pyx_k_cupy_choose_clip), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_clip, __pyx_k_cupy_clip, sizeof(__pyx_k_cupy_clip), 0, 0, 1, 1},
  {&__pyx_kp_s_cupy_complex_arithmetic_h, __pyx_k_cupy_complex_arithmetic_h, sizeof(__pyx_k_cupy_complex_arithmetic_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_catrig_h, __pyx_k_cupy_complex_catrig_h, sizeof(__pyx_k_cupy_complex_catrig_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_catrigf_h, __pyx_k_cupy_complex_catrigf_h, sizeof(__pyx_k_cupy_complex_catrigf_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_ccosh_h, __pyx_k_cupy_complex_ccosh_h, sizeof(__pyx_k_cupy_complex_ccosh_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_ccoshf_h, __pyx_k_cupy_complex_ccoshf_h, sizeof(__pyx_k_cupy_complex_ccoshf_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_cexp_h, __pyx_k_cupy_complex_cexp_h, sizeof(__pyx_k_cupy_complex_cexp_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_cexpf_h, __pyx_k_cupy_complex_cexpf_h, sizeof(__pyx_k_cupy_complex_cexpf_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_clog_h, __pyx_k_cupy_complex_clog_h, sizeof(__pyx_k_cupy_complex_clog_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_clogf_h, __pyx_k_cupy_complex_clogf_h, sizeof(__pyx_k_cupy_complex_clogf_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_complex_h, __pyx_k_cupy_complex_complex_h, sizeof(__pyx_k_cupy_complex_complex_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_complex_inl_h, __pyx_k_cupy_complex_complex_inl_h, sizeof(__pyx_k_cupy_complex_complex_inl_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_cpow_h, __pyx_k_cupy_complex_cpow_h, sizeof(__pyx_k_cupy_complex_cpow_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_cproj_h, __pyx_k_cupy_complex_cproj_h, sizeof(__pyx_k_cupy_complex_cproj_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_csinh_h, __pyx_k_cupy_complex_csinh_h, sizeof(__pyx_k_cupy_complex_csinh_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_csinhf_h, __pyx_k_cupy_complex_csinhf_h, sizeof(__pyx_k_cupy_complex_csinhf_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_csqrt_h, __pyx_k_cupy_complex_csqrt_h, sizeof(__pyx_k_cupy_complex_csqrt_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_csqrtf_h, __pyx_k_cupy_complex_csqrtf_h, sizeof(__pyx_k_cupy_complex_csqrtf_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_ctanh_h, __pyx_k_cupy_complex_ctanh_h, sizeof(__pyx_k_cupy_complex_ctanh_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_ctanhf_h, __pyx_k_cupy_complex_ctanhf_h, sizeof(__pyx_k_cupy_complex_ctanhf_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_cuh, __pyx_k_cupy_complex_cuh, sizeof(__pyx_k_cupy_complex_cuh), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_math_private_h, __pyx_k_cupy_complex_math_private_h, sizeof(__pyx_k_cupy_complex_math_private_h), 0, 0, 1, 0},
  {&__pyx_n_s_cupy_concatenate, __pyx_k_cupy_concatenate, sizeof(__pyx_k_cupy_concatenate), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_concatenate_one, __pyx_k_cupy_concatenate_one, sizeof(__pyx_k_cupy_concatenate_one), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_conj, __pyx_k_cupy_conj, sizeof(__pyx_k_cupy_conj), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_copy, __pyx_k_cupy_copy, sizeof(__pyx_k_cupy_copy), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_copy_where, __pyx_k_cupy_copy_where, sizeof(__pyx_k_cupy_copy_where), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_core, __pyx_k_cupy_core, sizeof(__pyx_k_cupy_core), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_core_core, __pyx_k_cupy_core_core, sizeof(__pyx_k_cupy_core_core), 0, 0, 1, 1},
  {&__pyx_kp_s_cupy_core_core_pyx, __pyx_k_cupy_core_core_pyx, sizeof(__pyx_k_cupy_core_core_pyx), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_core_elementwise_pxi, __pyx_k_cupy_core_elementwise_pxi, sizeof(__pyx_k_cupy_core_elementwise_pxi), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_core_reduction_pxi, __pyx_k_cupy_core_reduction_pxi, sizeof(__pyx_k_cupy_core_reduction_pxi), 0, 0, 1, 0},
  {&__pyx_n_s_cupy_cuda, __pyx_k_cupy_cuda, sizeof(__pyx_k_cupy_cuda), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_divide, __pyx_k_cupy_divide, sizeof(__pyx_k_cupy_divide), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_divmod, __pyx_k_cupy_divmod, sizeof(__pyx_k_cupy_divmod), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_floor_divide, __pyx_k_cupy_floor_divide, sizeof(__pyx_k_cupy_floor_divide), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_getitem_mask, __pyx_k_cupy_getitem_mask, sizeof(__pyx_k_cupy_getitem_mask), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_imag, __pyx_k_cupy_imag, sizeof(__pyx_k_cupy_imag), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_imag_setter, __pyx_k_cupy_imag_setter, sizeof(__pyx_k_cupy_imag_setter), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_invert, __pyx_k_cupy_invert, sizeof(__pyx_k_cupy_invert), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_max, __pyx_k_cupy_max, sizeof(__pyx_k_cupy_max), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_mean, __pyx_k_cupy_mean, sizeof(__pyx_k_cupy_mean), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_min, __pyx_k_cupy_min, sizeof(__pyx_k_cupy_min), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_nanmax, __pyx_k_cupy_nanmax, sizeof(__pyx_k_cupy_nanmax), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_nanmin, __pyx_k_cupy_nanmin, sizeof(__pyx_k_cupy_nanmin), 0, 0, 1, 1},
  {&__pyx_kp_s_cupy_ndarray_does_not_have_imagi, __pyx_k_cupy_ndarray_does_not_have_imagi, sizeof(__pyx_k_cupy_ndarray_does_not_have_imagi), 0, 0, 1, 0},
  {&__pyx_n_s_cupy_negative, __pyx_k_cupy_negative, sizeof(__pyx_k_cupy_negative), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_power, __pyx_k_cupy_power, sizeof(__pyx_k_cupy_power), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_prod, __pyx_k_cupy_prod, sizeof(__pyx_k_cupy_prod), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_real, __pyx_k_cupy_real, sizeof(__pyx_k_cupy_real), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_real_setter, __pyx_k_cupy_real_setter, sizeof(__pyx_k_cupy_real_setter), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_remainder, __pyx_k_cupy_remainder, sizeof(__pyx_k_cupy_remainder), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_scatter_add, __pyx_k_cupy_scatter_add, sizeof(__pyx_k_cupy_scatter_add), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_scatter_add_mask, __pyx_k_cupy_scatter_add_mask, sizeof(__pyx_k_cupy_scatter_add_mask), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_scatter_update, __pyx_k_cupy_scatter_update, sizeof(__pyx_k_cupy_scatter_update), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_scatter_update_mask, __pyx_k_cupy_scatter_update_mask, sizeof(__pyx_k_cupy_scatter_update_mask), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_sqrt, __pyx_k_cupy_sqrt, sizeof(__pyx_k_cupy_sqrt), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_sum, __pyx_k_cupy_sum, sizeof(__pyx_k_cupy_sum), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_take, __pyx_k_cupy_take, sizeof(__pyx_k_cupy_take), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_take_0axis, __pyx_k_cupy_take_0axis, sizeof(__pyx_k_cupy_take_0axis), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_true_divide, __pyx_k_cupy_true_divide, sizeof(__pyx_k_cupy_true_divide), 0, 0, 1, 1},
  {&__pyx_kp_s_currently_CuPy_only_supports_sli, __pyx_k_currently_CuPy_only_supports_sli, sizeof(__pyx_k_currently_CuPy_only_supports_sli), 0, 0, 1, 0},
  {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1},
  {&__pyx_kp_s_d_2, __pyx_k_d_2, sizeof(__pyx_k_d_2), 0, 0, 1, 0},
  {&__pyx_kp_s_d_3, __pyx_k_d_3, sizeof(__pyx_k_d_3), 0, 0, 1, 0},
  {&__pyx_kp_s_d_D, __pyx_k_d_D, sizeof(__pyx_k_d_D), 0, 0, 1, 0},
  {&__pyx_kp_s_d_d, __pyx_k_d_d, sizeof(__pyx_k_d_d), 0, 0, 1, 0},
  {&__pyx_kp_s_d_d_2, __pyx_k_d_d_2, sizeof(__pyx_k_d_d_2), 0, 0, 1, 0},
  {&__pyx_kp_s_d_q, __pyx_k_d_q, sizeof(__pyx_k_d_q), 0, 0, 1, 0},
  {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
  {&__pyx_kp_s_dd, __pyx_k_dd, sizeof(__pyx_k_dd), 0, 0, 1, 0},
  {&__pyx_kp_s_dd_d, __pyx_k_dd_d, sizeof(__pyx_k_dd_d), 0, 0, 1, 0},
  {&__pyx_kp_s_dd_dd, __pyx_k_dd_dd, sizeof(__pyx_k_dd_dd), 0, 0, 1, 0},
  {&__pyx_kp_s_ddd_d, __pyx_k_ddd_d, sizeof(__pyx_k_ddd_d), 0, 0, 1, 0},
  {&__pyx_n_s_ddof, __pyx_k_ddof, sizeof(__pyx_k_ddof), 0, 0, 1, 1},
  {&__pyx_n_s_decide_params_type, __pyx_k_decide_params_type, sizeof(__pyx_k_decide_params_type), 0, 0, 1, 1},
  {&__pyx_n_s_default_casting, __pyx_k_default_casting, sizeof(__pyx_k_default_casting), 0, 0, 1, 1},
  {&__pyx_n_s_default_casting_2, __pyx_k_default_casting_2, sizeof(__pyx_k_default_casting_2), 0, 0, 1, 1},
  {&__pyx_n_s_destination, __pyx_k_destination, sizeof(__pyx_k_destination), 0, 0, 1, 1},
  {&__pyx_n_s_device, __pyx_k_device, sizeof(__pyx_k_device), 0, 0, 1, 1},
  {&__pyx_kp_s_dfDFeqlihbQLIHB, __pyx_k_dfDFeqlihbQLIHB, sizeof(__pyx_k_dfDFeqlihbQLIHB), 0, 0, 1, 0},
  {&__pyx_n_s_dgeam, __pyx_k_dgeam, sizeof(__pyx_k_dgeam), 0, 0, 1, 1},
  {&__pyx_n_s_dgemmBatched, __pyx_k_dgemmBatched, sizeof(__pyx_k_dgemmBatched), 0, 0, 1, 1},
  {&__pyx_n_s_diagonal, __pyx_k_diagonal, sizeof(__pyx_k_diagonal), 0, 0, 1, 1},
  {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
  {&__pyx_n_s_dirname, __pyx_k_dirname, sizeof(__pyx_k_dirname), 0, 0, 1, 1},
  {&__pyx_n_s_divide, __pyx_k_divide, sizeof(__pyx_k_divide), 0, 0, 1, 1},
  {&__pyx_n_s_divmod, __pyx_k_divmod, sizeof(__pyx_k_divmod), 0, 0, 1, 1},
  {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  {&__pyx_n_s_doc_2, __pyx_k_doc_2, sizeof(__pyx_k_doc_2), 0, 0, 1, 1},
  {&__pyx_n_s_double, __pyx_k_double, sizeof(__pyx_k_double), 0, 0, 1, 1},
  {&__pyx_n_s_dst_dtype, __pyx_k_dst_dtype, sizeof(__pyx_k_dst_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
  {&__pyx_kp_s_dtype_is_None, __pyx_k_dtype_is_None, sizeof(__pyx_k_dtype_is_None), 0, 0, 1, 0},
  {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1},
  {&__pyx_n_s_dump, __pyx_k_dump, sizeof(__pyx_k_dump), 0, 0, 1, 1},
  {&__pyx_n_s_dumps, __pyx_k_dumps, sizeof(__pyx_k_dumps), 0, 0, 1, 1},
  {&__pyx_kp_s_duplicate_value_in_axis, __pyx_k_duplicate_value_in_axis, sizeof(__pyx_k_duplicate_value_in_axis), 0, 0, 1, 0},
  {&__pyx_n_s_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 0, 1, 1},
  {&__pyx_kp_s_e_2, __pyx_k_e_2, sizeof(__pyx_k_e_2), 0, 0, 1, 0},
  {&__pyx_kp_s_e_e, __pyx_k_e_e, sizeof(__pyx_k_e_e), 0, 0, 1, 0},
  {&__pyx_kp_s_e_e_2, __pyx_k_e_e_2, sizeof(__pyx_k_e_e_2), 0, 0, 1, 0},
  {&__pyx_kp_s_e_q, __pyx_k_e_q, sizeof(__pyx_k_e_q), 0, 0, 1, 0},
  {&__pyx_n_s_each_size, __pyx_k_each_size, sizeof(__pyx_k_each_size), 0, 0, 1, 1},
  {&__pyx_kp_s_ee, __pyx_k_ee, sizeof(__pyx_k_ee), 0, 0, 1, 0},
  {&__pyx_kp_s_ee_e, __pyx_k_ee_e, sizeof(__pyx_k_ee_e), 0, 0, 1, 0},
  {&__pyx_kp_s_ee_ee, __pyx_k_ee_ee, sizeof(__pyx_k_ee_ee), 0, 0, 1, 0},
  {&__pyx_kp_s_eee_e, __pyx_k_eee_e, sizeof(__pyx_k_eee_e), 0, 0, 1, 0},
  {&__pyx_n_s_elem, __pyx_k_elem, sizeof(__pyx_k_elem), 0, 0, 1, 1},
  {&__pyx_n_s_elementwise_copy, __pyx_k_elementwise_copy, sizeof(__pyx_k_elementwise_copy), 0, 0, 1, 1},
  {&__pyx_n_s_elementwise_copy_where, __pyx_k_elementwise_copy_where, sizeof(__pyx_k_elementwise_copy_where), 0, 0, 1, 1},
  {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1},
  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
  {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  {&__pyx_n_s_equal, __pyx_k_equal, sizeof(__pyx_k_equal), 0, 0, 1, 1},
  {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
  {&__pyx_n_s_exists, __pyx_k_exists, sizeof(__pyx_k_exists), 0, 0, 1, 1},
  {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
  {&__pyx_n_s_extend, __pyx_k_extend, sizeof(__pyx_k_extend), 0, 0, 1, 1},
  {&__pyx_kp_s_extern_C___global___void_name_C, __pyx_k_extern_C___global___void_name_C, sizeof(__pyx_k_extern_C___global___void_name_C), 0, 0, 1, 0},
  {&__pyx_kp_s_extern_C___global___void_name_c, __pyx_k_extern_C___global___void_name_c, sizeof(__pyx_k_extern_C___global___void_name_c), 0, 0, 1, 0},
  {&__pyx_kp_s_extern_C___global___void_name_c_2, __pyx_k_extern_C___global___void_name_c_2, sizeof(__pyx_k_extern_C___global___void_name_c_2), 0, 0, 1, 0},
  {&__pyx_kp_s_extern_C___global___void_name_c_3, __pyx_k_extern_C___global___void_name_c_3, sizeof(__pyx_k_extern_C___global___void_name_c_3), 0, 0, 1, 0},
  {&__pyx_n_s_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 0, 1, 1},
  {&__pyx_kp_s_f_2, __pyx_k_f_2, sizeof(__pyx_k_f_2), 0, 0, 1, 0},
  {&__pyx_kp_s_f_F, __pyx_k_f_F, sizeof(__pyx_k_f_F), 0, 0, 1, 0},
  {&__pyx_kp_s_f_f, __pyx_k_f_f, sizeof(__pyx_k_f_f), 0, 0, 1, 0},
  {&__pyx_kp_s_f_f_2, __pyx_k_f_f_2, sizeof(__pyx_k_f_f_2), 0, 0, 1, 0},
  {&__pyx_kp_s_f_q, __pyx_k_f_q, sizeof(__pyx_k_f_q), 0, 0, 1, 0},
  {&__pyx_n_s_false, __pyx_k_false, sizeof(__pyx_k_false), 0, 0, 1, 1},
  {&__pyx_n_s_fdFD, __pyx_k_fdFD, sizeof(__pyx_k_fdFD), 0, 0, 1, 1},
  {&__pyx_kp_s_ff, __pyx_k_ff, sizeof(__pyx_k_ff), 0, 0, 1, 0},
  {&__pyx_kp_s_ff_f, __pyx_k_ff_f, sizeof(__pyx_k_ff_f), 0, 0, 1, 0},
  {&__pyx_kp_s_ff_ff, __pyx_k_ff_ff, sizeof(__pyx_k_ff_ff), 0, 0, 1, 0},
  {&__pyx_kp_s_fff_f, __pyx_k_fff_f, sizeof(__pyx_k_fff_f), 0, 0, 1, 0},
  {&__pyx_n_s_fid, __pyx_k_fid, sizeof(__pyx_k_fid), 0, 0, 1, 1},
  {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1},
  {&__pyx_n_s_fill, __pyx_k_fill, sizeof(__pyx_k_fill), 0, 0, 1, 1},
  {&__pyx_n_s_find_common_type, __pyx_k_find_common_type, sizeof(__pyx_k_find_common_type), 0, 0, 1, 1},
  {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
  {&__pyx_n_s_flatten, __pyx_k_flatten, sizeof(__pyx_k_flatten), 0, 0, 1, 1},
  {&__pyx_n_s_float, __pyx_k_float, sizeof(__pyx_k_float), 0, 0, 1, 1},
  {&__pyx_n_s_float16, __pyx_k_float16, sizeof(__pyx_k_float16), 0, 0, 1, 1},
  {&__pyx_n_s_float32, __pyx_k_float32, sizeof(__pyx_k_float32), 0, 0, 1, 1},
  {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1},
  {&__pyx_n_s_floating, __pyx_k_floating, sizeof(__pyx_k_floating), 0, 0, 1, 1},
  {&__pyx_n_s_floor_divide, __pyx_k_floor_divide, sizeof(__pyx_k_floor_divide), 0, 0, 1, 1},
  {&__pyx_n_s_fmt, __pyx_k_fmt, sizeof(__pyx_k_fmt), 0, 0, 1, 1},
  {&__pyx_n_s_for_each_device, __pyx_k_for_each_device, sizeof(__pyx_k_for_each_device), 0, 0, 1, 1},
  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1},
  {&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1},
  {&__pyx_n_s_frombuffer, __pyx_k_frombuffer, sizeof(__pyx_k_frombuffer), 0, 0, 1, 1},
  {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  {&__pyx_n_s_get_as_parameter, __pyx_k_get_as_parameter, sizeof(__pyx_k_get_as_parameter), 0, 0, 1, 1},
  {&__pyx_n_s_get_elementwise_kernel, __pyx_k_get_elementwise_kernel, sizeof(__pyx_k_get_elementwise_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_get_elementwise_kernel_locals_g, __pyx_k_get_elementwise_kernel_locals_g, sizeof(__pyx_k_get_elementwise_kernel_locals_g), 0, 0, 1, 1},
  {&__pyx_n_s_get_param_info, __pyx_k_get_param_info, sizeof(__pyx_k_get_param_info), 0, 0, 1, 1},
  {&__pyx_n_s_get_reduction_kernel, __pyx_k_get_reduction_kernel, sizeof(__pyx_k_get_reduction_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_get_reduction_kernel_locals_gen, __pyx_k_get_reduction_kernel_locals_gen, sizeof(__pyx_k_get_reduction_kernel_locals_gen), 0, 0, 1, 1},
  {&__pyx_n_s_get_simple_elementwise_kernel, __pyx_k_get_simple_elementwise_kernel, sizeof(__pyx_k_get_simple_elementwise_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_get_simple_reduction_function, __pyx_k_get_simple_reduction_function, sizeof(__pyx_k_get_simple_reduction_function), 0, 0, 1, 1},
  {&__pyx_n_s_get_ufunc_kernel, __pyx_k_get_ufunc_kernel, sizeof(__pyx_k_get_ufunc_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_getenv, __pyx_k_getenv, sizeof(__pyx_k_getenv), 0, 0, 1, 1},
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  {&__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_k_got_differing_extents_in_dimensi, sizeof(__pyx_k_got_differing_extents_in_dimensi), 0, 0, 1, 0},
  {&__pyx_n_s_greater, __pyx_k_greater, sizeof(__pyx_k_greater), 0, 0, 1, 1},
  {&__pyx_n_s_greater_equal, __pyx_k_greater_equal, sizeof(__pyx_k_greater_equal), 0, 0, 1, 1},
  {&__pyx_n_s_grid, __pyx_k_grid, sizeof(__pyx_k_grid), 0, 0, 1, 1},
  {&__pyx_kp_s_h, __pyx_k_h, sizeof(__pyx_k_h), 0, 0, 1, 0},
  {&__pyx_kp_s_h_d, __pyx_k_h_d, sizeof(__pyx_k_h_d), 0, 0, 1, 0},
  {&__pyx_kp_s_h_h, __pyx_k_h_h, sizeof(__pyx_k_h_h), 0, 0, 1, 0},
  {&__pyx_kp_s_h_h_2, __pyx_k_h_h_2, sizeof(__pyx_k_h_h_2), 0, 0, 1, 0},
  {&__pyx_kp_s_h_l, __pyx_k_h_l, sizeof(__pyx_k_h_l), 0, 0, 1, 0},
  {&__pyx_kp_s_h_q, __pyx_k_h_q, sizeof(__pyx_k_h_q), 0, 0, 1, 0},
  {&__pyx_n_s_has_element, __pyx_k_has_element, sizeof(__pyx_k_has_element), 0, 0, 1, 1},
  {&__pyx_n_s_hex, __pyx_k_hex, sizeof(__pyx_k_hex), 0, 0, 1, 1},
  {&__pyx_kp_s_hh, __pyx_k_hh, sizeof(__pyx_k_hh), 0, 0, 1, 0},
  {&__pyx_kp_s_hh_d, __pyx_k_hh_d, sizeof(__pyx_k_hh_d), 0, 0, 1, 0},
  {&__pyx_kp_s_hh_h, __pyx_k_hh_h, sizeof(__pyx_k_hh_h), 0, 0, 1, 0},
  {&__pyx_kp_s_hh_hh, __pyx_k_hh_hh, sizeof(__pyx_k_hh_hh), 0, 0, 1, 0},
  {&__pyx_kp_s_hhh_h, __pyx_k_hhh_h, sizeof(__pyx_k_hhh_h), 0, 0, 1, 0},
  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  {&__pyx_kp_s_i_2, __pyx_k_i_2, sizeof(__pyx_k_i_2), 0, 0, 1, 0},
  {&__pyx_kp_s_i_d, __pyx_k_i_d, sizeof(__pyx_k_i_d), 0, 0, 1, 0},
  {&__pyx_kp_s_i_i, __pyx_k_i_i, sizeof(__pyx_k_i_i), 0, 0, 1, 0},
  {&__pyx_kp_s_i_i_2, __pyx_k_i_i_2, sizeof(__pyx_k_i_i_2), 0, 0, 1, 0},
  {&__pyx_kp_s_i_l, __pyx_k_i_l, sizeof(__pyx_k_i_l), 0, 0, 1, 0},
  {&__pyx_kp_s_i_q, __pyx_k_i_q, sizeof(__pyx_k_i_q), 0, 0, 1, 0},
  {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
  {&__pyx_n_s_identity, __pyx_k_identity, sizeof(__pyx_k_identity), 0, 0, 1, 1},
  {&__pyx_kp_s_if_in1_0_out0_0_out1_0_else_out, __pyx_k_if_in1_0_out0_0_out1_0_else_out, sizeof(__pyx_k_if_in1_0_out0_0_out1_0_else_out), 0, 0, 1, 0},
  {&__pyx_kp_s_if_in1_out0_in0, __pyx_k_if_in1_out0_in0, sizeof(__pyx_k_if_in1_out0_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_if_mask_a_a_v_mask_scanned_1, __pyx_k_if_mask_a_a_v_mask_scanned_1, sizeof(__pyx_k_if_mask_a_a_v_mask_scanned_1), 0, 0, 1, 0},
  {&__pyx_kp_s_if_mask_a_v_mask_scanned_1, __pyx_k_if_mask_a_v_mask_scanned_1, sizeof(__pyx_k_if_mask_a_v_mask_scanned_1), 0, 0, 1, 0},
  {&__pyx_kp_s_if_mask_out_mask_scanned_1_a, __pyx_k_if_mask_out_mask_scanned_1_a, sizeof(__pyx_k_if_mask_out_mask_scanned_1_a), 0, 0, 1, 0},
  {&__pyx_kp_s_ii, __pyx_k_ii, sizeof(__pyx_k_ii), 0, 0, 1, 0},
  {&__pyx_kp_s_ii_d, __pyx_k_ii_d, sizeof(__pyx_k_ii_d), 0, 0, 1, 0},
  {&__pyx_kp_s_ii_i, __pyx_k_ii_i, sizeof(__pyx_k_ii_i), 0, 0, 1, 0},
  {&__pyx_kp_s_ii_ii, __pyx_k_ii_ii, sizeof(__pyx_k_ii_ii), 0, 0, 1, 0},
  {&__pyx_kp_s_iii_i, __pyx_k_iii_i, sizeof(__pyx_k_iii_i), 0, 0, 1, 0},
  {&__pyx_n_s_iinfo, __pyx_k_iinfo, sizeof(__pyx_k_iinfo), 0, 0, 1, 1},
  {&__pyx_n_s_imag, __pyx_k_imag, sizeof(__pyx_k_imag), 0, 0, 1, 1},
  {&__pyx_n_s_imag_setter, __pyx_k_imag_setter, sizeof(__pyx_k_imag_setter), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_in0, __pyx_k_in0, sizeof(__pyx_k_in0), 0, 0, 1, 1},
  {&__pyx_kp_s_in0_type_in0_raw_0, __pyx_k_in0_type_in0_raw_0, sizeof(__pyx_k_in0_type_in0_raw_0), 0, 0, 1, 0},
  {&__pyx_n_s_in_arg_dtype, __pyx_k_in_arg_dtype, sizeof(__pyx_k_in_arg_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_in_args, __pyx_k_in_args, sizeof(__pyx_k_in_args), 0, 0, 1, 1},
  {&__pyx_n_s_in_args_dtype, __pyx_k_in_args_dtype, sizeof(__pyx_k_in_args_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_in_indexer, __pyx_k_in_indexer, sizeof(__pyx_k_in_indexer), 0, 0, 1, 1},
  {&__pyx_n_s_in_ndarray_types, __pyx_k_in_ndarray_types, sizeof(__pyx_k_in_ndarray_types), 0, 0, 1, 1},
  {&__pyx_n_s_in_params, __pyx_k_in_params, sizeof(__pyx_k_in_params), 0, 0, 1, 1},
  {&__pyx_n_s_in_params_2, __pyx_k_in_params_2, sizeof(__pyx_k_in_params_2), 0, 0, 1, 1},
  {&__pyx_n_s_in_sahpe, __pyx_k_in_sahpe, sizeof(__pyx_k_in_sahpe), 0, 0, 1, 1},
  {&__pyx_n_s_in_shape, __pyx_k_in_shape, sizeof(__pyx_k_in_shape), 0, 0, 1, 1},
  {&__pyx_n_s_in_str, __pyx_k_in_str, sizeof(__pyx_k_in_str), 0, 0, 1, 1},
  {&__pyx_n_s_in_types, __pyx_k_in_types, sizeof(__pyx_k_in_types), 0, 0, 1, 1},
  {&__pyx_n_s_include, __pyx_k_include, sizeof(__pyx_k_include), 0, 0, 1, 1},
  {&__pyx_kp_s_include_s, __pyx_k_include_s, sizeof(__pyx_k_include_s), 0, 0, 1, 0},
  {&__pyx_n_s_inclusive_scan_kernel, __pyx_k_inclusive_scan_kernel, sizeof(__pyx_k_inclusive_scan_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_inclusive_scan_kernel_2, __pyx_k_inclusive_scan_kernel_2, sizeof(__pyx_k_inclusive_scan_kernel_2), 0, 0, 1, 1},
  {&__pyx_kp_s_incompatible_shape, __pyx_k_incompatible_shape, sizeof(__pyx_k_incompatible_shape), 0, 0, 1, 0},
  {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1},
  {&__pyx_n_s_index_dtype, __pyx_k_index_dtype, sizeof(__pyx_k_index_dtype), 0, 0, 1, 1},
  {&__pyx_kp_s_index_out_of_range, __pyx_k_index_out_of_range, sizeof(__pyx_k_index_out_of_range), 0, 0, 1, 0},
  {&__pyx_n_s_indexer, __pyx_k_indexer, sizeof(__pyx_k_indexer), 0, 0, 1, 1},
  {&__pyx_n_s_indices, __pyx_k_indices, sizeof(__pyx_k_indices), 0, 0, 1, 1},
  {&__pyx_n_s_indices_or_sections, __pyx_k_indices_or_sections, sizeof(__pyx_k_indices_or_sections), 0, 0, 1, 1},
  {&__pyx_kp_s_inf, __pyx_k_inf, sizeof(__pyx_k_inf), 0, 0, 1, 0},
  {&__pyx_n_s_inf_2, __pyx_k_inf_2, sizeof(__pyx_k_inf_2), 0, 0, 1, 1},
  {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
  {&__pyx_n_s_inout_args, __pyx_k_inout_args, sizeof(__pyx_k_inout_args), 0, 0, 1, 1},
  {&__pyx_n_s_input_expr, __pyx_k_input_expr, sizeof(__pyx_k_input_expr), 0, 0, 1, 1},
  {&__pyx_n_s_input_expr_2, __pyx_k_input_expr_2, sizeof(__pyx_k_input_expr_2), 0, 0, 1, 1},
  {&__pyx_kp_s_input_operand_has_more_dimension, __pyx_k_input_operand_has_more_dimension, sizeof(__pyx_k_input_operand_has_more_dimension), 0, 0, 1, 0},
  {&__pyx_n_s_int, __pyx_k_int, sizeof(__pyx_k_int), 0, 0, 1, 1},
  {&__pyx_n_s_int16, __pyx_k_int16, sizeof(__pyx_k_int16), 0, 0, 1, 1},
  {&__pyx_n_s_int32, __pyx_k_int32, sizeof(__pyx_k_int32), 0, 0, 1, 1},
  {&__pyx_kp_s_int32__block_stride, __pyx_k_int32__block_stride, sizeof(__pyx_k_int32__block_stride), 0, 0, 1, 0},
  {&__pyx_n_s_int64, __pyx_k_int64, sizeof(__pyx_k_int64), 0, 0, 1, 1},
  {&__pyx_n_s_int8, __pyx_k_int8, sizeof(__pyx_k_int8), 0, 0, 1, 1},
  {&__pyx_kp_s_int_axis_ind__ind_get_axis_int, __pyx_k_int_axis_ind__ind_get_axis_int, sizeof(__pyx_k_int_axis_ind__ind_get_axis_int), 0, 0, 1, 0},
  {&__pyx_kp_s_int_middle_i_base_int_top_middl, __pyx_k_int_middle_i_base_int_top_middl, sizeof(__pyx_k_int_middle_i_base_int_top_middl), 0, 0, 1, 0},
  {&__pyx_n_s_integer, __pyx_k_integer, sizeof(__pyx_k_integer), 0, 0, 1, 1},
  {&__pyx_n_s_integer_types, __pyx_k_integer_types, sizeof(__pyx_k_integer_types), 0, 0, 1, 1},
  {&__pyx_n_s_intp, __pyx_k_intp, sizeof(__pyx_k_intp), 0, 0, 1, 1},
  {&__pyx_kp_s_invalid_entry_in_choice_array, __pyx_k_invalid_entry_in_choice_array, sizeof(__pyx_k_invalid_entry_in_choice_array), 0, 0, 1, 0},
  {&__pyx_n_s_invert, __pyx_k_invert, sizeof(__pyx_k_invert), 0, 0, 1, 1},
  {&__pyx_n_s_is_const, __pyx_k_is_const, sizeof(__pyx_k_is_const), 0, 0, 1, 1},
  {&__pyx_n_s_is_valid_kernel_name, __pyx_k_is_valid_kernel_name, sizeof(__pyx_k_is_valid_kernel_name), 0, 0, 1, 1},
  {&__pyx_n_s_isscalar, __pyx_k_isscalar, sizeof(__pyx_k_isscalar), 0, 0, 1, 1},
  {&__pyx_n_s_item, __pyx_k_item, sizeof(__pyx_k_item), 0, 0, 1, 1},
  {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
  {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1},
  {&__pyx_kp_s_itemsize_0_for_cython_array, __pyx_k_itemsize_0_for_cython_array, sizeof(__pyx_k_itemsize_0_for_cython_array), 0, 0, 1, 0},
  {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
  {&__pyx_n_s_k, __pyx_k_k, sizeof(__pyx_k_k), 0, 0, 1, 1},
  {&__pyx_n_s_keepdims, __pyx_k_keepdims, sizeof(__pyx_k_keepdims), 0, 0, 1, 1},
  {&__pyx_n_s_kern, __pyx_k_kern, sizeof(__pyx_k_kern), 0, 0, 1, 1},
  {&__pyx_n_s_kernel, __pyx_k_kernel, sizeof(__pyx_k_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_kernel_params, __pyx_k_kernel_params, sizeof(__pyx_k_kernel_params), 0, 0, 1, 1},
  {&__pyx_n_s_kind, __pyx_k_kind, sizeof(__pyx_k_kind), 0, 0, 1, 1},
  {&__pyx_n_s_kth, __pyx_k_kth, sizeof(__pyx_k_kth), 0, 0, 1, 1},
  {&__pyx_kp_s_kth_out_of_bounds, __pyx_k_kth_out_of_bounds, sizeof(__pyx_k_kth_out_of_bounds), 0, 0, 1, 0},
  {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
  {&__pyx_kp_s_l, __pyx_k_l, sizeof(__pyx_k_l), 0, 0, 1, 0},
  {&__pyx_kp_s_l_2, __pyx_k_l_2, sizeof(__pyx_k_l_2), 0, 0, 1, 0},
  {&__pyx_kp_s_l_d, __pyx_k_l_d, sizeof(__pyx_k_l_d), 0, 0, 1, 0},
  {&__pyx_kp_s_l_l, __pyx_k_l_l, sizeof(__pyx_k_l_l), 0, 0, 1, 0},
  {&__pyx_kp_s_l_l_2, __pyx_k_l_l_2, sizeof(__pyx_k_l_l_2), 0, 0, 1, 0},
  {&__pyx_kp_s_l_q, __pyx_k_l_q, sizeof(__pyx_k_l_q), 0, 0, 1, 0},
  {&__pyx_n_s_laxis, __pyx_k_laxis, sizeof(__pyx_k_laxis), 0, 0, 1, 1},
  {&__pyx_n_s_left_shift, __pyx_k_left_shift, sizeof(__pyx_k_left_shift), 0, 0, 1, 1},
  {&__pyx_kp_s_len_of_unsized_object, __pyx_k_len_of_unsized_object, sizeof(__pyx_k_len_of_unsized_object), 0, 0, 1, 0},
  {&__pyx_kp_s_len_shape_len_strides, __pyx_k_len_shape_len_strides, sizeof(__pyx_k_len_shape_len_strides), 0, 0, 1, 0},
  {&__pyx_n_s_less, __pyx_k_less, sizeof(__pyx_k_less), 0, 0, 1, 1},
  {&__pyx_n_s_less_equal, __pyx_k_less_equal, sizeof(__pyx_k_less_equal), 0, 0, 1, 1},
  {&__pyx_n_s_li, __pyx_k_li, sizeof(__pyx_k_li), 0, 0, 1, 1},
  {&__pyx_n_s_linear_launch, __pyx_k_linear_launch, sizeof(__pyx_k_linear_launch), 0, 0, 1, 1},
  {&__pyx_kp_s_ll, __pyx_k_ll, sizeof(__pyx_k_ll), 0, 0, 1, 0},
  {&__pyx_kp_s_ll_d, __pyx_k_ll_d, sizeof(__pyx_k_ll_d), 0, 0, 1, 0},
  {&__pyx_kp_s_ll_l, __pyx_k_ll_l, sizeof(__pyx_k_ll_l), 0, 0, 1, 0},
  {&__pyx_kp_s_ll_ll, __pyx_k_ll_ll, sizeof(__pyx_k_ll_ll), 0, 0, 1, 0},
  {&__pyx_kp_s_lll_l, __pyx_k_lll_l, sizeof(__pyx_k_lll_l), 0, 0, 1, 0},
  {&__pyx_n_s_long, __pyx_k_long, sizeof(__pyx_k_long), 0, 0, 1, 1},
  {&__pyx_kp_s_long_long, __pyx_k_long_long, sizeof(__pyx_k_long_long), 0, 0, 1, 0},
  {&__pyx_n_s_loop_prep, __pyx_k_loop_prep, sizeof(__pyx_k_loop_prep), 0, 0, 1, 1},
  {&__pyx_n_s_m, __pyx_k_m, sizeof(__pyx_k_m), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_map, __pyx_k_map, sizeof(__pyx_k_map), 0, 0, 1, 1},
  {&__pyx_n_s_map_expr, __pyx_k_map_expr, sizeof(__pyx_k_map_expr), 0, 0, 1, 1},
  {&__pyx_n_s_mask, __pyx_k_mask, sizeof(__pyx_k_mask), 0, 0, 1, 1},
  {&__pyx_n_s_max, __pyx_k_max, sizeof(__pyx_k_max), 0, 0, 1, 1},
  {&__pyx_n_s_maximum, __pyx_k_maximum, sizeof(__pyx_k_maximum), 0, 0, 1, 1},
  {&__pyx_n_s_maxsize, __pyx_k_maxsize, sizeof(__pyx_k_maxsize), 0, 0, 1, 1},
  {&__pyx_n_s_mean, __pyx_k_mean, sizeof(__pyx_k_mean), 0, 0, 1, 1},
  {&__pyx_n_s_memoize, __pyx_k_memoize, sizeof(__pyx_k_memoize), 0, 0, 1, 1},
  {&__pyx_n_s_memptr, __pyx_k_memptr, sizeof(__pyx_k_memptr), 0, 0, 1, 1},
  {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1},
  {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  {&__pyx_n_s_min, __pyx_k_min, sizeof(__pyx_k_min), 0, 0, 1, 1},
  {&__pyx_kp_s_min_max_st_type_in0_raw, __pyx_k_min_max_st_type_in0_raw, sizeof(__pyx_k_min_max_st_type_in0_raw), 0, 0, 1, 0},
  {&__pyx_kp_s_min_max_st_type_in0_raw_in0, __pyx_k_min_max_st_type_in0_raw_in0, sizeof(__pyx_k_min_max_st_type_in0_raw_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_min_max_st_type_in0_raw_in0__J, __pyx_k_min_max_st_type_in0_raw_in0__J, sizeof(__pyx_k_min_max_st_type_in0_raw_in0__J), 0, 0, 1, 0},
  {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  {&__pyx_n_s_module_2, __pyx_k_module_2, sizeof(__pyx_k_module_2), 0, 0, 1, 1},
  {&__pyx_n_s_moves, __pyx_k_moves, sizeof(__pyx_k_moves), 0, 0, 1, 1},
  {&__pyx_n_s_multiply, __pyx_k_multiply, sizeof(__pyx_k_multiply), 0, 0, 1, 1},
  {&__pyx_kp_s_my_argmax_a_b, __pyx_k_my_argmax_a_b, sizeof(__pyx_k_my_argmax_a_b), 0, 0, 1, 0},
  {&__pyx_kp_s_my_argmax_float_a_b, __pyx_k_my_argmax_float_a_b, sizeof(__pyx_k_my_argmax_float_a_b), 0, 0, 1, 0},
  {&__pyx_kp_s_my_argmin_a_b, __pyx_k_my_argmin_a_b, sizeof(__pyx_k_my_argmin_a_b), 0, 0, 1, 0},
  {&__pyx_kp_s_my_argmin_float_a_b, __pyx_k_my_argmin_float_a_b, sizeof(__pyx_k_my_argmin_float_a_b), 0, 0, 1, 0},
  {&__pyx_kp_s_my_max_a_b, __pyx_k_my_max_a_b, sizeof(__pyx_k_my_max_a_b), 0, 0, 1, 0},
  {&__pyx_kp_s_my_max_float_a_b, __pyx_k_my_max_float_a_b, sizeof(__pyx_k_my_max_float_a_b), 0, 0, 1, 0},
  {&__pyx_kp_s_my_min_a_b, __pyx_k_my_min_a_b, sizeof(__pyx_k_my_min_a_b), 0, 0, 1, 0},
  {&__pyx_kp_s_my_min_float_a_b, __pyx_k_my_min_float_a_b, sizeof(__pyx_k_my_min_float_a_b), 0, 0, 1, 0},
  {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1},
  {&__pyx_n_s_n_args, __pyx_k_n_args, sizeof(__pyx_k_n_args), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
  {&__pyx_n_s_nanmax, __pyx_k_nanmax, sizeof(__pyx_k_nanmax), 0, 0, 1, 1},
  {&__pyx_n_s_nanmin, __pyx_k_nanmin, sizeof(__pyx_k_nanmin), 0, 0, 1, 1},
  {&__pyx_n_s_nargs, __pyx_k_nargs, sizeof(__pyx_k_nargs), 0, 0, 1, 1},
  {&__pyx_n_s_nbytes, __pyx_k_nbytes, sizeof(__pyx_k_nbytes), 0, 0, 1, 1},
  {&__pyx_n_s_ndarray, __pyx_k_ndarray, sizeof(__pyx_k_ndarray), 0, 0, 1, 1},
  {&__pyx_kp_u_ndarray___getitem___line_1394, __pyx_k_ndarray___getitem___line_1394, sizeof(__pyx_k_ndarray___getitem___line_1394), 0, 1, 0, 0},
  {&__pyx_kp_u_ndarray___setitem___line_1584, __pyx_k_ndarray___setitem___line_1584, sizeof(__pyx_k_ndarray___setitem___line_1584), 0, 1, 0, 0},
  {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1},
  {&__pyx_n_s_ndmin, __pyx_k_ndmin, sizeof(__pyx_k_ndmin), 0, 0, 1, 1},
  {&__pyx_n_s_negative, __pyx_k_negative, sizeof(__pyx_k_negative), 0, 0, 1, 1},
  {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
  {&__pyx_n_s_newaxis, __pyx_k_newaxis, sizeof(__pyx_k_newaxis), 0, 0, 1, 1},
  {&__pyx_n_s_newshape, __pyx_k_newshape, sizeof(__pyx_k_newshape), 0, 0, 1, 1},
  {&__pyx_n_s_nin, __pyx_k_nin, sizeof(__pyx_k_nin), 0, 0, 1, 1},
  {&__pyx_n_s_no_bool, __pyx_k_no_bool, sizeof(__pyx_k_no_bool), 0, 0, 1, 1},
  {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0},
  {&__pyx_kp_s_non_scalar_numpy_ndarray_cannot, __pyx_k_non_scalar_numpy_ndarray_cannot, sizeof(__pyx_k_non_scalar_numpy_ndarray_cannot), 0, 0, 1, 0},
  {&__pyx_n_s_nonzero_1d_kernel, __pyx_k_nonzero_1d_kernel, sizeof(__pyx_k_nonzero_1d_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_nonzero_1d_kernel_2, __pyx_k_nonzero_1d_kernel_2, sizeof(__pyx_k_nonzero_1d_kernel_2), 0, 0, 1, 1},
  {&__pyx_n_s_nonzero_kernel, __pyx_k_nonzero_kernel, sizeof(__pyx_k_nonzero_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_nonzero_kernel_2, __pyx_k_nonzero_kernel_2, sizeof(__pyx_k_nonzero_kernel_2), 0, 0, 1, 1},
  {&__pyx_n_s_normpath, __pyx_k_normpath, sizeof(__pyx_k_normpath), 0, 0, 1, 1},
  {&__pyx_n_s_not_equal, __pyx_k_not_equal, sizeof(__pyx_k_not_equal), 0, 0, 1, 1},
  {&__pyx_n_s_nout, __pyx_k_nout, sizeof(__pyx_k_nout), 0, 0, 1, 1},
  {&__pyx_n_s_null, __pyx_k_null, sizeof(__pyx_k_null), 0, 0, 1, 1},
  {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  {&__pyx_n_s_nvcc, __pyx_k_nvcc, sizeof(__pyx_k_nvcc), 0, 0, 1, 1},
  {&__pyx_kp_s_nvcc_exe, __pyx_k_nvcc_exe, sizeof(__pyx_k_nvcc_exe), 0, 0, 1, 0},
  {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
  {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
  {&__pyx_n_s_oct, __pyx_k_oct, sizeof(__pyx_k_oct), 0, 0, 1, 1},
  {&__pyx_n_s_offset, __pyx_k_offset, sizeof(__pyx_k_offset), 0, 0, 1, 1},
  {&__pyx_kp_s_only_integers_slices_ellipsis_nu, __pyx_k_only_integers_slices_ellipsis_nu, sizeof(__pyx_k_only_integers_slices_ellipsis_nu), 0, 0, 1, 0},
  {&__pyx_n_s_op, __pyx_k_op, sizeof(__pyx_k_op), 0, 0, 1, 1},
  {&__pyx_n_s_open, __pyx_k_open, sizeof(__pyx_k_open), 0, 0, 1, 1},
  {&__pyx_kp_s_operands_could_not_be_broadcast, __pyx_k_operands_could_not_be_broadcast, sizeof(__pyx_k_operands_could_not_be_broadcast), 0, 0, 1, 0},
  {&__pyx_n_s_operation, __pyx_k_operation, sizeof(__pyx_k_operation), 0, 0, 1, 1},
  {&__pyx_n_s_ops, __pyx_k_ops, sizeof(__pyx_k_ops), 0, 0, 1, 1},
  {&__pyx_n_s_ops_2, __pyx_k_ops_2, sizeof(__pyx_k_ops_2), 0, 0, 1, 1},
  {&__pyx_n_s_options, __pyx_k_options, sizeof(__pyx_k_options), 0, 0, 1, 1},
  {&__pyx_n_s_order, __pyx_k_order, sizeof(__pyx_k_order), 0, 0, 1, 1},
  {&__pyx_kp_s_order_not_understood, __pyx_k_order_not_understood, sizeof(__pyx_k_order_not_understood), 0, 0, 1, 0},
  {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
  {&__pyx_n_s_out, __pyx_k_out, sizeof(__pyx_k_out), 0, 0, 1, 1},
  {&__pyx_kp_s_out0_0, __pyx_k_out0_0, sizeof(__pyx_k_out0_0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0__floor_divide_in0_in1, __pyx_k_out0__floor_divide_in0_in1, sizeof(__pyx_k_out0__floor_divide_in0_in1), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_a, __pyx_k_out0_a, sizeof(__pyx_k_out0_a), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_a__type_reduce__in_ind_size, __pyx_k_out0_a__type_reduce__in_ind_size, sizeof(__pyx_k_out0_a__type_reduce__in_ind_size), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_a_index, __pyx_k_out0_a_index, sizeof(__pyx_k_out0_a_index), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_a_value, __pyx_k_out0_a_value, sizeof(__pyx_k_out0_a_value), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_abs_in0, __pyx_k_out0_abs_in0, sizeof(__pyx_k_out0_abs_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_arg_in0, __pyx_k_out0_arg_in0, sizeof(__pyx_k_out0_arg_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_conj_in0, __pyx_k_out0_conj_in0, sizeof(__pyx_k_out0_conj_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_fabs_in0, __pyx_k_out0_fabs_in0, sizeof(__pyx_k_out0_fabs_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_fabsf_in0, __pyx_k_out0_fabsf_in0, sizeof(__pyx_k_out0_fabsf_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_imag_in0, __pyx_k_out0_imag_in0, sizeof(__pyx_k_out0_imag_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0, __pyx_k_out0_in0, sizeof(__pyx_k_out0_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_0_0_M_PI, __pyx_k_out0_in0_0_0_M_PI, sizeof(__pyx_k_out0_in0_0_0_M_PI), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_0_in0_in0, __pyx_k_out0_in0_0_in0_in0, sizeof(__pyx_k_out0_in0_0_in0_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_2, __pyx_k_out0_in0_2, sizeof(__pyx_k_out0_in0_2), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_3, __pyx_k_out0_in0_3, sizeof(__pyx_k_out0_in0_3), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_4, __pyx_k_out0_in0_4, sizeof(__pyx_k_out0_in0_4), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0__floor_divide_in0_in1_i, __pyx_k_out0_in0__floor_divide_in0_in1_i, sizeof(__pyx_k_out0_in0__floor_divide_in0_in1_i), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0__floor_divide_in0_in1_i_2, __pyx_k_out0_in0__floor_divide_in0_in1_i_2, sizeof(__pyx_k_out0_in0__floor_divide_in0_in1_i_2), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_imag, __pyx_k_out0_in0_imag, sizeof(__pyx_k_out0_in0_imag), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_in1, __pyx_k_out0_in0_in1, sizeof(__pyx_k_out0_in0_in1), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_in1_in1_in0_in2_in2_in0, __pyx_k_out0_in0_in1_in1_in0_in2_in2_in0, sizeof(__pyx_k_out0_in0_in1_in1_in0_in2_in2_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_real, __pyx_k_out0_in0_real, sizeof(__pyx_k_out0_in0_real), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_s_in1, __pyx_k_out0_in0_s_in1, sizeof(__pyx_k_out0_in0_s_in1), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in1_0_0_floor_double_in0_do, __pyx_k_out0_in1_0_0_floor_double_in0_do, sizeof(__pyx_k_out0_in1_0_0_floor_double_in0_do), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_out0_type_in0, __pyx_k_out0_out0_type_in0, sizeof(__pyx_k_out0_out0_type_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_out0_type_in0_out0_type_in1, __pyx_k_out0_out0_type_in0_out0_type_in1, sizeof(__pyx_k_out0_out0_type_in0_out0_type_in1), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_pow_in0_in1, __pyx_k_out0_pow_in0_in1, sizeof(__pyx_k_out0_pow_in0_in1), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_powf_in0_in1, __pyx_k_out0_powf_in0_in1, sizeof(__pyx_k_out0_powf_in0_in1), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_real_in0, __pyx_k_out0_real_in0, sizeof(__pyx_k_out0_real_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_rint_pow_double_in0_double, __pyx_k_out0_rint_pow_double_in0_double, sizeof(__pyx_k_out0_rint_pow_double_in0_double), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_sqrt_in0, __pyx_k_out0_sqrt_in0, sizeof(__pyx_k_out0_sqrt_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_type_a__floor_divide_in0_i, __pyx_k_out0_type_a__floor_divide_in0_i, sizeof(__pyx_k_out0_type_a__floor_divide_in0_i), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_type_out0_raw_a, __pyx_k_out0_type_out0_raw_a, sizeof(__pyx_k_out0_type_out0_raw_a), 0, 0, 1, 0},
  {&__pyx_kp_s_out_0__type_out_0__raw_out_0__in, __pyx_k_out_0__type_out_0__raw_out_0__in, sizeof(__pyx_k_out_0__type_out_0__raw_out_0__in), 0, 0, 1, 0},
  {&__pyx_kp_s_out_a, __pyx_k_out_a, sizeof(__pyx_k_out_a), 0, 0, 1, 0},
  {&__pyx_kp_s_out_alpha_a, __pyx_k_out_alpha_a, sizeof(__pyx_k_out_alpha_a), 0, 0, 1, 0},
  {&__pyx_n_s_out_arg_dtype, __pyx_k_out_arg_dtype, sizeof(__pyx_k_out_arg_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_out_args, __pyx_k_out_args, sizeof(__pyx_k_out_args), 0, 0, 1, 1},
  {&__pyx_n_s_out_args_dtype, __pyx_k_out_args_dtype, sizeof(__pyx_k_out_args_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_out_clp2_size, __pyx_k_out_clp2_size, sizeof(__pyx_k_out_clp2_size), 0, 0, 1, 1},
  {&__pyx_n_s_out_indexer, __pyx_k_out_indexer, sizeof(__pyx_k_out_indexer), 0, 0, 1, 1},
  {&__pyx_n_s_out_ndarray_types, __pyx_k_out_ndarray_types, sizeof(__pyx_k_out_ndarray_types), 0, 0, 1, 1},
  {&__pyx_n_s_out_params, __pyx_k_out_params, sizeof(__pyx_k_out_params), 0, 0, 1, 1},
  {&__pyx_n_s_out_params_2, __pyx_k_out_params_2, sizeof(__pyx_k_out_params_2), 0, 0, 1, 1},
  {&__pyx_n_s_out_shape, __pyx_k_out_shape, sizeof(__pyx_k_out_shape), 0, 0, 1, 1},
  {&__pyx_n_s_out_str, __pyx_k_out_str, sizeof(__pyx_k_out_str), 0, 0, 1, 1},
  {&__pyx_n_s_out_types, __pyx_k_out_types, sizeof(__pyx_k_out_types), 0, 0, 1, 1},
  {&__pyx_n_s_output_expr, __pyx_k_output_expr, sizeof(__pyx_k_output_expr), 0, 0, 1, 1},
  {&__pyx_n_s_output_expr_2, __pyx_k_output_expr_2, sizeof(__pyx_k_output_expr_2), 0, 0, 1, 1},
  {&__pyx_kp_s_output_typecode_could_not_be_coe, __pyx_k_output_typecode_could_not_be_coe, sizeof(__pyx_k_output_typecode_could_not_be_coe), 0, 0, 1, 0},
  {&__pyx_n_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 1},
  {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1},
  {&__pyx_n_s_param, __pyx_k_param, sizeof(__pyx_k_param), 0, 0, 1, 1},
  {&__pyx_n_s_params, __pyx_k_params, sizeof(__pyx_k_params), 0, 0, 1, 1},
  {&__pyx_n_s_params_2, __pyx_k_params_2, sizeof(__pyx_k_params_2), 0, 0, 1, 1},
  {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1},
  {&__pyx_n_s_pathsep, __pyx_k_pathsep, sizeof(__pyx_k_pathsep), 0, 0, 1, 1},
  {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
  {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
  {&__pyx_n_s_post_map_expr, __pyx_k_post_map_expr, sizeof(__pyx_k_post_map_expr), 0, 0, 1, 1},
  {&__pyx_n_s_power, __pyx_k_power, sizeof(__pyx_k_power), 0, 0, 1, 1},
  {&__pyx_n_s_pre_map_expr, __pyx_k_pre_map_expr, sizeof(__pyx_k_pre_map_expr), 0, 0, 1, 1},
  {&__pyx_n_s_preamble, __pyx_k_preamble, sizeof(__pyx_k_preamble), 0, 0, 1, 1},
  {&__pyx_n_s_preamble_2, __pyx_k_preamble_2, sizeof(__pyx_k_preamble_2), 0, 0, 1, 1},
  {&__pyx_kp_s_preamble_extern_C___global___vo, __pyx_k_preamble_extern_C___global___vo, sizeof(__pyx_k_preamble_extern_C___global___vo), 0, 0, 1, 0},
  {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  {&__pyx_n_s_prev, __pyx_k_prev, sizeof(__pyx_k_prev), 0, 0, 1, 1},
  {&__pyx_n_s_prod, __pyx_k_prod, sizeof(__pyx_k_prod), 0, 0, 1, 1},
  {&__pyx_n_s_prod_2, __pyx_k_prod_2, sizeof(__pyx_k_prod_2), 0, 0, 1, 1},
  {&__pyx_n_s_property, __pyx_k_property, sizeof(__pyx_k_property), 0, 0, 1, 1},
  {&__pyx_kp_s_provided_op_is_not_supported, __pyx_k_provided_op_is_not_supported, sizeof(__pyx_k_provided_op_is_not_supported), 0, 0, 1, 0},
  {&__pyx_n_s_ptr, __pyx_k_ptr, sizeof(__pyx_k_ptr), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_getbuffer, __pyx_k_pyx_getbuffer, sizeof(__pyx_k_pyx_getbuffer), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_ElementwiseKernel, __pyx_k_pyx_unpickle_ElementwiseKernel, sizeof(__pyx_k_pyx_unpickle_ElementwiseKernel), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Enum, __pyx_k_pyx_unpickle_Enum, sizeof(__pyx_k_pyx_unpickle_Enum), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Indexer, __pyx_k_pyx_unpickle_Indexer, sizeof(__pyx_k_pyx_unpickle_Indexer), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_ParameterInfo, __pyx_k_pyx_unpickle_ParameterInfo, sizeof(__pyx_k_pyx_unpickle_ParameterInfo), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_broadcast, __pyx_k_pyx_unpickle_broadcast, sizeof(__pyx_k_pyx_unpickle_broadcast), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_kp_s_q, __pyx_k_q, sizeof(__pyx_k_q), 0, 0, 1, 0},
  {&__pyx_kp_s_q_2, __pyx_k_q_2, sizeof(__pyx_k_q_2), 0, 0, 1, 0},
  {&__pyx_kp_s_q_d, __pyx_k_q_d, sizeof(__pyx_k_q_d), 0, 0, 1, 0},
  {&__pyx_kp_s_q_q, __pyx_k_q_q, sizeof(__pyx_k_q_q), 0, 0, 1, 0},
  {&__pyx_kp_s_q_q_2, __pyx_k_q_q_2, sizeof(__pyx_k_q_q_2), 0, 0, 1, 0},
  {&__pyx_kp_s_qq, __pyx_k_qq, sizeof(__pyx_k_qq), 0, 0, 1, 0},
  {&__pyx_kp_s_qq_d, __pyx_k_qq_d, sizeof(__pyx_k_qq_d), 0, 0, 1, 0},
  {&__pyx_kp_s_qq_q, __pyx_k_qq_q, sizeof(__pyx_k_qq_q), 0, 0, 1, 0},
  {&__pyx_kp_s_qq_qq, __pyx_k_qq_qq, sizeof(__pyx_k_qq_qq), 0, 0, 1, 0},
  {&__pyx_kp_s_qqq_q, __pyx_k_qqq_q, sizeof(__pyx_k_qqq_q), 0, 0, 1, 0},
  {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  {&__pyx_n_s_radd, __pyx_k_radd, sizeof(__pyx_k_radd), 0, 0, 1, 1},
  {&__pyx_n_s_raise, __pyx_k_raise, sizeof(__pyx_k_raise), 0, 0, 1, 1},
  {&__pyx_n_s_rand, __pyx_k_rand, sizeof(__pyx_k_rand), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_ravel, __pyx_k_ravel, sizeof(__pyx_k_ravel), 0, 0, 1, 1},
  {&__pyx_n_s_raw, __pyx_k_raw, sizeof(__pyx_k_raw), 0, 0, 1, 1},
  {&__pyx_n_s_raw_2, __pyx_k_raw_2, sizeof(__pyx_k_raw_2), 0, 0, 1, 1},
  {&__pyx_kp_s_raw_P_x_int32_axis_raw_int32_cum, __pyx_k_raw_P_x_int32_axis_raw_int32_cum, sizeof(__pyx_k_raw_P_x_int32_axis_raw_int32_cum), 0, 0, 1, 0},
  {&__pyx_kp_s_raw_P_x_int32_base, __pyx_k_raw_P_x_int32_base, sizeof(__pyx_k_raw_P_x_int32_base), 0, 0, 1, 0},
  {&__pyx_kp_s_raw_T_a, __pyx_k_raw_T_a, sizeof(__pyx_k_raw_T_a), 0, 0, 1, 0},
  {&__pyx_kp_s_raw_T_a_S_indices_int32_cdim_int, __pyx_k_raw_T_a_S_indices_int32_cdim_int, sizeof(__pyx_k_raw_T_a_S_indices_int32_cdim_int), 0, 0, 1, 0},
  {&__pyx_kp_s_raw_T_a_S_indices_int32_rdim_S_i, __pyx_k_raw_T_a_S_indices_int32_rdim_S_i, sizeof(__pyx_k_raw_T_a_S_indices_int32_rdim_S_i), 0, 0, 1, 0},
  {&__pyx_kp_s_raw_T_out, __pyx_k_raw_T_out, sizeof(__pyx_k_raw_T_out), 0, 0, 1, 0},
  {&__pyx_kp_s_raw_T_v_S_indices_int32_cdim_int, __pyx_k_raw_T_v_S_indices_int32_cdim_int, sizeof(__pyx_k_raw_T_v_S_indices_int32_cdim_int), 0, 0, 1, 0},
  {&__pyx_kp_s_raw_T_v_bool_mask_S_mask_scanned, __pyx_k_raw_T_v_bool_mask_S_mask_scanned, sizeof(__pyx_k_raw_T_v_bool_mask_S_mask_scanned), 0, 0, 1, 0},
  {&__pyx_n_s_raxis, __pyx_k_raxis, sizeof(__pyx_k_raxis), 0, 0, 1, 1},
  {&__pyx_n_s_rdiv, __pyx_k_rdiv, sizeof(__pyx_k_rdiv), 0, 0, 1, 1},
  {&__pyx_n_s_rdivmod, __pyx_k_rdivmod, sizeof(__pyx_k_rdivmod), 0, 0, 1, 1},
  {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1},
  {&__pyx_n_s_real, __pyx_k_real, sizeof(__pyx_k_real), 0, 0, 1, 1},
  {&__pyx_n_s_real_setter, __pyx_k_real_setter, sizeof(__pyx_k_real_setter), 0, 0, 1, 1},
  {&__pyx_n_s_record, __pyx_k_record, sizeof(__pyx_k_record), 0, 0, 1, 1},
  {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_dims, __pyx_k_reduce_dims, sizeof(__pyx_k_reduce_dims), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_expr, __pyx_k_reduce_expr, sizeof(__pyx_k_reduce_expr), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_kernel, __pyx_k_reduce_kernel, sizeof(__pyx_k_reduce_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_type, __pyx_k_reduce_type, sizeof(__pyx_k_reduce_type), 0, 0, 1, 1},
  {&__pyx_n_s_reduced_view, __pyx_k_reduced_view, sizeof(__pyx_k_reduced_view), 0, 0, 1, 1},
  {&__pyx_n_s_remainder, __pyx_k_remainder, sizeof(__pyx_k_remainder), 0, 0, 1, 1},
  {&__pyx_n_s_repeat, __pyx_k_repeat, sizeof(__pyx_k_repeat), 0, 0, 1, 1},
  {&__pyx_n_s_repeats, __pyx_k_repeats, sizeof(__pyx_k_repeats), 0, 0, 1, 1},
  {&__pyx_kp_s_repeats_and_axis_of_a_should_be, __pyx_k_repeats_and_axis_of_a_should_be, sizeof(__pyx_k_repeats_and_axis_of_a_should_be), 0, 0, 1, 0},
  {&__pyx_kp_s_repeats_should_be_int_or_sequen, __pyx_k_repeats_should_be_int_or_sequen, sizeof(__pyx_k_repeats_should_be_int_or_sequen), 0, 0, 1, 0},
  {&__pyx_kp_s_repeats_should_not_be_negative, __pyx_k_repeats_should_not_be_negative, sizeof(__pyx_k_repeats_should_not_be_negative), 0, 0, 1, 0},
  {&__pyx_n_s_repr, __pyx_k_repr, sizeof(__pyx_k_repr), 0, 0, 1, 1},
  {&__pyx_n_s_require_sortable_dtype, __pyx_k_require_sortable_dtype, sizeof(__pyx_k_require_sortable_dtype), 0, 0, 1, 1},
  {&__pyx_kp_s_requires_a_ndim_1, __pyx_k_requires_a_ndim_1, sizeof(__pyx_k_requires_a_ndim_1), 0, 0, 1, 0},
  {&__pyx_n_s_reshape, __pyx_k_reshape, sizeof(__pyx_k_reshape), 0, 0, 1, 1},
  {&__pyx_n_s_reshape_2, __pyx_k_reshape_2, sizeof(__pyx_k_reshape_2), 0, 0, 1, 1},
  {&__pyx_n_s_result_type, __pyx_k_result_type, sizeof(__pyx_k_result_type), 0, 0, 1, 1},
  {&__pyx_n_s_ret, __pyx_k_ret, sizeof(__pyx_k_ret), 0, 0, 1, 1},
  {&__pyx_n_s_ret_shape, __pyx_k_ret_shape, sizeof(__pyx_k_ret_shape), 0, 0, 1, 1},
  {&__pyx_n_s_rfloordiv, __pyx_k_rfloordiv, sizeof(__pyx_k_rfloordiv), 0, 0, 1, 1},
  {&__pyx_n_s_ri, __pyx_k_ri, sizeof(__pyx_k_ri), 0, 0, 1, 1},
  {&__pyx_n_s_right_shift, __pyx_k_right_shift, sizeof(__pyx_k_right_shift), 0, 0, 1, 1},
  {&__pyx_n_s_rlshift, __pyx_k_rlshift, sizeof(__pyx_k_rlshift), 0, 0, 1, 1},
  {&__pyx_n_s_rmatmul, __pyx_k_rmatmul, sizeof(__pyx_k_rmatmul), 0, 0, 1, 1},
  {&__pyx_n_s_rmod, __pyx_k_rmod, sizeof(__pyx_k_rmod), 0, 0, 1, 1},
  {&__pyx_n_s_rmul, __pyx_k_rmul, sizeof(__pyx_k_rmul), 0, 0, 1, 1},
  {&__pyx_n_s_rollaxis, __pyx_k_rollaxis, sizeof(__pyx_k_rollaxis), 0, 0, 1, 1},
  {&__pyx_n_s_ror, __pyx_k_ror, sizeof(__pyx_k_ror), 0, 0, 1, 1},
  {&__pyx_n_s_routine, __pyx_k_routine, sizeof(__pyx_k_routine), 0, 0, 1, 1},
  {&__pyx_n_s_routine_cache, __pyx_k_routine_cache, sizeof(__pyx_k_routine_cache), 0, 0, 1, 1},
  {&__pyx_n_s_rpow, __pyx_k_rpow, sizeof(__pyx_k_rpow), 0, 0, 1, 1},
  {&__pyx_n_s_rrshift, __pyx_k_rrshift, sizeof(__pyx_k_rrshift), 0, 0, 1, 1},
  {&__pyx_n_s_rsub, __pyx_k_rsub, sizeof(__pyx_k_rsub), 0, 0, 1, 1},
  {&__pyx_n_s_rtruediv, __pyx_k_rtruediv, sizeof(__pyx_k_rtruediv), 0, 0, 1, 1},
  {&__pyx_n_s_rundim, __pyx_k_rundim, sizeof(__pyx_k_rundim), 0, 0, 1, 1},
  {&__pyx_n_s_rxor, __pyx_k_rxor, sizeof(__pyx_k_rxor), 0, 0, 1, 1},
  {&__pyx_kp_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 0},
  {&__pyx_n_s_s_2, __pyx_k_s_2, sizeof(__pyx_k_s_2), 0, 0, 1, 1},
  {&__pyx_kp_s_s_s, __pyx_k_s_s, sizeof(__pyx_k_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s_s, __pyx_k_s_s_s, sizeof(__pyx_k_s_s_s), 0, 0, 1, 0},
  {&__pyx_n_s_same_kind, __pyx_k_same_kind, sizeof(__pyx_k_same_kind), 0, 0, 1, 1},
  {&__pyx_kp_s_scatter_add_only_supports_int32, __pyx_k_scatter_add_only_supports_int32, sizeof(__pyx_k_scatter_add_only_supports_int32), 0, 0, 1, 0},
  {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  {&__pyx_kp_s_self_ptr_cannot_be_converted_to, __pyx_k_self_ptr_cannot_be_converted_to, sizeof(__pyx_k_self_ptr_cannot_be_converted_to), 0, 0, 1, 0},
  {&__pyx_kp_s_self_ptr_self_val_cannot_be_conv, __pyx_k_self_ptr_self_val_cannot_be_conv, sizeof(__pyx_k_self_ptr_self_val_cannot_be_conv), 0, 0, 1, 0},
  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  {&__pyx_n_s_sep, __pyx_k_sep, sizeof(__pyx_k_sep), 0, 0, 1, 1},
  {&__pyx_n_s_set, __pyx_k_set, sizeof(__pyx_k_set), 0, 0, 1, 1},
  {&__pyx_n_s_set_shape_and_strides, __pyx_k_set_shape_and_strides, sizeof(__pyx_k_set_shape_and_strides), 0, 0, 1, 1},
  {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_sgeam, __pyx_k_sgeam, sizeof(__pyx_k_sgeam), 0, 0, 1, 1},
  {&__pyx_n_s_sgemmBatched, __pyx_k_sgemmBatched, sizeof(__pyx_k_sgemmBatched), 0, 0, 1, 1},
  {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
  {&__pyx_n_s_shape_2, __pyx_k_shape_2, sizeof(__pyx_k_shape_2), 0, 0, 1, 1},
  {&__pyx_kp_s_shape_mismatch_objects_cannot_be, __pyx_k_shape_mismatch_objects_cannot_be, sizeof(__pyx_k_shape_mismatch_objects_cannot_be), 0, 0, 1, 0},
  {&__pyx_kp_s_shapes_and_not_aligned, __pyx_k_shapes_and_not_aligned, sizeof(__pyx_k_shapes_and_not_aligned), 0, 0, 1, 0},
  {&__pyx_n_s_shared_mem, __pyx_k_shared_mem, sizeof(__pyx_k_shared_mem), 0, 0, 1, 1},
  {&__pyx_n_s_short, __pyx_k_short, sizeof(__pyx_k_short), 0, 0, 1, 1},
  {&__pyx_kp_s_signed_char, __pyx_k_signed_char, sizeof(__pyx_k_signed_char), 0, 0, 1, 0},
  {&__pyx_n_s_simple_reduction_function, __pyx_k_simple_reduction_function, sizeof(__pyx_k_simple_reduction_function), 0, 0, 1, 1},
  {&__pyx_n_s_simple_reduction_function___call, __pyx_k_simple_reduction_function___call, sizeof(__pyx_k_simple_reduction_function___call), 0, 0, 1, 1},
  {&__pyx_n_s_simple_reduction_function___init, __pyx_k_simple_reduction_function___init, sizeof(__pyx_k_simple_reduction_function___init), 0, 0, 1, 1},
  {&__pyx_n_s_six, __pyx_k_six, sizeof(__pyx_k_six), 0, 0, 1, 1},
  {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
  {&__pyx_n_s_slices, __pyx_k_slices, sizeof(__pyx_k_slices), 0, 0, 1, 1},
  {&__pyx_n_s_sort, __pyx_k_sort, sizeof(__pyx_k_sort), 0, 0, 1, 1},
  {&__pyx_n_s_source, __pyx_k_source, sizeof(__pyx_k_source), 0, 0, 1, 1},
  {&__pyx_kp_s_source_and_destination_argument, __pyx_k_source_and_destination_argument, sizeof(__pyx_k_source_and_destination_argument), 0, 0, 1, 0},
  {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
  {&__pyx_n_s_sqrt, __pyx_k_sqrt, sizeof(__pyx_k_sqrt), 0, 0, 1, 1},
  {&__pyx_n_s_squeeze, __pyx_k_squeeze, sizeof(__pyx_k_squeeze), 0, 0, 1, 1},
  {&__pyx_n_s_src_dtype, __pyx_k_src_dtype, sizeof(__pyx_k_src_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_src_ndim, __pyx_k_src_ndim, sizeof(__pyx_k_src_ndim), 0, 0, 1, 1},
  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
  {&__pyx_n_s_start_adr, __pyx_k_start_adr, sizeof(__pyx_k_start_adr), 0, 0, 1, 1},
  {&__pyx_kp_s_static_cast_U_x_static_cast_U_y, __pyx_k_static_cast_U_x_static_cast_U_y, sizeof(__pyx_k_static_cast_U_x_static_cast_U_y), 0, 0, 1, 0},
  {&__pyx_n_s_std, __pyx_k_std, sizeof(__pyx_k_std), 0, 0, 1, 1},
  {&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1},
  {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
  {&__pyx_n_s_stream, __pyx_k_stream, sizeof(__pyx_k_stream), 0, 0, 1, 1},
  {&__pyx_n_s_stride, __pyx_k_stride, sizeof(__pyx_k_stride), 0, 0, 1, 1},
  {&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0},
  {&__pyx_kp_s_strided_and_direct_or_indirect, __pyx_k_strided_and_direct_or_indirect, sizeof(__pyx_k_strided_and_direct_or_indirect), 0, 0, 1, 0},
  {&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0},
  {&__pyx_n_s_strides, __pyx_k_strides, sizeof(__pyx_k_strides), 0, 0, 1, 1},
  {&__pyx_n_s_string, __pyx_k_string, sizeof(__pyx_k_string), 0, 0, 1, 1},
  {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
  {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
  {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1},
  {&__pyx_n_s_subok, __pyx_k_subok, sizeof(__pyx_k_subok), 0, 0, 1, 1},
  {&__pyx_kp_s_subok_is_not_supported_yet, __pyx_k_subok_is_not_supported_yet, sizeof(__pyx_k_subok_is_not_supported_yet), 0, 0, 1, 0},
  {&__pyx_n_s_substitute, __pyx_k_substitute, sizeof(__pyx_k_substitute), 0, 0, 1, 1},
  {&__pyx_n_s_subtract, __pyx_k_subtract, sizeof(__pyx_k_subtract), 0, 0, 1, 1},
  {&__pyx_n_s_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 0, 0, 1, 1},
  {&__pyx_n_s_sum_2, __pyx_k_sum_2, sizeof(__pyx_k_sum_2), 0, 0, 1, 1},
  {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1},
  {&__pyx_n_s_swapaxes, __pyx_k_swapaxes, sizeof(__pyx_k_swapaxes), 0, 0, 1, 1},
  {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
  {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1},
  {&__pyx_kp_s_t_n__raw__n__ind_get, __pyx_k_t_n__raw__n__ind_get, sizeof(__pyx_k_t_n__raw__n__ind_get), 0, 0, 1, 0},
  {&__pyx_n_s_take, __pyx_k_take, sizeof(__pyx_k_take), 0, 0, 1, 1},
  {&__pyx_kp_s_template_typename_T_struct_min, __pyx_k_template_typename_T_struct_min, sizeof(__pyx_k_template_typename_T_struct_min), 0, 0, 1, 0},
  {&__pyx_n_s_tensordot_core_mul_sum, __pyx_k_tensordot_core_mul_sum, sizeof(__pyx_k_tensordot_core_mul_sum), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_kp_s_this_op_is_not_supported, __pyx_k_this_op_is_not_supported, sizeof(__pyx_k_this_op_is_not_supported), 0, 0, 1, 0},
  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  {&__pyx_n_s_thrust, __pyx_k_thrust, sizeof(__pyx_k_thrust), 0, 0, 1, 1},
  {&__pyx_n_s_thrust_enabled, __pyx_k_thrust_enabled, sizeof(__pyx_k_thrust_enabled), 0, 0, 1, 1},
  {&__pyx_kp_s_to_environment_variable_CUDA_PAT, __pyx_k_to_environment_variable_CUDA_PAT, sizeof(__pyx_k_to_environment_variable_CUDA_PAT), 0, 0, 1, 0},
  {&__pyx_n_s_tofile, __pyx_k_tofile, sizeof(__pyx_k_tofile), 0, 0, 1, 1},
  {&__pyx_n_s_tolist, __pyx_k_tolist, sizeof(__pyx_k_tolist), 0, 0, 1, 1},
  {&__pyx_kp_s_too_many_indices_for_array, __pyx_k_too_many_indices_for_array, sizeof(__pyx_k_too_many_indices_for_array), 0, 0, 1, 0},
  {&__pyx_kp_s_total_size_of_new_array_must_be, __pyx_k_total_size_of_new_array_must_be, sizeof(__pyx_k_total_size_of_new_array_must_be), 0, 0, 1, 0},
  {&__pyx_n_s_trace, __pyx_k_trace, sizeof(__pyx_k_trace), 0, 0, 1, 1},
  {&__pyx_n_s_trans, __pyx_k_trans, sizeof(__pyx_k_trans), 0, 0, 1, 1},
  {&__pyx_n_s_transpose, __pyx_k_transpose, sizeof(__pyx_k_transpose), 0, 0, 1, 1},
  {&__pyx_n_s_transpose_2, __pyx_k_transpose_2, sizeof(__pyx_k_transpose_2), 0, 0, 1, 1},
  {&__pyx_n_s_true, __pyx_k_true, sizeof(__pyx_k_true), 0, 0, 1, 1},
  {&__pyx_n_s_true_divide, __pyx_k_true_divide, sizeof(__pyx_k_true_divide), 0, 0, 1, 1},
  {&__pyx_n_s_tup, __pyx_k_tup, sizeof(__pyx_k_tup), 0, 0, 1, 1},
  {&__pyx_n_s_type, __pyx_k_type, sizeof(__pyx_k_type), 0, 0, 1, 1},
  {&__pyx_n_s_type_dict, __pyx_k_type_dict, sizeof(__pyx_k_type_dict), 0, 0, 1, 1},
  {&__pyx_kp_s_type_out0_raw_out0__raw_out0__ou, __pyx_k_type_out0_raw_out0__raw_out0__ou, sizeof(__pyx_k_type_out0_raw_out0__raw_out0__ou), 0, 0, 1, 0},
  {&__pyx_n_s_type_preamble, __pyx_k_type_preamble, sizeof(__pyx_k_type_preamble), 0, 0, 1, 1},
  {&__pyx_kp_s_type_preamble_preamble_define_R, __pyx_k_type_preamble_preamble_define_R, sizeof(__pyx_k_type_preamble_preamble_define_R), 0, 0, 1, 0},
  {&__pyx_kp_s_typedef_s_in_d_type, __pyx_k_typedef_s_in_d_type, sizeof(__pyx_k_typedef_s_in_d_type), 0, 0, 1, 0},
  {&__pyx_kp_s_typedef_s_out_d_type, __pyx_k_typedef_s_out_d_type, sizeof(__pyx_k_typedef_s_out_d_type), 0, 0, 1, 0},
  {&__pyx_kp_s_typedef_s_s, __pyx_k_typedef_s_s, sizeof(__pyx_k_typedef_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_typedef_s_type_in0_raw_typedef_s, __pyx_k_typedef_s_type_in0_raw_typedef_s, sizeof(__pyx_k_typedef_s_type_in0_raw_typedef_s), 0, 0, 1, 0},
  {&__pyx_n_s_types, __pyx_k_types, sizeof(__pyx_k_types), 0, 0, 1, 1},
  {&__pyx_n_s_types_preamble, __pyx_k_types_preamble, sizeof(__pyx_k_types_preamble), 0, 0, 1, 1},
  {&__pyx_n_s_u, __pyx_k_u, sizeof(__pyx_k_u), 0, 0, 1, 1},
  {&__pyx_n_s_ufunc, __pyx_k_ufunc, sizeof(__pyx_k_ufunc), 0, 0, 1, 1},
  {&__pyx_n_s_ufunc___call, __pyx_k_ufunc___call, sizeof(__pyx_k_ufunc___call), 0, 0, 1, 1},
  {&__pyx_n_s_ufunc___init, __pyx_k_ufunc___init, sizeof(__pyx_k_ufunc___init), 0, 0, 1, 1},
  {&__pyx_n_s_ufunc___init___locals_genexpr, __pyx_k_ufunc___init___locals_genexpr, sizeof(__pyx_k_ufunc___init___locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_ufunc___repr, __pyx_k_ufunc___repr, sizeof(__pyx_k_ufunc___repr), 0, 0, 1, 1},
  {&__pyx_kp_s_ufunc_s, __pyx_k_ufunc_s, sizeof(__pyx_k_ufunc_s), 0, 0, 1, 0},
  {&__pyx_n_s_ufunc_types, __pyx_k_ufunc_types, sizeof(__pyx_k_ufunc_types), 0, 0, 1, 1},
  {&__pyx_n_s_uint16, __pyx_k_uint16, sizeof(__pyx_k_uint16), 0, 0, 1, 1},
  {&__pyx_n_s_uint32, __pyx_k_uint32, sizeof(__pyx_k_uint32), 0, 0, 1, 1},
  {&__pyx_n_s_uint64, __pyx_k_uint64, sizeof(__pyx_k_uint64), 0, 0, 1, 1},
  {&__pyx_n_s_uint8, __pyx_k_uint8, sizeof(__pyx_k_uint8), 0, 0, 1, 1},
  {&__pyx_n_s_uintp, __pyx_k_uintp, sizeof(__pyx_k_uintp), 0, 0, 1, 1},
  {&__pyx_n_s_ulonglong, __pyx_k_ulonglong, sizeof(__pyx_k_ulonglong), 0, 0, 1, 1},
  {&__pyx_kp_s_unable_to_allocate_array_data, __pyx_k_unable_to_allocate_array_data, sizeof(__pyx_k_unable_to_allocate_array_data), 0, 0, 1, 0},
  {&__pyx_kp_s_unable_to_allocate_shape_and_str, __pyx_k_unable_to_allocate_shape_and_str, sizeof(__pyx_k_unable_to_allocate_shape_and_str), 0, 0, 1, 0},
  {&__pyx_n_s_unknown_ctype, __pyx_k_unknown_ctype, sizeof(__pyx_k_unknown_ctype), 0, 0, 1, 1},
  {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1},
  {&__pyx_n_s_unsafe, __pyx_k_unsafe, sizeof(__pyx_k_unsafe), 0, 0, 1, 1},
  {&__pyx_kp_s_unsigned_char, __pyx_k_unsigned_char, sizeof(__pyx_k_unsigned_char), 0, 0, 1, 0},
  {&__pyx_kp_s_unsigned_int, __pyx_k_unsigned_int, sizeof(__pyx_k_unsigned_int), 0, 0, 1, 0},
  {&__pyx_kp_s_unsigned_long_long, __pyx_k_unsigned_long_long, sizeof(__pyx_k_unsigned_long_long), 0, 0, 1, 0},
  {&__pyx_kp_s_unsigned_short, __pyx_k_unsigned_short, sizeof(__pyx_k_unsigned_short), 0, 0, 1, 0},
  {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  {&__pyx_n_s_update_c_contiguity, __pyx_k_update_c_contiguity, sizeof(__pyx_k_update_c_contiguity), 0, 0, 1, 1},
  {&__pyx_n_s_update_c_contiguity_2, __pyx_k_update_c_contiguity_2, sizeof(__pyx_k_update_c_contiguity_2), 0, 0, 1, 1},
  {&__pyx_n_s_update_contiguity, __pyx_k_update_contiguity, sizeof(__pyx_k_update_contiguity), 0, 0, 1, 1},
  {&__pyx_n_s_update_f_contiguity, __pyx_k_update_f_contiguity, sizeof(__pyx_k_update_f_contiguity), 0, 0, 1, 1},
  {&__pyx_kp_s_usr_local_cuda, __pyx_k_usr_local_cuda, sizeof(__pyx_k_usr_local_cuda), 0, 0, 1, 0},
  {&__pyx_n_s_util, __pyx_k_util, sizeof(__pyx_k_util), 0, 0, 1, 1},
  {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1},
  {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  {&__pyx_n_s_var, __pyx_k_var, sizeof(__pyx_k_var), 0, 0, 1, 1},
  {&__pyx_n_s_var_2, __pyx_k_var_2, sizeof(__pyx_k_var_2), 0, 0, 1, 1},
  {&__pyx_n_s_var_core, __pyx_k_var_core, sizeof(__pyx_k_var_core), 0, 0, 1, 1},
  {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1},
  {&__pyx_n_s_view, __pyx_k_view, sizeof(__pyx_k_view), 0, 0, 1, 1},
  {&__pyx_n_s_warn, __pyx_k_warn, sizeof(__pyx_k_warn), 0, 0, 1, 1},
  {&__pyx_n_s_warnings, __pyx_k_warnings, sizeof(__pyx_k_warnings), 0, 0, 1, 1},
  {&__pyx_n_s_wrap, __pyx_k_wrap, sizeof(__pyx_k_wrap), 0, 0, 1, 1},
  {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1},
  {&__pyx_kp_u_x___getitem___y_x_y_Supports_bot, __pyx_k_x___getitem___y_x_y_Supports_bot, sizeof(__pyx_k_x___getitem___y_x_y_Supports_bot), 0, 1, 0, 0},
  {&__pyx_kp_u_x___setitem___slices_y_x_slices, __pyx_k_x___setitem___slices_y_x_slices, sizeof(__pyx_k_x___setitem___slices_y_x_slices), 0, 1, 0, 0},
  {&__pyx_kp_s_x_mean_x_mean, __pyx_k_x_mean_x_mean, sizeof(__pyx_k_x_mean_x_mean), 0, 0, 1, 0},
  {&__pyx_kp_s_y_choices_i_n_channel_a, __pyx_k_y_choices_i_n_channel_a, sizeof(__pyx_k_y_choices_i_n_channel_a), 0, 0, 1, 0},
  {&__pyx_kp_s_zero_dimensional_arrays_cannot_b, __pyx_k_zero_dimensional_arrays_cannot_b, sizeof(__pyx_k_zero_dimensional_arrays_cannot_b), 0, 0, 1, 0},
  {&__pyx_kp_s_zero_size_array_to_reduction_ope, __pyx_k_zero_size_array_to_reduction_ope, sizeof(__pyx_k_zero_size_array_to_reduction_ope), 0, 0, 1, 0},
  {&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(0, 15, __pyx_L1_error)
  __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 43, __pyx_L1_error)
  __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(0, 44, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 44, __pyx_L1_error)
  __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(1, 699, __pyx_L1_error)
  __pyx_builtin_property = __Pyx_GetBuiltinName(__pyx_n_s_property); if (!__pyx_builtin_property) __PYX_ERR(1, 737, __pyx_L1_error)
  __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 47, __pyx_L1_error)
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 111, __pyx_L1_error)
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 341, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 506, __pyx_L1_error)
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(0, 758, __pyx_L1_error)
  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(0, 768, __pyx_L1_error)
  __pyx_builtin_NotImplemented = __Pyx_GetBuiltinName(__pyx_n_s_NotImplemented); if (!__pyx_builtin_NotImplemented) __PYX_ERR(0, 1161, __pyx_L1_error)
  __pyx_builtin_all = __Pyx_GetBuiltinName(__pyx_n_s_all); if (!__pyx_builtin_all) __PYX_ERR(0, 1426, __pyx_L1_error)
  __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(0, 1437, __pyx_L1_error)
  __pyx_builtin_sum = __Pyx_GetBuiltinName(__pyx_n_s_sum); if (!__pyx_builtin_sum) __PYX_ERR(0, 1523, __pyx_L1_error)
  __pyx_builtin_oct = __Pyx_GetBuiltinName(__pyx_n_s_oct); if (!__pyx_builtin_oct) __PYX_ERR(0, 1664, __pyx_L1_error)
  __pyx_builtin_hex = __Pyx_GetBuiltinName(__pyx_n_s_hex); if (!__pyx_builtin_hex) __PYX_ERR(0, 1667, __pyx_L1_error)
  __pyx_builtin_open = __Pyx_GetBuiltinName(__pyx_n_s_open); if (!__pyx_builtin_open) __PYX_ERR(2, 118, __pyx_L1_error)
  __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(1, 301, __pyx_L1_error)
  __pyx_builtin_map = __Pyx_GetBuiltinName(__pyx_n_s_map); if (!__pyx_builtin_map) __PYX_ERR(1, 845, __pyx_L1_error)
  __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(4, 146, __pyx_L1_error)
  __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(4, 601, __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":90
 *         for x in self._shape:
 *             if x < 0:
 *                 raise ValueError('Negative dimensions are not allowed')             # <<<<<<<<<<<<<<
 *         self.dtype = numpy.dtype(dtype)
 *         self.size = internal.prod_ssize_t(self._shape)
 */
  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_Negative_dimensions_are_not_allo); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 90, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "cupy/core/core.pyx":111
 *             self._update_c_contiguity()
 *         else:
 *             raise TypeError('order not understood')             # <<<<<<<<<<<<<<
 * 
 *     # The definition order of attributes and methods are borrowed from the
 */
  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_order_not_understood); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);

  /* "cupy/core/core.pyx":154
 *             strides = _get_strides_for_nocopy_reshape(self, shape)
 *             if strides.size() != shape.size():
 *                 raise AttributeError('incompatible shape')             # <<<<<<<<<<<<<<
 *             self._shape = shape
 *             self._strides = strides
 */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_incompatible_shape); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 154, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "cupy/core/core.pyx":308
 *         # 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__6 = PyTuple_Pack(1, __pyx_kp_s_casting_is_not_supported_yet); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "cupy/core/core.pyx":310
 *             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__7 = PyTuple_Pack(1, __pyx_kp_s_subok_is_not_supported_yet); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);

  /* "cupy/core/core.pyx":315
 *             order = 'K'
 *         if order not in ['C', 'F', 'A', 'K']:
 *             raise TypeError('order not understood')             # <<<<<<<<<<<<<<
 * 
 *         dtype = numpy.dtype(dtype)
 */
  __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_order_not_understood); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "cupy/core/core.pyx":384
 *         else:
 *             # It need to make a contiguous copy for copying from another device
 *             with self.device:             # <<<<<<<<<<<<<<
 *                 x = self.astype(self.dtype, copy=False, order=order)
 *             newarray = ndarray(x.shape, dtype=x.dtype)
 */
  __pyx_tuple__9 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "cupy/core/core.pyx":444
 *         if isinstance(value, numpy.ndarray):
 *             if value.shape != ():
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'non-scalar numpy.ndarray cannot be used for fill')
 *             value = value.item()
 */
  __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_non_scalar_numpy_ndarray_cannot); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 444, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "cupy/core/core.pyx":471
 * 
 *         if shape.size() != strides.size():
 *             raise ValueError('total size of new array must be unchanged')             # <<<<<<<<<<<<<<
 *         newarray._set_shape_and_strides(shape, strides, False)
 *         return newarray
 */
  __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_total_size_of_new_array_must_be); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 471, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);

  /* "cupy/core/core.pyx":510
 *             axis = axes[i]
 *             if axis < -ndim or axis >= ndim:
 *                 raise IndexError('Axes overrun')             # <<<<<<<<<<<<<<
 *             axes[i] = axis % ndim
 * 
 */
  __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_Axes_overrun); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 510, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "cupy/core/core.pyx":564
 *         cdef vector.vector[Py_ssize_t] axes
 *         if axis1 < -ndim or axis1 >= ndim or axis2 < -ndim or axis2 >= ndim:
 *             raise ValueError('Axis out of range')             # <<<<<<<<<<<<<<
 *         axis1 %= ndim
 *         axis2 %= ndim
 */
  __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_Axis_out_of_range); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);

  /* "cupy/core/core.pyx":638
 *                         (axis_orig, ndim, ndim))
 *                 if axis_flags[_axis] == 1:
 *                     raise ValueError("duplicate value in 'axis'")             # <<<<<<<<<<<<<<
 *                 axis_flags[_axis] = 1
 *         else:
 */
  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_duplicate_value_in_axis); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 638, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "cupy/core/core.pyx":663
 *                     any_ones = 1
 *                 else:
 *                     raise ValueError('cannot select an axis to squeeze out '             # <<<<<<<<<<<<<<
 *                                      'which has size not equal to one')
 * 
 */
  __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_cannot_select_an_axis_to_squeeze); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 663, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "cupy/core/core.pyx":711
 *         if a.ndim < choices.ndim - 1:
 *             for i in range(choices.ndim - 1 - a.ndim):
 *                 a = a[None, ...]             # <<<<<<<<<<<<<<
 *         elif a.ndim > choices.ndim - 1:
 *             for i in range(a.ndim + 1 - choices.ndim):
 */
  __pyx_tuple__16 = PyTuple_Pack(2, Py_None, Py_Ellipsis); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 711, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "cupy/core/core.pyx":714
 *         elif a.ndim > choices.ndim - 1:
 *             for i in range(a.ndim + 1 - choices.ndim):
 *                 choices = choices[:, None, ...]             # <<<<<<<<<<<<<<
 *         ba, bcs = broadcast(a, choices).values
 * 
 */
  __pyx_slice__17 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__17)) __PYX_ERR(0, 714, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__17);
  __Pyx_GIVEREF(__pyx_slice__17);
  __pyx_tuple__18 = PyTuple_Pack(3, __pyx_slice__17, Py_None, Py_Ellipsis); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 714, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "cupy/core/core.pyx":718
 * 
 *         if out is None:
 *             out = ndarray(ba.shape[1:], choices.dtype)             # <<<<<<<<<<<<<<
 * 
 *         n_channel = numpy.prod(bcs[0].shape)
 */
  __pyx_slice__19 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__19)) __PYX_ERR(0, 718, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__19);
  __Pyx_GIVEREF(__pyx_slice__19);

  /* "cupy/core/core.pyx":723
 *         if mode == 'raise':
 *             if not ((a < n).all() and (0 <= a).all()):
 *                 raise ValueError('invalid entry in choice array')             # <<<<<<<<<<<<<<
 *             _choose_kernel(ba[0], bcs, n_channel, out)
 *         elif mode == 'wrap':
 */
  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_invalid_entry_in_choice_array); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 723, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "cupy/core/core.pyx":731
 *             _choose_clip_kernel(ba[0], bcs, n_channel, n, out)
 *         else:
 *             raise TypeError('clipmode not understood')             # <<<<<<<<<<<<<<
 * 
 *         return out
 */
  __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_clipmode_not_understood); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 731, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);

  /* "cupy/core/core.pyx":758
 * 
 *         if not cupy.cuda.thrust_enabled:
 *             raise RuntimeError('Thrust is needed to use cupy.sort. Please '             # <<<<<<<<<<<<<<
 *                                'install CUDA Toolkit with Thrust then '
 *                                'reinstall CuPy after uninstalling it.')
 */
  __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_Thrust_is_needed_to_use_cupy_sor); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);

  /* "cupy/core/core.pyx":763
 * 
 *         if ndim == 0:
 *             raise ValueError('Sorting arrays with the rank of zero is not '             # <<<<<<<<<<<<<<
 *                              'supported')  # as numpy.sort() raises
 * 
 */
  __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_Sorting_arrays_with_the_rank_of); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 763, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);

  /* "cupy/core/core.pyx":768
 *         # TODO(takagi): Support sorting views
 *         if not self._c_contiguous:
 *             raise NotImplementedError('Sorting non-contiguous array is not '             # <<<<<<<<<<<<<<
 *                                       'supported.')
 * 
 */
  __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_Sorting_non_contiguous_array_is); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 768, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "cupy/core/core.pyx":774
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')             # <<<<<<<<<<<<<<
 * 
 *         if axis == ndim - 1:
 */
  __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_Axis_out_of_range); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 774, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "cupy/core/core.pyx":816
 * 
 *         if not cupy.cuda.thrust_enabled:
 *             raise RuntimeError('Thrust is needed to use cupy.argsort. Please '             # <<<<<<<<<<<<<<
 *                                'install CUDA Toolkit with Thrust then '
 *                                'reinstall CuPy after uninstalling it.')
 */
  __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_Thrust_is_needed_to_use_cupy_arg); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 816, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "cupy/core/core.pyx":821
 * 
 *         if ndim == 0:
 *             raise ValueError('Sorting arrays with the rank of zero is not '             # <<<<<<<<<<<<<<
 *                              'supported')  # as numpy.argsort() raises
 * 
 */
  __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_Sorting_arrays_with_the_rank_of); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 821, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);

  /* "cupy/core/core.pyx":833
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')             # <<<<<<<<<<<<<<
 * 
 *         if axis == ndim - 1:
 */
  __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_Axis_out_of_range); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 833, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);

  /* "cupy/core/core.pyx":881
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')             # <<<<<<<<<<<<<<
 * 
 *         length = self.shape[axis]
 */
  __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_Axis_out_of_range); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 881, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);

  /* "cupy/core/core.pyx":924
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')             # <<<<<<<<<<<<<<
 * 
 *         length = data.shape[axis]
 */
  __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_Axis_out_of_range); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 924, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);

  /* "cupy/core/core.pyx":967
 *         ndim = max(self._shape.size(), 1)
 *         if count_nonzero == 0:
 *             return (ndarray((0,), dtype=dtype),) * ndim             # <<<<<<<<<<<<<<
 * 
 *         dst = ndarray((count_nonzero * ndim,), dtype=dtype)
 */
  __pyx_tuple__31 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 967, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);
  __pyx_tuple__32 = PyTuple_Pack(1, __pyx_tuple__31); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 967, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);

  /* "cupy/core/core.pyx":1052
 *         """
 *         if a_min is None and a_max is None:
 *             raise ValueError('array_clip: must set either max or min')             # <<<<<<<<<<<<<<
 *         if a_min is None:
 *             if issubclass(self.dtype.type, numpy.floating):
 */
  __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_array_clip_must_set_either_max_o); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 1052, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);

  /* "cupy/core/core.pyx":1055
 *         if a_min is None:
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_min = self.dtype.type('-inf')             # <<<<<<<<<<<<<<
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_min = numpy.iinfo(self.dtype.type).min
 */
  __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_inf); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 1055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);

  /* "cupy/core/core.pyx":1060
 *         if a_max is None:
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_max = self.dtype.type('inf')             # <<<<<<<<<<<<<<
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_max = numpy.iinfo(self.dtype.type).max
 */
  __pyx_tuple__35 = PyTuple_Pack(1, __pyx_n_s_inf_2); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 1060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);

  /* "cupy/core/core.pyx":1355
 *             _imag_setter(value, self)
 *         else:
 *             raise TypeError('cupy.ndarray does not have imaginary part to set')             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_cupy_ndarray_does_not_have_imagi); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 1355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);

  /* "cupy/core/core.pyx":1367
 *     def __deepcopy__(self, memo):
 *         if self.device is not None:
 *             with self.device:             # <<<<<<<<<<<<<<
 *                 return self.copy()
 *         else:
 */
  __pyx_tuple__37 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 1367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);
  __pyx_tuple__38 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 1367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);

  /* "cupy/core/core.pyx":1391
 *     def __len__(self):
 *         if self._shape.size() == 0:
 *             raise TypeError('len() of unsized object')             # <<<<<<<<<<<<<<
 *         return self._shape[0]
 * 
 */
  __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_len_of_unsized_object); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 1391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);

  /* "cupy/core/core.pyx":1441
 *                 ellipsis = i
 *         ndim = self._shape.size()
 *         noneslices = [slice(None)]             # <<<<<<<<<<<<<<
 *         if n_ellipses > 0:
 *             if n_ellipses > 1:
 */
  __pyx_slice__40 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__40)) __PYX_ERR(0, 1441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__40);
  __Pyx_GIVEREF(__pyx_slice__40);

  /* "cupy/core/core.pyx":1444
 *         if n_ellipses > 0:
 *             if n_ellipses > 1:
 *                 raise ValueError('Only one Ellipsis is allowed in index')             # <<<<<<<<<<<<<<
 *             ellipsis_size = ndim - (<Py_ssize_t>len(slices) - n_newaxes - 1)
 *             slices[ellipsis:ellipsis + 1] = noneslices * ellipsis_size
 */
  __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_s_Only_one_Ellipsis_is_allowed_in); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 1444, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);

  /* "cupy/core/core.pyx":1474
 * 
 *         if not mask_exists and len(slices) > self.ndim + n_newaxes:
 *             raise IndexError('too many indices for array')             # <<<<<<<<<<<<<<
 * 
 *         if mask_exists:
 */
  __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_s_too_many_indices_for_array); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 1474, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);

  /* "cupy/core/core.pyx":1480
 *             mask_i = None
 *             for i, s in enumerate(slices):
 *                 if not isinstance(s, slice) or s != slice(None):             # <<<<<<<<<<<<<<
 *                     n_not_slice_none += 1
 *                     if issubclass(s.dtype.type, numpy.bool_):
 */
  __pyx_slice__43 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__43)) __PYX_ERR(0, 1480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__43);
  __Pyx_GIVEREF(__pyx_slice__43);

  /* "cupy/core/core.pyx":1485
 *                         mask_i = i
 *             if n_not_slice_none != 1 and mask_i is not None:
 *                 raise ValueError('currently, CuPy only supports slices that '             # <<<<<<<<<<<<<<
 *                                  'consist of one boolean array.')
 *             return _getitem_mask_single(self, slices[mask_i], mask_i)
 */
  __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_s_currently_CuPy_only_supports_sli); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 1485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__44);
  __Pyx_GIVEREF(__pyx_tuple__44);

  /* "cupy/core/core.pyx":1496
 *                 if type(s) is slice:
 *                     basic_slices.append(s)
 *                     adv_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *                 elif s is None:
 *                     basic_slices.append(None)
 */
  __pyx_slice__45 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__45)) __PYX_ERR(0, 1496, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__45);
  __Pyx_GIVEREF(__pyx_slice__45);

  /* "cupy/core/core.pyx":1499
 *                 elif s is None:
 *                     basic_slices.append(None)
 *                     adv_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *                 elif (isinstance(s, ndarray) and
 *                         issubclass(s.dtype.type, numpy.integer)):
 */
  __pyx_slice__46 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__46)) __PYX_ERR(0, 1499, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__46);
  __Pyx_GIVEREF(__pyx_slice__46);

  /* "cupy/core/core.pyx":1502
 *                 elif (isinstance(s, ndarray) and
 *                         issubclass(s.dtype.type, numpy.integer)):
 *                     basic_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *                     adv_slices.append(s)
 *                 elif isinstance(s, int):
 */
  __pyx_slice__47 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__47)) __PYX_ERR(0, 1502, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__47);
  __Pyx_GIVEREF(__pyx_slice__47);

  /* "cupy/core/core.pyx":1505
 *                     adv_slices.append(s)
 *                 elif isinstance(s, int):
 *                     basic_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *                     scalar_array = ndarray((), dtype=numpy.int64)
 *                     scalar_array.fill(s)
 */
  __pyx_slice__48 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__48)) __PYX_ERR(0, 1505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__48);
  __Pyx_GIVEREF(__pyx_slice__48);

  /* "cupy/core/core.pyx":1506
 *                 elif isinstance(s, int):
 *                     basic_slices.append(slice(None))
 *                     scalar_array = ndarray((), dtype=numpy.int64)             # <<<<<<<<<<<<<<
 *                     scalar_array.fill(s)
 *                     adv_slices.append(scalar_array)
 */
  __pyx_tuple__49 = PyTuple_Pack(1, __pyx_empty_tuple); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 1506, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);

  /* "cupy/core/core.pyx":1510
 *                     adv_slices.append(scalar_array)
 *                 else:
 *                     raise IndexError(             # <<<<<<<<<<<<<<
 *                         'only integers, slices (`:`), ellipsis (`...`),'
 *                         'numpy.newaxis (`None`) and integer or '
 */
  __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_s_only_integers_slices_ellipsis_nu); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 1510, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);

  /* "cupy/core/core.pyx":1518
 *             a = self
 *             for s in basic_slices:
 *                 if s is None or (isinstance(s, slice) and s != slice(None)):             # <<<<<<<<<<<<<<
 *                     a = self[tuple(basic_slices)]
 *                     break
 */
  __pyx_slice__51 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__51)) __PYX_ERR(0, 1518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__51);
  __Pyx_GIVEREF(__pyx_slice__51);

  /* "cupy/core/core.pyx":1524
 *             arr_slices_mask = [not isinstance(s, slice) for s in adv_slices]
 *             if sum(arr_slices_mask) == 1:
 *                 axis = arr_slices_mask.index(True)             # <<<<<<<<<<<<<<
 *                 return a.take(adv_slices[axis], axis)
 *             return _getitem_multiple(a, adv_slices)
 */
  __pyx_tuple__52 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 1524, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__52);
  __Pyx_GIVEREF(__pyx_tuple__52);

  /* "cupy/core/core.pyx":1541
 *                     strides.push_back(self.itemsize)
 *             elif ndim <= j:
 *                 raise IndexError("too many indices for array")             # <<<<<<<<<<<<<<
 *             elif isinstance(s, slice):
 *                 s = internal.complete_slice(s, self._shape[j])
 */
  __pyx_tuple__53 = PyTuple_Pack(1, __pyx_kp_s_too_many_indices_for_array); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 1541, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__53);
  __Pyx_GIVEREF(__pyx_tuple__53);

  /* "cupy/core/core.pyx":1713
 *             return numpy.ndarray(self.shape, dtype=self.dtype)
 * 
 *         with self.device:             # <<<<<<<<<<<<<<
 *             a_gpu = ascontiguousarray(self)
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 */
  __pyx_tuple__54 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(0, 1713, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__54);
  __Pyx_GIVEREF(__pyx_tuple__54);

  /* "cupy/core/core.pyx":1738
 *         """
 *         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__55 = PyTuple_Pack(1, __pyx_kp_s_Only_numpy_ndarray_can_be_set_to); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 1738, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_GIVEREF(__pyx_tuple__55);

  /* "cupy/core/core.pyx":1751
 *             arr = numpy.asfortranarray(arr)
 *         else:
 *             raise RuntimeError('Cannot set to non-contiguous array')             # <<<<<<<<<<<<<<
 * 
 *         ptr = arr.ctypes.get_as_parameter()
 */
  __pyx_tuple__56 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_to_non_contiguous_arr); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(0, 1751, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__56);
  __Pyx_GIVEREF(__pyx_tuple__56);

  /* "cupy/core/core.pyx":1821
 *                                  bint update_c_contiguity=True):
 *         if shape.size() != strides.size():
 *             raise ValueError('len(shape) != len(strides)')             # <<<<<<<<<<<<<<
 *         self._shape = shape
 *         self._strides = strides
 */
  __pyx_tuple__57 = PyTuple_Pack(1, __pyx_kp_s_len_shape_len_strides); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 1821, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_GIVEREF(__pyx_tuple__57);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__58 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_self_val_cannot_be_conv); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(4, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__58);
  __Pyx_GIVEREF(__pyx_tuple__58);

  /* "(tree fragment)":4
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__59 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_self_val_cannot_be_conv); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__60 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_cannot_be_converted_to); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(4, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__60);
  __Pyx_GIVEREF(__pyx_tuple__60);

  /* "(tree fragment)":4
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__61 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_cannot_be_converted_to); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__61);
  __Pyx_GIVEREF(__pyx_tuple__61);

  /* "cupy/core/carray.pxi":118
 *         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__62 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(2, 118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__62);
  __Pyx_GIVEREF(__pyx_tuple__62);

  /* "cupy/core/carray.pxi":129
 *     global _cuda_path
 *     if _cuda_path is None:
 *         _cuda_path = os.getenv('CUDA_PATH', None)             # <<<<<<<<<<<<<<
 *         if _cuda_path is not None:
 *             return _cuda_path
 */
  __pyx_tuple__64 = PyTuple_Pack(2, __pyx_n_s_CUDA_PATH, Py_None); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(2, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__64);
  __Pyx_GIVEREF(__pyx_tuple__64);

  /* "cupy/core/carray.pxi":133
 *             return _cuda_path
 * 
 *         for p in os.getenv('PATH', '').split(os.pathsep):             # <<<<<<<<<<<<<<
 *             for cmd in ('nvcc', 'nvcc.exe'):
 *                 nvcc_path = os.path.join(p, cmd)
 */
  __pyx_tuple__65 = PyTuple_Pack(2, __pyx_n_s_PATH, __pyx_kp_s__5); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(2, 133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__65);
  __Pyx_GIVEREF(__pyx_tuple__65);

  /* "cupy/core/carray.pxi":134
 * 
 *         for p in os.getenv('PATH', '').split(os.pathsep):
 *             for cmd in ('nvcc', 'nvcc.exe'):             # <<<<<<<<<<<<<<
 *                 nvcc_path = os.path.join(p, cmd)
 *                 if not os.path.exists(nvcc_path):
 */
  __pyx_tuple__66 = PyTuple_Pack(2, __pyx_n_s_nvcc, __pyx_kp_s_nvcc_exe); if (unlikely(!__pyx_tuple__66)) __PYX_ERR(2, 134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__66);
  __Pyx_GIVEREF(__pyx_tuple__66);

  /* "cupy/core/carray.pxi":144
 *                 return _cuda_path
 * 
 *         if os.path.exists('/usr/local/cuda'):             # <<<<<<<<<<<<<<
 *             _cuda_path = '/usr/local/cuda'
 * 
 */
  __pyx_tuple__68 = PyTuple_Pack(1, __pyx_kp_s_usr_local_cuda); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(2, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__68);
  __Pyx_GIVEREF(__pyx_tuple__68);

  /* "cupy/core/elementwise.pxi":16
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):
 *     module_code = string.Template('''             # <<<<<<<<<<<<<<
 *     ${preamble}
 *     extern "C" __global__ void ${name}(${params}) {
 */
  __pyx_tuple__69 = PyTuple_Pack(1, __pyx_kp_s_preamble_extern_C___global___vo); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__69);
  __Pyx_GIVEREF(__pyx_tuple__69);

  /* "cupy/core/elementwise.pxi":111
 * cpdef str _get_typename(dtype):
 *     if dtype is None:
 *         raise ValueError('dtype is None')             # <<<<<<<<<<<<<<
 *     if dtype not in _typenames:
 *         dtype = numpy.dtype(dtype).type
 */
  __pyx_tuple__70 = PyTuple_Pack(1, __pyx_kp_s_dtype_is_None); if (unlikely(!__pyx_tuple__70)) __PYX_ERR(1, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__70);
  __Pyx_GIVEREF(__pyx_tuple__70);

  /* "cupy/core/elementwise.pxi":293
 *     if len(s) == 0:
 *         return ()
 *     return tuple([ParameterInfo(i, is_const) for i in s.strip().split(',')])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__73 = PyTuple_Pack(1, __pyx_kp_s__72); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(1, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__73);
  __Pyx_GIVEREF(__pyx_tuple__73);

  /* "cupy/core/elementwise.pxi":303
 *         for p, a in zip(out_params, out_args_dtype):
 *             if a is None:
 *                 raise TypeError('Output arguments must be cupy.ndarray')             # <<<<<<<<<<<<<<
 *             if p.dtype is not None:
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):
 */
  __pyx_tuple__74 = PyTuple_Pack(1, __pyx_kp_s_Output_arguments_must_be_cupy_nd); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(1, 303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__74);
  __Pyx_GIVEREF(__pyx_tuple__74);

  /* "cupy/core/elementwise.pxi":363
 *     if use_size:
 *         if not is_none:
 *             raise ValueError("Specified 'size' can be used only "             # <<<<<<<<<<<<<<
 *                              "if all of the ndarray are 'raw'.")
 *     else:
 */
  __pyx_tuple__75 = PyTuple_Pack(1, __pyx_kp_s_Specified_size_can_be_used_only); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(1, 363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__75);
  __Pyx_GIVEREF(__pyx_tuple__75);

  /* "cupy/core/elementwise.pxi":367
 *     else:
 *         if not is_not_none:
 *             raise ValueError('Loop size is Undecided')             # <<<<<<<<<<<<<<
 *     brod = broadcast(*value)
 *     value = []
 */
  __pyx_tuple__76 = PyTuple_Pack(1, __pyx_kp_s_Loop_size_is_Undecided); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(1, 367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__76);
  __Pyx_GIVEREF(__pyx_tuple__76);

  /* "cupy/core/elementwise.pxi":385
 *     for i, a in enumerate(out_args):
 *         if not isinstance(a, ndarray):
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 'Output arguments type must be cupy.ndarray')
 *         if a.shape != out_shape:
 */
  __pyx_tuple__77 = PyTuple_Pack(1, __pyx_kp_s_Output_arguments_type_must_be_cu); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(1, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__77);
  __Pyx_GIVEREF(__pyx_tuple__77);

  /* "cupy/core/elementwise.pxi":388
 *                 'Output arguments type must be cupy.ndarray')
 *         if a.shape != out_shape:
 *             raise ValueError('Out shape is mismatched')             # <<<<<<<<<<<<<<
 *         out_type = out_types[i]
 *         if not numpy.can_cast(out_type, a.dtype, casting=casting):
 */
  __pyx_tuple__78 = PyTuple_Pack(1, __pyx_kp_s_Out_shape_is_mismatched); if (unlikely(!__pyx_tuple__78)) __PYX_ERR(1, 388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__78);
  __Pyx_GIVEREF(__pyx_tuple__78);

  /* "cupy/core/elementwise.pxi":408
 *         for p in out_params:
 *             if p.raw and is_size_specified is False:
 *                 raise ValueError('Output array size is Undecided')             # <<<<<<<<<<<<<<
 *         return [ndarray(out_shape, t) for t in out_types]
 * 
 */
  __pyx_tuple__79 = PyTuple_Pack(1, __pyx_kp_s_Output_array_size_is_Undecided); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(1, 408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__79);
  __Pyx_GIVEREF(__pyx_tuple__79);

  /* "cupy/core/elementwise.pxi":415
 *         p = out_params[i]
 *         if not isinstance(a, ndarray):
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 'Output arguments type must be cupy.ndarray')
 *         if not p.raw and a.shape != out_shape:
 */
  __pyx_tuple__80 = PyTuple_Pack(1, __pyx_kp_s_Output_arguments_type_must_be_cu); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(1, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__80);
  __Pyx_GIVEREF(__pyx_tuple__80);

  /* "cupy/core/elementwise.pxi":418
 *                 'Output arguments type must be cupy.ndarray')
 *         if not p.raw and a.shape != out_shape:
 *             raise ValueError('Out shape is mismatched')             # <<<<<<<<<<<<<<
 *     return out_args
 * 
 */
  __pyx_tuple__81 = PyTuple_Pack(1, __pyx_kp_s_Out_shape_is_mismatched); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(1, 418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__81);
  __Pyx_GIVEREF(__pyx_tuple__81);

  /* "cupy/core/elementwise.pxi":505
 *         self.nout = len(self.out_params)
 *         self.nargs = self.nin + self.nout
 *         param_rest = _get_param_info('CIndexer _ind', False)             # <<<<<<<<<<<<<<
 *         self.params = self.in_params + self.out_params + param_rest
 *         self.operation = operation
 */
  __pyx_tuple__82 = PyTuple_Pack(2, __pyx_kp_s_CIndexer__ind, Py_False); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(1, 505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__82);
  __Pyx_GIVEREF(__pyx_tuple__82);

  /* "cupy/core/elementwise.pxi":514
 *         names = [p.name for p in self.in_params + self.out_params]
 *         if 'i' in names:
 *             raise ValueError("Can not use 'i' as a parameter name")             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, *args, **kwargs):
 */
  __pyx_tuple__83 = PyTuple_Pack(1, __pyx_kp_s_Can_not_use_i_as_a_parameter_nam); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(1, 514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__83);
  __Pyx_GIVEREF(__pyx_tuple__83);

  /* "cupy/core/elementwise.pxi":540
 *         cdef function.Function kern
 * 
 *         size = kwargs.pop('size', None)             # <<<<<<<<<<<<<<
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:
 */
  __pyx_tuple__84 = PyTuple_Pack(2, __pyx_n_s_size, Py_None); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(1, 540, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__84);
  __Pyx_GIVEREF(__pyx_tuple__84);

  /* "cupy/core/elementwise.pxi":541
 * 
 *         size = kwargs.pop('size', None)
 *         stream = kwargs.pop('stream', None)             # <<<<<<<<<<<<<<
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)
 */
  __pyx_tuple__85 = PyTuple_Pack(2, __pyx_n_s_stream, Py_None); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(1, 541, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__85);
  __Pyx_GIVEREF(__pyx_tuple__85);

  /* "cupy/core/elementwise.pxi":731
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (
 *             ParameterInfo('CIndexer _ind', False),)             # <<<<<<<<<<<<<<
 *         self._routine_cache = {}
 * 
 */
  __pyx_tuple__86 = PyTuple_Pack(2, __pyx_kp_s_CIndexer__ind, Py_False); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(1, 731, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__86);
  __Pyx_GIVEREF(__pyx_tuple__86);

  /* "cupy/core/elementwise.pxi":770
 *         cdef function.Function kern
 * 
 *         out = kwargs.pop('out', None)             # <<<<<<<<<<<<<<
 *         dtype = kwargs.pop('dtype', None)
 *         # Note default behavior of casting is 'same_kind' on numpy>=1.10
 */
  __pyx_tuple__87 = PyTuple_Pack(2, __pyx_n_s_out, Py_None); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(1, 770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__87);
  __Pyx_GIVEREF(__pyx_tuple__87);

  /* "cupy/core/elementwise.pxi":771
 * 
 *         out = kwargs.pop('out', None)
 *         dtype = kwargs.pop('dtype', None)             # <<<<<<<<<<<<<<
 *         # Note default behavior of casting is 'same_kind' on numpy>=1.10
 *         casting = kwargs.pop('casting', self._default_casting)
 */
  __pyx_tuple__88 = PyTuple_Pack(2, __pyx_n_s_dtype, Py_None); if (unlikely(!__pyx_tuple__88)) __PYX_ERR(1, 771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__88);
  __Pyx_GIVEREF(__pyx_tuple__88);

  /* "cupy/core/elementwise.pxi":791
 *                 raise ValueError("Cannot use 'out' in %s" % self.name)
 *             if n_args != self.nin:
 *                 raise ValueError("Cannot specify 'out' as both "             # <<<<<<<<<<<<<<
 *                                  "a positional and keyword argument")
 * 
 */
  __pyx_tuple__89 = PyTuple_Pack(1, __pyx_kp_s_Cannot_specify_out_as_both_a_pos); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(1, 791, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__89);
  __Pyx_GIVEREF(__pyx_tuple__89);

  /* "cupy/core/elementwise.pxi":841
 *             typ, rt = t
 * 
 *         types = typ.split('->')             # <<<<<<<<<<<<<<
 *         if len(types) == 1:
 *             in_types = out_types = tuple(types)
 */
  __pyx_tuple__91 = PyTuple_Pack(1, __pyx_kp_s__90); if (unlikely(!__pyx_tuple__91)) __PYX_ERR(1, 841, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__91);
  __Pyx_GIVEREF(__pyx_tuple__91);

  /* "cupy/core/reduction.pxi":16
 *     if identity is None:
 *         identity = ''
 *     module_code = string.Template('''             # <<<<<<<<<<<<<<
 *     ${type_preamble}
 *     ${preamble}
 */
  __pyx_tuple__92 = PyTuple_Pack(1, __pyx_kp_s_type_preamble_preamble_define_R); if (unlikely(!__pyx_tuple__92)) __PYX_ERR(5, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__92);
  __Pyx_GIVEREF(__pyx_tuple__92);

  /* "cupy/core/reduction.pxi":120
 *     for dim in axis:
 *         if dim < -ndim or dim >= ndim:
 *             raise ValueError('Axis overrun')             # <<<<<<<<<<<<<<
 *     axis = tuple(sorted([dim % ndim for dim in axis]))
 *     raxis = tuple([dim for dim in range(ndim) if dim not in axis])
 */
  __pyx_tuple__93 = PyTuple_Pack(1, __pyx_kp_s_Axis_overrun); if (unlikely(!__pyx_tuple__93)) __PYX_ERR(5, 120, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__93);
  __Pyx_GIVEREF(__pyx_tuple__93);

  /* "cupy/core/reduction.pxi":143
 *         for p in params:
 *             if p.raw:
 *                 raise NotImplementedError('Illegal conditions')             # <<<<<<<<<<<<<<
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a
 *             for a in args]
 */
  __pyx_tuple__94 = PyTuple_Pack(1, __pyx_kp_s_Illegal_conditions); if (unlikely(!__pyx_tuple__94)) __PYX_ERR(5, 143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__94);
  __Pyx_GIVEREF(__pyx_tuple__94);

  /* "cupy/core/reduction.pxi":195
 *         self.nin = 1
 *         self.nout = 1
 *         in_params = _get_param_info('T in0', True)             # <<<<<<<<<<<<<<
 *         out_params = _get_param_info('T out0', False)
 *         self._params = (
 */
  __pyx_tuple__95 = PyTuple_Pack(2, __pyx_kp_s_T_in0, Py_True); if (unlikely(!__pyx_tuple__95)) __PYX_ERR(5, 195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__95);
  __Pyx_GIVEREF(__pyx_tuple__95);

  /* "cupy/core/reduction.pxi":196
 *         self.nout = 1
 *         in_params = _get_param_info('T in0', True)
 *         out_params = _get_param_info('T out0', False)             # <<<<<<<<<<<<<<
 *         self._params = (
 *             in_params + out_params +
 */
  __pyx_tuple__96 = PyTuple_Pack(2, __pyx_kp_s_T_out0, Py_False); if (unlikely(!__pyx_tuple__96)) __PYX_ERR(5, 196, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__96);
  __Pyx_GIVEREF(__pyx_tuple__96);

  /* "cupy/core/reduction.pxi":199
 *         self._params = (
 *             in_params + out_params +
 *             _get_param_info(             # <<<<<<<<<<<<<<
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))
 */
  __pyx_tuple__97 = PyTuple_Pack(2, __pyx_kp_s_CIndexer__in_ind_CIndexer__out_i, Py_False); if (unlikely(!__pyx_tuple__97)) __PYX_ERR(5, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__97);
  __Pyx_GIVEREF(__pyx_tuple__97);

  /* "cupy/core/reduction.pxi":201
 *             _get_param_info(
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))             # <<<<<<<<<<<<<<
 *         self._input_expr = 'const type_in0_raw in0 = _raw_in0[_in_ind.get()];'
 *         self._output_expr = 'type_out0_raw &out0 = _raw_out0[_out_ind.get()];'
 */
  __pyx_tuple__98 = PyTuple_Pack(2, __pyx_kp_s_int32__block_stride, Py_True); if (unlikely(!__pyx_tuple__98)) __PYX_ERR(5, 201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__98);
  __Pyx_GIVEREF(__pyx_tuple__98);

  /* "cupy/core/reduction.pxi":342
 *         self.params = (
 *             self.in_params + self.out_params +
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +             # <<<<<<<<<<<<<<
 *             _get_param_info('int32 _block_stride', True))
 *         self.identity = identity
 */
  __pyx_tuple__99 = PyTuple_Pack(2, __pyx_kp_s_CIndexer__in_ind_CIndexer__out_i, Py_False); if (unlikely(!__pyx_tuple__99)) __PYX_ERR(5, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__99);
  __Pyx_GIVEREF(__pyx_tuple__99);

  /* "cupy/core/reduction.pxi":343
 *             self.in_params + self.out_params +
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))             # <<<<<<<<<<<<<<
 *         self.identity = identity
 *         self.reduce_expr = reduce_expr
 */
  __pyx_tuple__100 = PyTuple_Pack(2, __pyx_kp_s_int32__block_stride, Py_True); if (unlikely(!__pyx_tuple__100)) __PYX_ERR(5, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__100);
  __Pyx_GIVEREF(__pyx_tuple__100);

  /* "cupy/core/reduction.pxi":374
 *         """
 * 
 *         out = kwargs.pop('out', None)             # <<<<<<<<<<<<<<
 *         axis = kwargs.pop('axis', None)
 *         keepdims = kwargs.pop('keepdims', False)
 */
  __pyx_tuple__101 = PyTuple_Pack(2, __pyx_n_s_out, Py_None); if (unlikely(!__pyx_tuple__101)) __PYX_ERR(5, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__101);
  __Pyx_GIVEREF(__pyx_tuple__101);

  /* "cupy/core/reduction.pxi":375
 * 
 *         out = kwargs.pop('out', None)
 *         axis = kwargs.pop('axis', None)             # <<<<<<<<<<<<<<
 *         keepdims = kwargs.pop('keepdims', False)
 *         stream = kwargs.pop('stream', None)
 */
  __pyx_tuple__102 = PyTuple_Pack(2, __pyx_n_s_axis, Py_None); if (unlikely(!__pyx_tuple__102)) __PYX_ERR(5, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__102);
  __Pyx_GIVEREF(__pyx_tuple__102);

  /* "cupy/core/reduction.pxi":376
 *         out = kwargs.pop('out', None)
 *         axis = kwargs.pop('axis', None)
 *         keepdims = kwargs.pop('keepdims', False)             # <<<<<<<<<<<<<<
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:
 */
  __pyx_tuple__103 = PyTuple_Pack(2, __pyx_n_s_keepdims, Py_False); if (unlikely(!__pyx_tuple__103)) __PYX_ERR(5, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__103);
  __Pyx_GIVEREF(__pyx_tuple__103);

  /* "cupy/core/reduction.pxi":377
 *         axis = kwargs.pop('axis', None)
 *         keepdims = kwargs.pop('keepdims', False)
 *         stream = kwargs.pop('stream', None)             # <<<<<<<<<<<<<<
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)
 */
  __pyx_tuple__104 = PyTuple_Pack(2, __pyx_n_s_stream, Py_None); if (unlikely(!__pyx_tuple__104)) __PYX_ERR(5, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__104);
  __Pyx_GIVEREF(__pyx_tuple__104);

  /* "cupy/core/reduction.pxi":388
 *         if out is not None:
 *             if self.nout != 1:
 *                 raise NotImplementedError('')             # <<<<<<<<<<<<<<
 *             if len(out_args) != 0:
 *                 raise ValueError("cannot specify 'out' as both "
 */
  __pyx_tuple__105 = PyTuple_Pack(1, __pyx_kp_s__5); if (unlikely(!__pyx_tuple__105)) __PYX_ERR(5, 388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__105);
  __Pyx_GIVEREF(__pyx_tuple__105);

  /* "cupy/core/reduction.pxi":390
 *                 raise NotImplementedError('')
 *             if len(out_args) != 0:
 *                 raise ValueError("cannot specify 'out' as both "             # <<<<<<<<<<<<<<
 *                                  "a positional and keyword argument")
 *             out_args = [out]
 */
  __pyx_tuple__106 = PyTuple_Pack(1, __pyx_kp_s_cannot_specify_out_as_both_a_pos); if (unlikely(!__pyx_tuple__106)) __PYX_ERR(5, 390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__106);
  __Pyx_GIVEREF(__pyx_tuple__106);

  /* "cupy/core/reduction.pxi":464
 *             rt = tuple([i or j for i, j in zip(rt, routine)])
 * 
 *         types = typ.split('->')             # <<<<<<<<<<<<<<
 *         if len(types) == 1:
 *             in_types = out_types = tuple(types)
 */
  __pyx_tuple__107 = PyTuple_Pack(1, __pyx_kp_s__90); if (unlikely(!__pyx_tuple__107)) __PYX_ERR(5, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__107);
  __Pyx_GIVEREF(__pyx_tuple__107);

  /* "cupy/core/core.pyx":2107
 *                 # When `copy` is False, `a` is same as `obj`.
 *                 a = a.view()
 *             a.shape = (1,) * (ndmin - ndim) + a.shape             # <<<<<<<<<<<<<<
 *     else:
 *         if order == 'K':
 */
  __pyx_tuple__108 = PyTuple_New(1); if (unlikely(!__pyx_tuple__108)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__108);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__108, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__108);

  /* "cupy/core/core.pyx":2218
 * 
 *     if len(src) != len(dest):
 *         raise ValueError('`source` and `destination` arguments must have '             # <<<<<<<<<<<<<<
 *                          'the same number of elements')
 * 
 */
  __pyx_tuple__109 = PyTuple_Pack(1, __pyx_kp_s_source_and_destination_argument); if (unlikely(!__pyx_tuple__109)) __PYX_ERR(0, 2218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__109);
  __Pyx_GIVEREF(__pyx_tuple__109);

  /* "cupy/core/core.pyx":2243
 *         start += ndim
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 *         raise ValueError('Axis out of range')             # <<<<<<<<<<<<<<
 *     if axis < start:
 *         start -= 1
 */
  __pyx_tuple__110 = PyTuple_Pack(1, __pyx_kp_s_Axis_out_of_range); if (unlikely(!__pyx_tuple__110)) __PYX_ERR(0, 2243, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__110);
  __Pyx_GIVEREF(__pyx_tuple__110);

  /* "cupy/core/core.pyx":2265
 *     ndim = ary.ndim
 *     if -ndim > axis or ndim <= axis:
 *         raise IndexError('Axis exceeds ndim')             # <<<<<<<<<<<<<<
 *     if axis < 0:
 *         axis += ndim
 */
  __pyx_tuple__111 = PyTuple_Pack(1, __pyx_kp_s_Axis_exceeds_ndim); if (unlikely(!__pyx_tuple__111)) __PYX_ERR(0, 2265, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__111);
  __Pyx_GIVEREF(__pyx_tuple__111);

  /* "cupy/core/core.pyx":2337
 *         cdef vector.vector[vector.vector[Py_ssize_t]] shape_arr
 *         cdef ndarray a, view
 *         rev = slice(None, None, -1)             # <<<<<<<<<<<<<<
 * 
 *         self.nd = 0
 */
  __pyx_slice__112 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__112)) __PYX_ERR(0, 2337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__112);
  __Pyx_GIVEREF(__pyx_slice__112);

  /* "cupy/core/core.pyx":2358
 *                     smax = max(smax, s)
 *             if smin == 0 and smax > 1:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'shape mismatch: objects cannot be broadcast to a '
 *                     'single shape')
 */
  __pyx_tuple__113 = PyTuple_Pack(1, __pyx_kp_s_shape_mismatch_objects_cannot_be); if (unlikely(!__pyx_tuple__113)) __PYX_ERR(0, 2358, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__113);
  __Pyx_GIVEREF(__pyx_tuple__113);

  /* "cupy/core/core.pyx":2384
 *                     r_strides[i] = a._strides[a_ndim - i - 1]
 *                 elif a_sh != 1:
 *                     raise ValueError('Broadcasting failed')             # <<<<<<<<<<<<<<
 * 
 *             strides.assign(r_strides.rbegin(), r_strides.rend())
 */
  __pyx_tuple__114 = PyTuple_Pack(1, __pyx_kp_s_Broadcasting_failed); if (unlikely(!__pyx_tuple__114)) __PYX_ERR(0, 2384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__114);
  __Pyx_GIVEREF(__pyx_tuple__114);

  /* "cupy/core/core.pyx":2403
 *     """
 *     if array.ndim > len(shape):
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             'input operand has more dimensions than allowed by the axis '
 *             'remapping')
 */
  __pyx_tuple__115 = PyTuple_Pack(1, __pyx_kp_s_input_operand_has_more_dimension); if (unlikely(!__pyx_tuple__115)) __PYX_ERR(0, 2403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__115);
  __Pyx_GIVEREF(__pyx_tuple__115);

  /* "cupy/core/core.pyx":2415
 *             strides[j] = array._strides[j % array.ndim]
 *         elif a_sh != 1:
 *             raise ValueError('Broadcasting failed')             # <<<<<<<<<<<<<<
 * 
 *     view = array.view()
 */
  __pyx_tuple__116 = PyTuple_Pack(1, __pyx_kp_s_Broadcasting_failed); if (unlikely(!__pyx_tuple__116)) __PYX_ERR(0, 2415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__116);
  __Pyx_GIVEREF(__pyx_tuple__116);

  /* "cupy/core/core.pyx":2461
 *     if axis is None:
 *         if broadcast:
 *             a = a.reshape((-1, 1))             # <<<<<<<<<<<<<<
 *             ret = ndarray((a.size, repeats[0]), dtype=a.dtype)
 *             if ret.size:
 */
  __pyx_tuple__117 = PyTuple_Pack(2, __pyx_int_neg_1, __pyx_int_1); if (unlikely(!__pyx_tuple__117)) __PYX_ERR(0, 2461, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__117);
  __Pyx_GIVEREF(__pyx_tuple__117);
  __pyx_tuple__118 = PyTuple_Pack(1, __pyx_tuple__117); if (unlikely(!__pyx_tuple__118)) __PYX_ERR(0, 2461, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__118);
  __Pyx_GIVEREF(__pyx_tuple__118);

  /* "cupy/core/core.pyx":2487
 *     ret_shape[axis] = sum(repeats)
 *     ret = ndarray(ret_shape, dtype=a.dtype)
 *     a_index = [slice(None)] * len(ret_shape)             # <<<<<<<<<<<<<<
 *     ret_index = list(a_index)
 *     offset = 0
 */
  __pyx_slice__119 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__119)) __PYX_ERR(0, 2487, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__119);
  __Pyx_GIVEREF(__pyx_slice__119);

  /* "cupy/core/core.pyx":2513
 *     for o in tup:
 *         if not isinstance(o, ndarray):
 *             raise TypeError('Only cupy arrays can be concatenated')             # <<<<<<<<<<<<<<
 *         a = o
 *         if a.ndim == 0:
 */
  __pyx_tuple__120 = PyTuple_Pack(1, __pyx_kp_s_Only_cupy_arrays_can_be_concaten); if (unlikely(!__pyx_tuple__120)) __PYX_ERR(0, 2513, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__120);
  __Pyx_GIVEREF(__pyx_tuple__120);

  /* "cupy/core/core.pyx":2516
 *         a = o
 *         if a.ndim == 0:
 *             raise TypeError('zero-dimensional arrays cannot be concatenated')             # <<<<<<<<<<<<<<
 *         if ndim == -1:
 *             ndim = a.ndim
 */
  __pyx_tuple__121 = PyTuple_Pack(1, __pyx_kp_s_zero_dimensional_arrays_cannot_b); if (unlikely(!__pyx_tuple__121)) __PYX_ERR(0, 2516, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__121);
  __Pyx_GIVEREF(__pyx_tuple__121);

  /* "cupy/core/core.pyx":2530
 *         have_same_types = have_same_types and (a.dtype == dtype)
 *         if a.ndim != ndim:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'All arrays to concatenate must have the same ndim')
 *         for i in range(ndim):
 */
  __pyx_tuple__122 = PyTuple_Pack(1, __pyx_kp_s_All_arrays_to_concatenate_must_h); if (unlikely(!__pyx_tuple__122)) __PYX_ERR(0, 2530, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__122);
  __Pyx_GIVEREF(__pyx_tuple__122);

  /* "cupy/core/core.pyx":2534
 *         for i in range(ndim):
 *             if i != axis and shape[i] != a._shape[i]:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'All arrays must have same shape except the axis to '
 *                     'concatenate')
 */
  __pyx_tuple__123 = PyTuple_Pack(1, __pyx_kp_s_All_arrays_must_have_same_shape); if (unlikely(!__pyx_tuple__123)) __PYX_ERR(0, 2534, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__123);
  __Pyx_GIVEREF(__pyx_tuple__123);

  /* "cupy/core/core.pyx":2540
 * 
 *     if ndim == -1:
 *         raise ValueError('Cannot concatenate from empty tuple')             # <<<<<<<<<<<<<<
 * 
 *     if not have_same_types:
 */
  __pyx_tuple__124 = PyTuple_Pack(1, __pyx_kp_s_Cannot_concatenate_from_empty_tu); if (unlikely(!__pyx_tuple__124)) __PYX_ERR(0, 2540, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__124);
  __Pyx_GIVEREF(__pyx_tuple__124);

  /* "cupy/core/core.pyx":2574
 *     if ((not all_same_type or not any_contiguous_on_axis) and
 *             (len(tup) < 256 or total_bytes / len(tup) > 524288)):
 *         skip = (slice(None),) * axis             # <<<<<<<<<<<<<<
 *         i = 0
 *         for a in tup:
 */
  __pyx_slice__125 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__125)) __PYX_ERR(0, 2574, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__125);
  __Pyx_GIVEREF(__pyx_slice__125);
  __pyx_tuple__126 = PyTuple_New(1); if (unlikely(!__pyx_tuple__126)) __PYX_ERR(0, 2574, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__126);
  __Pyx_INCREF(__pyx_slice__125);
  __Pyx_GIVEREF(__pyx_slice__125);
  PyTuple_SET_ITEM(__pyx_tuple__126, 0, __pyx_slice__125);
  __Pyx_GIVEREF(__pyx_tuple__126);

  /* "cupy/core/core.pyx":2678
 *             index += ndim
 *         if not 0 <= index < ndim:
 *             raise IndexError('index out of range')             # <<<<<<<<<<<<<<
 *         return a._shape[index]
 * 
 */
  __pyx_tuple__127 = PyTuple_Pack(1, __pyx_kp_s_index_out_of_range); if (unlikely(!__pyx_tuple__127)) __PYX_ERR(0, 2678, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__127);
  __Pyx_GIVEREF(__pyx_tuple__127);

  /* "cupy/core/core.pyx":2686
 * 
 * cpdef _create_bit_op(name, op, no_bool, doc=''):
 *     types = () if no_bool else ('??->?',)             # <<<<<<<<<<<<<<
 *     return create_ufunc(
 *         'cupy_' + name,
 */
  __pyx_tuple__129 = PyTuple_Pack(1, __pyx_kp_s__128); if (unlikely(!__pyx_tuple__129)) __PYX_ERR(0, 2686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__129);
  __Pyx_GIVEREF(__pyx_tuple__129);

  /* "cupy/core/core.pyx":2689
 *     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__130 = PyTuple_Pack(10, __pyx_kp_s_bb_b, __pyx_kp_s_BB_B, __pyx_kp_s_hh_h, __pyx_kp_s_HH_H, __pyx_kp_s_ii_i, __pyx_kp_s_II_I, __pyx_kp_s_ll_l, __pyx_kp_s_LL_L, __pyx_kp_s_qq_q, __pyx_kp_s_QQ_Q); if (unlikely(!__pyx_tuple__130)) __PYX_ERR(0, 2689, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__130);
  __Pyx_GIVEREF(__pyx_tuple__130);

  /* "cupy/core/core.pyx":2871
 * 
 *     if mask.size == 0:
 *         masked_shape = lshape + (0,) + rshape             # <<<<<<<<<<<<<<
 *         mask_br = mask._reshape(masked_shape)
 *         return mask_br, mask_br, masked_shape
 */
  __pyx_tuple__131 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__131)) __PYX_ERR(0, 2871, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__131);
  __Pyx_GIVEREF(__pyx_tuple__131);

  /* "cupy/core/core.pyx":2891
 *     # The scan of the broadcasted array is used to index on kernel.
 *     mask_br = mask._reshape(
 *         axis * (1,) + mask.shape + (a.ndim - axis - mask.ndim) * (1,))             # <<<<<<<<<<<<<<
 *     mask_br = broadcast_to(mask_br, a.shape)
 *     if mask.size <= 2 ** 31 - 1:
 */
  __pyx_tuple__132 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__132)) __PYX_ERR(0, 2891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__132);
  __Pyx_GIVEREF(__pyx_tuple__132);
  __pyx_tuple__133 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__133)) __PYX_ERR(0, 2891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__133);
  __Pyx_GIVEREF(__pyx_tuple__133);

  /* "cupy/core/core.pyx":2927
 *     else:
 *         if not (-a.ndim <= li < a.ndim and -a.ndim <= ri < a.ndim):
 *             raise _AxisError('Axis overrun')             # <<<<<<<<<<<<<<
 *         if a.ndim != 0:
 *             li %= a.ndim
 */
  __pyx_tuple__134 = PyTuple_Pack(1, __pyx_kp_s_Axis_overrun); if (unlikely(!__pyx_tuple__134)) __PYX_ERR(0, 2927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__134);
  __Pyx_GIVEREF(__pyx_tuple__134);

  /* "cupy/core/core.pyx":2945
 *         else:
 *             if out.dtype != a.dtype:
 *                 raise TypeError('Output dtype mismatch')             # <<<<<<<<<<<<<<
 *             if out.shape != a.shape[1:]:
 *                 raise ValueError('Output shape mismatch')
 */
  __pyx_tuple__135 = PyTuple_Pack(1, __pyx_kp_s_Output_dtype_mismatch); if (unlikely(!__pyx_tuple__135)) __PYX_ERR(0, 2945, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__135);
  __Pyx_GIVEREF(__pyx_tuple__135);

  /* "cupy/core/core.pyx":2946
 *             if out.dtype != a.dtype:
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Output shape mismatch')
 *             out[()] = a[indices]
 */
  __pyx_slice__136 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__136)) __PYX_ERR(0, 2946, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__136);
  __Pyx_GIVEREF(__pyx_slice__136);

  /* "cupy/core/core.pyx":2947
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:
 *                 raise ValueError('Output shape mismatch')             # <<<<<<<<<<<<<<
 *             out[()] = a[indices]
 *             return out
 */
  __pyx_tuple__137 = PyTuple_Pack(1, __pyx_kp_s_Output_shape_mismatch); if (unlikely(!__pyx_tuple__137)) __PYX_ERR(0, 2947, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__137);
  __Pyx_GIVEREF(__pyx_tuple__137);

  /* "cupy/core/core.pyx":2958
 *     else:
 *         if out.dtype != a.dtype:
 *             raise TypeError('Output dtype mismatch')             # <<<<<<<<<<<<<<
 *         if out.shape != out_shape:
 *             raise ValueError('Output shape mismatch')
 */
  __pyx_tuple__138 = PyTuple_Pack(1, __pyx_kp_s_Output_dtype_mismatch); if (unlikely(!__pyx_tuple__138)) __PYX_ERR(0, 2958, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__138);
  __Pyx_GIVEREF(__pyx_tuple__138);

  /* "cupy/core/core.pyx":2960
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:
 *             raise ValueError('Output shape mismatch')             # <<<<<<<<<<<<<<
 * 
 *     cdim = indices.size
 */
  __pyx_tuple__139 = PyTuple_Pack(1, __pyx_kp_s_Output_shape_mismatch); if (unlikely(!__pyx_tuple__139)) __PYX_ERR(0, 2960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__139);
  __Pyx_GIVEREF(__pyx_tuple__139);

  /* "cupy/core/core.pyx":2965
 *     rdim = internal.prod(rshape)
 *     indices = indices.reshape(
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))             # <<<<<<<<<<<<<<
 *     if (li == 0 and ri == 0) or (li is None and ri is None):
 *         return _take_kernel_0axis(
 */
  __pyx_tuple__140 = PyTuple_New(1); if (unlikely(!__pyx_tuple__140)) __PYX_ERR(0, 2965, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__140);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__140, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__140);
  __pyx_tuple__141 = PyTuple_New(1); if (unlikely(!__pyx_tuple__141)) __PYX_ERR(0, 2965, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__141);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__141, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__141);

  /* "cupy/core/core.pyx":2992
 * 
 *     if ndim == 0:
 *         raise ValueError("requires a.ndim >= 1")             # <<<<<<<<<<<<<<
 *     if not (-ndim <= li < ndim and -ndim <= ri < ndim):
 *         raise ValueError('Axis overrun')
 */
  __pyx_tuple__142 = PyTuple_Pack(1, __pyx_kp_s_requires_a_ndim_1); if (unlikely(!__pyx_tuple__142)) __PYX_ERR(0, 2992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__142);
  __Pyx_GIVEREF(__pyx_tuple__142);

  /* "cupy/core/core.pyx":2994
 *         raise ValueError("requires a.ndim >= 1")
 *     if not (-ndim <= li < ndim and -ndim <= ri < ndim):
 *         raise ValueError('Axis overrun')             # <<<<<<<<<<<<<<
 * 
 *     if not isinstance(v, ndarray):
 */
  __pyx_tuple__143 = PyTuple_Pack(1, __pyx_kp_s_Axis_overrun); if (unlikely(!__pyx_tuple__143)) __PYX_ERR(0, 2994, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__143);
  __Pyx_GIVEREF(__pyx_tuple__143);

  /* "cupy/core/core.pyx":3015
 *     rdim = internal.prod(rshape)
 *     indices = indices._reshape(
 *         (1,) * len(lshape) + indices_shape + (1,) * len(rshape))             # <<<<<<<<<<<<<<
 *     indices = broadcast_to(indices, v_shape)
 * 
 */
  __pyx_tuple__144 = PyTuple_New(1); if (unlikely(!__pyx_tuple__144)) __PYX_ERR(0, 3015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__144);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__144, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__144);
  __pyx_tuple__145 = PyTuple_New(1); if (unlikely(!__pyx_tuple__145)) __PYX_ERR(0, 3015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__145);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__145, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__145);

  /* "cupy/core/core.pyx":3027
 *                           (numpy.int32, numpy.float32,
 *                            numpy.uint32, numpy.uint64, numpy.ulonglong)):
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 'scatter_add only supports int32, float32, uint32, uint64 as '
 *                 'data type')
 */
  __pyx_tuple__146 = PyTuple_Pack(1, __pyx_kp_s_scatter_add_only_supports_int32); if (unlikely(!__pyx_tuple__146)) __PYX_ERR(0, 3027, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__146);
  __Pyx_GIVEREF(__pyx_tuple__146);

  /* "cupy/core/core.pyx":3033
 *             v, indices, cdim, rdim, adim, a.reduced_view())
 *     else:
 *         raise ValueError('provided op is not supported')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__147 = PyTuple_Pack(1, __pyx_kp_s_provided_op_is_not_supported); if (unlikely(!__pyx_tuple__147)) __PYX_ERR(0, 3033, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__147);
  __Pyx_GIVEREF(__pyx_tuple__147);

  /* "cupy/core/core.pyx":3056
 *         _scatter_add_mask_kernel(v, mask, mask_scanned, a)
 *     else:
 *         raise ValueError('provided op is not supported')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__148 = PyTuple_Pack(1, __pyx_kp_s_provided_op_is_not_supported); if (unlikely(!__pyx_tuple__148)) __PYX_ERR(0, 3056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__148);
  __Pyx_GIVEREF(__pyx_tuple__148);

  /* "cupy/core/core.pyx":3085
 *             ellipsis = i
 *     ndim = a._shape.size()
 *     noneslices = [slice(None)]             # <<<<<<<<<<<<<<
 *     if n_ellipses > 0:
 *         if n_ellipses > 1:
 */
  __pyx_slice__149 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__149)) __PYX_ERR(0, 3085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__149);
  __Pyx_GIVEREF(__pyx_slice__149);

  /* "cupy/core/core.pyx":3088
 *     if n_ellipses > 0:
 *         if n_ellipses > 1:
 *             raise ValueError('Only one Ellipsis is allowed in index')             # <<<<<<<<<<<<<<
 *         ellipsis_size = ndim - (<Py_ssize_t>len(slices) - n_newaxes - 1)
 *         slices[ellipsis:ellipsis + 1] = noneslices * ellipsis_size
 */
  __pyx_tuple__150 = PyTuple_Pack(1, __pyx_kp_s_Only_one_Ellipsis_is_allowed_in); if (unlikely(!__pyx_tuple__150)) __PYX_ERR(0, 3088, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__150);
  __Pyx_GIVEREF(__pyx_tuple__150);

  /* "cupy/core/core.pyx":3118
 * 
 *     if not mask_exists and len(slices) > a.ndim + n_newaxes:
 *         raise IndexError('too many indices for array')             # <<<<<<<<<<<<<<
 * 
 *     if mask_exists:
 */
  __pyx_tuple__151 = PyTuple_Pack(1, __pyx_kp_s_too_many_indices_for_array); if (unlikely(!__pyx_tuple__151)) __PYX_ERR(0, 3118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__151);
  __Pyx_GIVEREF(__pyx_tuple__151);

  /* "cupy/core/core.pyx":3123
 *         n_not_slice_none = 0
 *         for i, s in enumerate(slices):
 *             if not isinstance(s, slice) or s != slice(None):             # <<<<<<<<<<<<<<
 *                 n_not_slice_none += 1
 *                 if issubclass(s.dtype.type, numpy.bool_):
 */
  __pyx_slice__152 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__152)) __PYX_ERR(0, 3123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__152);
  __Pyx_GIVEREF(__pyx_slice__152);

  /* "cupy/core/core.pyx":3128
 *                     mask_i = i
 *         if n_not_slice_none != 1:
 *             raise ValueError('currently, CuPy only supports slices that '             # <<<<<<<<<<<<<<
 *                              'consist of one boolean array.')
 *         _scatter_op_mask_single(a, slices[mask_i], value, mask_i, op)
 */
  __pyx_tuple__153 = PyTuple_Pack(1, __pyx_kp_s_currently_CuPy_only_supports_sli); if (unlikely(!__pyx_tuple__153)) __PYX_ERR(0, 3128, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__153);
  __Pyx_GIVEREF(__pyx_tuple__153);

  /* "cupy/core/core.pyx":3140
 *             if type(s) is slice:
 *                 basic_slices.append(s)
 *                 adv_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *             elif s is None:
 *                 basic_slices.append(None)
 */
  __pyx_slice__154 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__154)) __PYX_ERR(0, 3140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__154);
  __Pyx_GIVEREF(__pyx_slice__154);

  /* "cupy/core/core.pyx":3143
 *             elif s is None:
 *                 basic_slices.append(None)
 *                 adv_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *             elif (isinstance(s, ndarray) and
 *                     issubclass(s.dtype.type, numpy.integer)):
 */
  __pyx_slice__155 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__155)) __PYX_ERR(0, 3143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__155);
  __Pyx_GIVEREF(__pyx_slice__155);

  /* "cupy/core/core.pyx":3146
 *             elif (isinstance(s, ndarray) and
 *                     issubclass(s.dtype.type, numpy.integer)):
 *                 basic_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *                 adv_slices.append(s)
 *             elif isinstance(s, int):
 */
  __pyx_slice__156 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__156)) __PYX_ERR(0, 3146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__156);
  __Pyx_GIVEREF(__pyx_slice__156);

  /* "cupy/core/core.pyx":3149
 *                 adv_slices.append(s)
 *             elif isinstance(s, int):
 *                 basic_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *                 scalar_array = ndarray((), dtype=numpy.int64)
 *                 scalar_array.fill(s)
 */
  __pyx_slice__157 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__157)) __PYX_ERR(0, 3149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__157);
  __Pyx_GIVEREF(__pyx_slice__157);

  /* "cupy/core/core.pyx":3150
 *             elif isinstance(s, int):
 *                 basic_slices.append(slice(None))
 *                 scalar_array = ndarray((), dtype=numpy.int64)             # <<<<<<<<<<<<<<
 *                 scalar_array.fill(s)
 *                 adv_slices.append(scalar_array)
 */
  __pyx_tuple__158 = PyTuple_Pack(1, __pyx_empty_tuple); if (unlikely(!__pyx_tuple__158)) __PYX_ERR(0, 3150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__158);
  __Pyx_GIVEREF(__pyx_tuple__158);

  /* "cupy/core/core.pyx":3154
 *                 adv_slices.append(scalar_array)
 *             else:
 *                 raise IndexError(             # <<<<<<<<<<<<<<
 *                     'only integers, slices (`:`), ellipsis (`...`),'
 *                     'numpy.newaxis (`None`) and integer or '
 */
  __pyx_tuple__159 = PyTuple_Pack(1, __pyx_kp_s_only_integers_slices_ellipsis_nu); if (unlikely(!__pyx_tuple__159)) __PYX_ERR(0, 3154, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__159);
  __Pyx_GIVEREF(__pyx_tuple__159);

  /* "cupy/core/core.pyx":3161
 *         # check if this is a combination of basic and advanced indexing
 *         for s in basic_slices:
 *             if s is None or (isinstance(s, slice) and s != slice(None)):             # <<<<<<<<<<<<<<
 *                 # returns a view of a
 *                 a = a[tuple(basic_slices)]
 */
  __pyx_slice__160 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__160)) __PYX_ERR(0, 3161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__160);
  __Pyx_GIVEREF(__pyx_slice__160);

  /* "cupy/core/core.pyx":3168
 *         arr_slices_mask = [not isinstance(s, slice) for s in adv_slices]
 *         if sum(arr_slices_mask) == 1:
 *             axis = arr_slices_mask.index(True)             # <<<<<<<<<<<<<<
 *             _scatter_op_single(a, adv_slices[axis], value,
 *                                li=axis, ri=axis, op=op)
 */
  __pyx_tuple__161 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__161)) __PYX_ERR(0, 3168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__161);
  __Pyx_GIVEREF(__pyx_tuple__161);

  /* "cupy/core/core.pyx":3201
 *         elementwise_copy(x + y, y)
 *     else:
 *         raise ValueError('this op is not supported')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__162 = PyTuple_Pack(1, __pyx_kp_s_this_op_is_not_supported); if (unlikely(!__pyx_tuple__162)) __PYX_ERR(0, 3201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__162);
  __Pyx_GIVEREF(__pyx_tuple__162);

  /* "cupy/core/core.pyx":3229
 * 
 *     diag_size = max(0, min(a.shape[-2], a.shape[-1] - offset))
 *     ret_shape = a.shape[:-2] + (diag_size,)             # <<<<<<<<<<<<<<
 *     if diag_size == 0:
 *         return ndarray(ret_shape, dtype=a.dtype)
 */
  __pyx_slice__163 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__163)) __PYX_ERR(0, 3229, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__163);
  __Pyx_GIVEREF(__pyx_slice__163);

  /* "cupy/core/core.pyx":3237
 *     ret = a.view()
 *     ret._set_shape_and_strides(
 *         a.shape[:-2] + (diag_size,),             # <<<<<<<<<<<<<<
 *         a.strides[:-2] + (a.strides[-1] + a.strides[-2],))
 *     return ret
 */
  __pyx_slice__164 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__164)) __PYX_ERR(0, 3237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__164);
  __Pyx_GIVEREF(__pyx_slice__164);

  /* "cupy/core/core.pyx":3238
 *     ret._set_shape_and_strides(
 *         a.shape[:-2] + (diag_size,),
 *         a.strides[:-2] + (a.strides[-1] + a.strides[-2],))             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
  __pyx_slice__165 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__165)) __PYX_ERR(0, 3238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__165);
  __Pyx_GIVEREF(__pyx_slice__165);

  /* "cupy/core/core.pyx":3303
 *     concat_shape = (len(flattened_indexes),) + br.shape
 *     flattened_indexes = concatenate(
 *         [index._reshape((1,) + index.shape) for index in flattened_indexes],             # <<<<<<<<<<<<<<
 *         axis=0, shape=concat_shape, dtype=flattened_indexes[0].dtype)
 * 
 */
  __pyx_tuple__166 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__166)) __PYX_ERR(0, 3303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__166);
  __Pyx_GIVEREF(__pyx_tuple__166);

  /* "cupy/core/core.pyx":3340
 * 
 *     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__167 = PyTuple_Pack(1, __pyx_kp_s_Not_supported_dtype_combination); if (unlikely(!__pyx_tuple__167)) __PYX_ERR(0, 3340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__167);
  __Pyx_GIVEREF(__pyx_tuple__167);

  /* "cupy/core/core.pyx":3364
 * 
 *     if a._shape[a_axis] != b._shape[b_axis]:
 *         raise ValueError('Axis dimension mismatch')             # <<<<<<<<<<<<<<
 * 
 *     if a_axis:
 */
  __pyx_tuple__168 = PyTuple_Pack(1, __pyx_kp_s_Axis_dimension_mismatch); if (unlikely(!__pyx_tuple__168)) __PYX_ERR(0, 3364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__168);
  __Pyx_GIVEREF(__pyx_tuple__168);

  /* "cupy/core/core.pyx":3387
 *     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__169 = PyTuple_Pack(1, __pyx_kp_s_Output_array_has_an_invalid_size); if (unlikely(!__pyx_tuple__169)) __PYX_ERR(0, 3387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__169);
  __Pyx_GIVEREF(__pyx_tuple__169);

  /* "cupy/core/core.pyx":3389
 *             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__170 = PyTuple_Pack(1, __pyx_kp_s_Output_array_must_be_C_contiguou); if (unlikely(!__pyx_tuple__170)) __PYX_ERR(0, 3389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__170);
  __Pyx_GIVEREF(__pyx_tuple__170);

  /* "cupy/core/core.pyx":3399
 *     idx = numpy.array([start_adr])
 *     for sh_, st_ in zip(shape, strides):
 *         idx = (idx[:, None] + (numpy.arange(sh_) * st_)[None, :]).ravel()             # <<<<<<<<<<<<<<
 *     idx = idx.astype(numpy.uintp)
 * 
 */
  __pyx_slice__171 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__171)) __PYX_ERR(0, 3399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__171);
  __Pyx_GIVEREF(__pyx_slice__171);
  __pyx_tuple__172 = PyTuple_Pack(2, __pyx_slice__171, Py_None); if (unlikely(!__pyx_tuple__172)) __PYX_ERR(0, 3399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__172);
  __Pyx_GIVEREF(__pyx_tuple__172);
  __pyx_slice__173 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__173)) __PYX_ERR(0, 3399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__173);
  __Pyx_GIVEREF(__pyx_slice__173);
  __pyx_tuple__174 = PyTuple_Pack(2, Py_None, __pyx_slice__173); if (unlikely(!__pyx_tuple__174)) __PYX_ERR(0, 3399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__174);
  __Pyx_GIVEREF(__pyx_tuple__174);

  /* "cupy/core/core.pyx":3423
 *     cdef ndarray ret
 *     if a.ndim <= 2:
 *         ret = ndarray((1,), dtype=numpy.uintp)             # <<<<<<<<<<<<<<
 *         ret.fill(a.data.ptr)
 *         return ret
 */
  __pyx_tuple__175 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__175)) __PYX_ERR(0, 3423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__175);
  __Pyx_GIVEREF(__pyx_tuple__175);
  __pyx_tuple__176 = PyTuple_Pack(1, __pyx_tuple__175); if (unlikely(!__pyx_tuple__176)) __PYX_ERR(0, 3423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__176);
  __Pyx_GIVEREF(__pyx_tuple__176);

  /* "cupy/core/core.pyx":3427
 *         return ret
 *     else:
 *         return _get_all_addresses(a.data.ptr, a.shape[:-2], a.strides[:-2])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_slice__177 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__177)) __PYX_ERR(0, 3427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__177);
  __Pyx_GIVEREF(__pyx_slice__177);
  __pyx_slice__178 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__178)) __PYX_ERR(0, 3427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__178);
  __Pyx_GIVEREF(__pyx_slice__178);

  /* "cupy/core/core.pyx":3462
 *     # ToDo: remove python object .reshape
 *     if out is not None:
 *         raise NotImplementedError('The out array as input is currently not '             # <<<<<<<<<<<<<<
 *                                   'supported')
 * 
 */
  __pyx_tuple__179 = PyTuple_Pack(1, __pyx_kp_s_The_out_array_as_input_is_curren); if (unlikely(!__pyx_tuple__179)) __PYX_ERR(0, 3462, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__179);
  __Pyx_GIVEREF(__pyx_tuple__179);

  /* "cupy/core/core.pyx":3472
 *     orig_b_shape = b.shape
 *     if len(orig_a_shape) == 0 or len(orig_b_shape) == 0:
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')             # <<<<<<<<<<<<<<
 * 
 *     ret_dtype = numpy.result_type(a.dtype, b.dtype)
 */
  __pyx_tuple__180 = PyTuple_Pack(1, __pyx_kp_s_Scalar_operands_are_not_allowed); if (unlikely(!__pyx_tuple__180)) __PYX_ERR(0, 3472, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__180);
  __Pyx_GIVEREF(__pyx_tuple__180);

  /* "cupy/core/core.pyx":3490
 *         ldout = 1
 *     else:
 *         b_part_outshape = b.shape[-1:]             # <<<<<<<<<<<<<<
 *         ldout = b.shape[-1]
 * 
 */
  __pyx_slice__181 = PySlice_New(__pyx_int_neg_1, Py_None, Py_None); if (unlikely(!__pyx_slice__181)) __PYX_ERR(0, 3490, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__181);
  __Pyx_GIVEREF(__pyx_slice__181);

  /* "cupy/core/core.pyx":3497
 *         view = a.view()
 *         view._set_shape_and_strides(
 *             (1,) * (b.ndim - a.ndim) + a.shape,             # <<<<<<<<<<<<<<
 *             (0,) * (b.ndim - a.ndim) + a.strides)
 *         a = view
 */
  __pyx_tuple__182 = PyTuple_New(1); if (unlikely(!__pyx_tuple__182)) __PYX_ERR(0, 3497, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__182);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__182, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__182);

  /* "cupy/core/core.pyx":3498
 *         view._set_shape_and_strides(
 *             (1,) * (b.ndim - a.ndim) + a.shape,
 *             (0,) * (b.ndim - a.ndim) + a.strides)             # <<<<<<<<<<<<<<
 *         a = view
 *     elif a.ndim > b.ndim:
 */
  __pyx_tuple__183 = PyTuple_New(1); if (unlikely(!__pyx_tuple__183)) __PYX_ERR(0, 3498, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__183);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_tuple__183, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_tuple__183);

  /* "cupy/core/core.pyx":3503
 *         view = b.view()
 *         view._set_shape_and_strides(
 *             (1,) * (a.ndim - b.ndim) + b.shape,             # <<<<<<<<<<<<<<
 *             (0,) * (a.ndim - b.ndim) + b.strides)
 *         b = view
 */
  __pyx_tuple__184 = PyTuple_New(1); if (unlikely(!__pyx_tuple__184)) __PYX_ERR(0, 3503, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__184);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__184, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__184);

  /* "cupy/core/core.pyx":3504
 *         view._set_shape_and_strides(
 *             (1,) * (a.ndim - b.ndim) + b.shape,
 *             (0,) * (a.ndim - b.ndim) + b.strides)             # <<<<<<<<<<<<<<
 *         b = view
 * 
 */
  __pyx_tuple__185 = PyTuple_New(1); if (unlikely(!__pyx_tuple__185)) __PYX_ERR(0, 3504, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__185);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_tuple__185, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_tuple__185);

  /* "cupy/core/core.pyx":3507
 *         b = view
 * 
 *     broatcast_pre_shape = numpy.maximum(a.shape[:-2], b.shape[:-2])             # <<<<<<<<<<<<<<
 * 
 *     out_shape = (*broatcast_pre_shape, *a_part_outshape, *b_part_outshape)
 */
  __pyx_slice__186 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__186)) __PYX_ERR(0, 3507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__186);
  __Pyx_GIVEREF(__pyx_slice__186);
  __pyx_slice__187 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__187)) __PYX_ERR(0, 3507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__187);
  __Pyx_GIVEREF(__pyx_slice__187);

  /* "cupy/core/core.pyx":3542
 *     out_view_strides = out.strides
 *     if a_part_outshape == ():
 *         out_view_shape += (1,)             # <<<<<<<<<<<<<<
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():
 */
  __pyx_tuple__188 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__188)) __PYX_ERR(0, 3542, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__188);
  __Pyx_GIVEREF(__pyx_tuple__188);

  /* "cupy/core/core.pyx":3543
 *     if a_part_outshape == ():
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)             # <<<<<<<<<<<<<<
 *     if b_part_outshape == ():
 *         out_view_shape += (1,)
 */
  __pyx_tuple__189 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__189)) __PYX_ERR(0, 3543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__189);
  __Pyx_GIVEREF(__pyx_tuple__189);

  /* "cupy/core/core.pyx":3545
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():
 *         out_view_shape += (1,)             # <<<<<<<<<<<<<<
 *         out_view_strides += (0,)
 * 
 */
  __pyx_tuple__190 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__190)) __PYX_ERR(0, 3545, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__190);
  __Pyx_GIVEREF(__pyx_tuple__190);

  /* "cupy/core/core.pyx":3546
 *     if b_part_outshape == ():
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)             # <<<<<<<<<<<<<<
 * 
 *     out_view._set_shape_and_strides(out_view_shape, out_view_strides)
 */
  __pyx_tuple__191 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__191)) __PYX_ERR(0, 3546, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__191);
  __Pyx_GIVEREF(__pyx_tuple__191);

  /* "cupy/core/core.pyx":3566
 *     for la_, lb_ in zip(la, lb):
 *         if not (la_ == lb_ or la_ == 1 or lb_ == 1):
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'operands could not be broadcast together with '
 *                 'remapped shapes')
 */
  __pyx_tuple__192 = PyTuple_Pack(1, __pyx_kp_s_operands_could_not_be_broadcast); if (unlikely(!__pyx_tuple__192)) __PYX_ERR(0, 3566, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__192);
  __Pyx_GIVEREF(__pyx_tuple__192);

  /* "cupy/core/core.pyx":3679
 * 
 *     if m == 1 and n == 1:
 *         _tensordot_core_mul_sum(a.ravel(), b.ravel(), out.reshape(()))             # <<<<<<<<<<<<<<
 *         if out is not ret:
 *             elementwise_copy(out, ret)
 */
  __pyx_tuple__193 = PyTuple_Pack(1, __pyx_empty_tuple); if (unlikely(!__pyx_tuple__193)) __PYX_ERR(0, 3679, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__193);
  __Pyx_GIVEREF(__pyx_tuple__193);

  /* "cupy/core/core.pyx":3783
 * 
 *     if require_sortable_dtype:
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',             # <<<<<<<<<<<<<<
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 *     else:
 */
  __pyx_tuple__194 = PyTuple_Pack(14, __pyx_kp_s__128, __pyx_kp_s_bb, __pyx_kp_s_BB, __pyx_kp_s_hh, __pyx_kp_s_HH, __pyx_kp_s_ii, __pyx_kp_s_II, __pyx_kp_s_ll, __pyx_kp_s_LL, __pyx_kp_s_qq, __pyx_kp_s_QQ, __pyx_kp_s_ee, __pyx_kp_s_ff, __pyx_kp_s_dd); if (unlikely(!__pyx_tuple__194)) __PYX_ERR(0, 3783, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__194);
  __Pyx_GIVEREF(__pyx_tuple__194);

  /* "cupy/core/core.pyx":3786
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 *     else:
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',             # <<<<<<<<<<<<<<
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'FF->?',
 *                'dd->?', 'DD->?')
 */
  __pyx_tuple__195 = PyTuple_Pack(16, __pyx_kp_s__128, __pyx_kp_s_bb, __pyx_kp_s_BB, __pyx_kp_s_hh, __pyx_kp_s_HH, __pyx_kp_s_ii, __pyx_kp_s_II, __pyx_kp_s_ll, __pyx_kp_s_LL, __pyx_kp_s_qq, __pyx_kp_s_QQ, __pyx_kp_s_ee, __pyx_kp_s_ff, __pyx_kp_s_FF, __pyx_kp_s_dd, __pyx_kp_s_DD); if (unlikely(!__pyx_tuple__195)) __PYX_ERR(0, 3786, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__195);
  __Pyx_GIVEREF(__pyx_tuple__195);

  /* "cupy/core/core.pyx":4204
 *     name = "inclusive_scan_kernel"
 *     dtype = _get_typename(dtype)
 *     source = string.Template("""             # <<<<<<<<<<<<<<
 *     extern "C" __global__ void ${name}(const CArray<${dtype}, 1> src,
 *         CArray<${dtype}, 1> dst){
 */
  __pyx_tuple__196 = PyTuple_Pack(1, __pyx_kp_s_extern_C___global___void_name_c); if (unlikely(!__pyx_tuple__196)) __PYX_ERR(0, 4204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__196);
  __Pyx_GIVEREF(__pyx_tuple__196);

  /* "cupy/core/core.pyx":4251
 *     name = "add_scan_blocked_sum_kernel"
 *     dtype = _get_typename(dtype)
 *     source = string.Template("""             # <<<<<<<<<<<<<<
 *     extern "C" __global__ void ${name}(CArray<${dtype}, 1> src_dst){
 *         long long n = src_dst.size();
 */
  __pyx_tuple__197 = PyTuple_Pack(1, __pyx_kp_s_extern_C___global___void_name_C); if (unlikely(!__pyx_tuple__197)) __PYX_ERR(0, 4251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__197);
  __Pyx_GIVEREF(__pyx_tuple__197);

  /* "cupy/core/core.pyx":4273
 *     index_dtype = _get_typename(index_dtype)
 * 
 *     source = string.Template("""             # <<<<<<<<<<<<<<
 *     extern "C" __global__ void ${name}(const CArray<${src_dtype}, 1> src,
 *         const CArray<${index_dtype}, 1> scaned_index,
 */
  __pyx_tuple__198 = PyTuple_Pack(1, __pyx_kp_s_extern_C___global___void_name_c_2); if (unlikely(!__pyx_tuple__198)) __PYX_ERR(0, 4273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__198);
  __Pyx_GIVEREF(__pyx_tuple__198);

  /* "cupy/core/core.pyx":4297
 *     dst_dtype = _get_typename(dst_dtype)
 * 
 *     source = string.Template("""             # <<<<<<<<<<<<<<
 *         extern "C" __global__ void ${name}(const CArray<${src_dtype}, 1> src,
 *             CIndexer<${src_ndim}> shape,
 */
  __pyx_tuple__199 = PyTuple_Pack(1, __pyx_kp_s_extern_C___global___void_name_c_3); if (unlikely(!__pyx_tuple__199)) __PYX_ERR(0, 4297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__199);
  __Pyx_GIVEREF(__pyx_tuple__199);

  /* "cupy/core/core.pyx":4338
 *     """
 *     if a.ndim != 1:
 *         raise TypeError("Input array should be 1D array.")             # <<<<<<<<<<<<<<
 * 
 *     block_size = 256
 */
  __pyx_tuple__200 = PyTuple_Pack(1, __pyx_kp_s_Input_array_should_be_1D_array); if (unlikely(!__pyx_tuple__200)) __PYX_ERR(0, 4338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__200);
  __Pyx_GIVEREF(__pyx_tuple__200);

  /* "cupy/core/core.pyx":4346
 *     else:
 *         if a.size != out.size:
 *             raise ValueError("Provided out is the wrong size")             # <<<<<<<<<<<<<<
 * 
 *     kern_scan = _inclusive_scan_kernel(a.dtype, block_size)
 */
  __pyx_tuple__201 = PyTuple_Pack(1, __pyx_kp_s_Provided_out_is_the_wrong_size); if (unlikely(!__pyx_tuple__201)) __PYX_ERR(0, 4346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__201);
  __Pyx_GIVEREF(__pyx_tuple__201);

  /* "View.MemoryView":131
 * 
 *         if not self.ndim:
 *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
 * 
 *         if itemsize <= 0:
 */
  __pyx_tuple__202 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__202)) __PYX_ERR(4, 131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__202);
  __Pyx_GIVEREF(__pyx_tuple__202);

  /* "View.MemoryView":134
 * 
 *         if itemsize <= 0:
 *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
 * 
 *         if not isinstance(format, bytes):
 */
  __pyx_tuple__203 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__203)) __PYX_ERR(4, 134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__203);
  __Pyx_GIVEREF(__pyx_tuple__203);

  /* "View.MemoryView":137
 * 
 *         if not isinstance(format, bytes):
 *             format = format.encode('ASCII')             # <<<<<<<<<<<<<<
 *         self._format = format  # keep a reference to the byte string
 *         self.format = self._format
 */
  __pyx_tuple__204 = PyTuple_Pack(1, __pyx_n_s_ASCII); if (unlikely(!__pyx_tuple__204)) __PYX_ERR(4, 137, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__204);
  __Pyx_GIVEREF(__pyx_tuple__204);

  /* "View.MemoryView":146
 * 
 *         if not self._shape:
 *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__205 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__205)) __PYX_ERR(4, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__205);
  __Pyx_GIVEREF(__pyx_tuple__205);

  /* "View.MemoryView":174
 *             self.data = <char *>malloc(self.len)
 *             if not self.data:
 *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
 * 
 *             if self.dtype_is_object:
 */
  __pyx_tuple__206 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__206)) __PYX_ERR(4, 174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__206);
  __Pyx_GIVEREF(__pyx_tuple__206);

  /* "View.MemoryView":190
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         if not (flags & bufmode):
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")             # <<<<<<<<<<<<<<
 *         info.buf = self.data
 *         info.len = self.len
 */
  __pyx_tuple__207 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__207)) __PYX_ERR(4, 190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__207);
  __Pyx_GIVEREF(__pyx_tuple__207);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__208 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__208)) __PYX_ERR(4, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__208);
  __Pyx_GIVEREF(__pyx_tuple__208);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__209 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__209)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__209);
  __Pyx_GIVEREF(__pyx_tuple__209);

  /* "View.MemoryView":486
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:
 *             raise ValueError("Unable to convert item to object")             # <<<<<<<<<<<<<<
 *         else:
 *             if len(self.view.format) == 1:
 */
  __pyx_tuple__210 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__210)) __PYX_ERR(4, 486, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__210);
  __Pyx_GIVEREF(__pyx_tuple__210);

  /* "View.MemoryView":558
 *         if self.view.strides == NULL:
 * 
 *             raise ValueError("Buffer view does not expose strides")             # <<<<<<<<<<<<<<
 * 
 *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])
 */
  __pyx_tuple__211 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__211)) __PYX_ERR(4, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__211);
  __Pyx_GIVEREF(__pyx_tuple__211);

  /* "View.MemoryView":565
 *     def suboffsets(self):
 *         if self.view.suboffsets == NULL:
 *             return (-1,) * self.view.ndim             # <<<<<<<<<<<<<<
 * 
 *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
 */
  __pyx_tuple__212 = PyTuple_New(1); if (unlikely(!__pyx_tuple__212)) __PYX_ERR(4, 565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__212);
  __Pyx_INCREF(__pyx_int_neg_1);
  __Pyx_GIVEREF(__pyx_int_neg_1);
  PyTuple_SET_ITEM(__pyx_tuple__212, 0, __pyx_int_neg_1);
  __Pyx_GIVEREF(__pyx_tuple__212);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__213 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__213)) __PYX_ERR(4, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__213);
  __Pyx_GIVEREF(__pyx_tuple__213);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__214 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__214)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__214);
  __Pyx_GIVEREF(__pyx_tuple__214);

  /* "View.MemoryView":670
 *         if item is Ellipsis:
 *             if not seen_ellipsis:
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
 *                 seen_ellipsis = True
 *             else:
 */
  __pyx_slice__215 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__215)) __PYX_ERR(4, 670, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__215);
  __Pyx_GIVEREF(__pyx_slice__215);

  /* "View.MemoryView":673
 *                 seen_ellipsis = True
 *             else:
 *                 result.append(slice(None))             # <<<<<<<<<<<<<<
 *             have_slices = True
 *         else:
 */
  __pyx_slice__216 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__216)) __PYX_ERR(4, 673, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__216);
  __Pyx_GIVEREF(__pyx_slice__216);

  /* "View.MemoryView":684
 *     nslices = ndim - len(result)
 *     if nslices:
 *         result.extend([slice(None)] * nslices)             # <<<<<<<<<<<<<<
 * 
 *     return have_slices or nslices, tuple(result)
 */
  __pyx_slice__217 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__217)) __PYX_ERR(4, 684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__217);
  __Pyx_GIVEREF(__pyx_slice__217);

  /* "View.MemoryView":691
 *     for suboffset in suboffsets[:ndim]:
 *         if suboffset >= 0:
 *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__218 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__218)) __PYX_ERR(4, 691, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__218);
  __Pyx_GIVEREF(__pyx_tuple__218);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__219 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__219)) __PYX_ERR(4, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__219);
  __Pyx_GIVEREF(__pyx_tuple__219);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__220 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__220)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__220);
  __Pyx_GIVEREF(__pyx_tuple__220);

  /* "cupy/core/core.pyx":46
 *     class IndexOrValueError(IndexError, ValueError):
 * 
 *         def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *             super(IndexOrValueError, self).__init__(*args, **kwargs)
 * 
 */
  __pyx_tuple__221 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_args, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__221)) __PYX_ERR(0, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__221);
  __Pyx_GIVEREF(__pyx_tuple__221);
  __pyx_codeobj__222 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__221, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_core_pyx, __pyx_n_s_init, 46, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__222)) __PYX_ERR(0, 46, __pyx_L1_error)

  /* "cupy/core/core.pyx":1652
 *         return int(self.get())
 * 
 *     if sys.version_info < (3,):             # <<<<<<<<<<<<<<
 *         def __long__(self):
 *             # Avoid using long() for flake8
 */
  __pyx_tuple__223 = PyTuple_Pack(1, __pyx_int_3); if (unlikely(!__pyx_tuple__223)) __PYX_ERR(0, 1652, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__223);
  __Pyx_GIVEREF(__pyx_tuple__223);

  /* "cupy/core/elementwise.pxi":38
 * 
 * cdef dict _typenames_base = {
 *     numpy.dtype('float64'): 'double',             # <<<<<<<<<<<<<<
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',
 */
  __pyx_tuple__224 = PyTuple_Pack(1, __pyx_n_s_float64); if (unlikely(!__pyx_tuple__224)) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__224);
  __Pyx_GIVEREF(__pyx_tuple__224);

  /* "cupy/core/elementwise.pxi":39
 * cdef dict _typenames_base = {
 *     numpy.dtype('float64'): 'double',
 *     numpy.dtype('float32'): 'float',             # <<<<<<<<<<<<<<
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('complex128'): 'complex<double>',
 */
  __pyx_tuple__225 = PyTuple_Pack(1, __pyx_n_s_float32); if (unlikely(!__pyx_tuple__225)) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__225);
  __Pyx_GIVEREF(__pyx_tuple__225);

  /* "cupy/core/elementwise.pxi":40
 *     numpy.dtype('float64'): 'double',
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',             # <<<<<<<<<<<<<<
 *     numpy.dtype('complex128'): 'complex<double>',
 *     numpy.dtype('complex64'): 'complex<float>',
 */
  __pyx_tuple__226 = PyTuple_Pack(1, __pyx_n_s_float16); if (unlikely(!__pyx_tuple__226)) __PYX_ERR(1, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__226);
  __Pyx_GIVEREF(__pyx_tuple__226);

  /* "cupy/core/elementwise.pxi":41
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('complex128'): 'complex<double>',             # <<<<<<<<<<<<<<
 *     numpy.dtype('complex64'): 'complex<float>',
 *     numpy.dtype('int64'): 'long long',
 */
  __pyx_tuple__227 = PyTuple_Pack(1, __pyx_n_s_complex128); if (unlikely(!__pyx_tuple__227)) __PYX_ERR(1, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__227);
  __Pyx_GIVEREF(__pyx_tuple__227);

  /* "cupy/core/elementwise.pxi":42
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('complex128'): 'complex<double>',
 *     numpy.dtype('complex64'): 'complex<float>',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',
 */
  __pyx_tuple__228 = PyTuple_Pack(1, __pyx_n_s_complex64); if (unlikely(!__pyx_tuple__228)) __PYX_ERR(1, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__228);
  __Pyx_GIVEREF(__pyx_tuple__228);

  /* "cupy/core/elementwise.pxi":43
 *     numpy.dtype('complex128'): 'complex<double>',
 *     numpy.dtype('complex64'): 'complex<float>',
 *     numpy.dtype('int64'): 'long long',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int32'): 'int',
 *     numpy.dtype('int16'): 'short',
 */
  __pyx_tuple__229 = PyTuple_Pack(1, __pyx_n_s_int64); if (unlikely(!__pyx_tuple__229)) __PYX_ERR(1, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__229);
  __Pyx_GIVEREF(__pyx_tuple__229);

  /* "cupy/core/elementwise.pxi":44
 *     numpy.dtype('complex64'): 'complex<float>',
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int16'): 'short',
 *     numpy.dtype('int8'): 'signed char',
 */
  __pyx_tuple__230 = PyTuple_Pack(1, __pyx_n_s_int32); if (unlikely(!__pyx_tuple__230)) __PYX_ERR(1, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__230);
  __Pyx_GIVEREF(__pyx_tuple__230);

  /* "cupy/core/elementwise.pxi":45
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',
 *     numpy.dtype('int16'): 'short',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int8'): 'signed char',
 *     numpy.dtype('uint64'): 'unsigned long long',
 */
  __pyx_tuple__231 = PyTuple_Pack(1, __pyx_n_s_int16); if (unlikely(!__pyx_tuple__231)) __PYX_ERR(1, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__231);
  __Pyx_GIVEREF(__pyx_tuple__231);

  /* "cupy/core/elementwise.pxi":46
 *     numpy.dtype('int32'): 'int',
 *     numpy.dtype('int16'): 'short',
 *     numpy.dtype('int8'): 'signed char',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint64'): 'unsigned long long',
 *     numpy.dtype('uint32'): 'unsigned int',
 */
  __pyx_tuple__232 = PyTuple_Pack(1, __pyx_n_s_int8); if (unlikely(!__pyx_tuple__232)) __PYX_ERR(1, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__232);
  __Pyx_GIVEREF(__pyx_tuple__232);

  /* "cupy/core/elementwise.pxi":47
 *     numpy.dtype('int16'): 'short',
 *     numpy.dtype('int8'): 'signed char',
 *     numpy.dtype('uint64'): 'unsigned long long',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint32'): 'unsigned int',
 *     numpy.dtype('uint16'): 'unsigned short',
 */
  __pyx_tuple__233 = PyTuple_Pack(1, __pyx_n_s_uint64); if (unlikely(!__pyx_tuple__233)) __PYX_ERR(1, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__233);
  __Pyx_GIVEREF(__pyx_tuple__233);

  /* "cupy/core/elementwise.pxi":48
 *     numpy.dtype('int8'): 'signed char',
 *     numpy.dtype('uint64'): 'unsigned long long',
 *     numpy.dtype('uint32'): 'unsigned int',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',
 */
  __pyx_tuple__234 = PyTuple_Pack(1, __pyx_n_s_uint32); if (unlikely(!__pyx_tuple__234)) __PYX_ERR(1, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__234);
  __Pyx_GIVEREF(__pyx_tuple__234);

  /* "cupy/core/elementwise.pxi":49
 *     numpy.dtype('uint64'): 'unsigned long long',
 *     numpy.dtype('uint32'): 'unsigned int',
 *     numpy.dtype('uint16'): 'unsigned short',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint8'): 'unsigned char',
 *     numpy.dtype('bool'): 'bool',
 */
  __pyx_tuple__235 = PyTuple_Pack(1, __pyx_n_s_uint16); if (unlikely(!__pyx_tuple__235)) __PYX_ERR(1, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__235);
  __Pyx_GIVEREF(__pyx_tuple__235);

  /* "cupy/core/elementwise.pxi":50
 *     numpy.dtype('uint32'): 'unsigned int',
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',             # <<<<<<<<<<<<<<
 *     numpy.dtype('bool'): 'bool',
 * }
 */
  __pyx_tuple__236 = PyTuple_Pack(1, __pyx_n_s_uint8); if (unlikely(!__pyx_tuple__236)) __PYX_ERR(1, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__236);
  __Pyx_GIVEREF(__pyx_tuple__236);

  /* "cupy/core/elementwise.pxi":51
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',
 *     numpy.dtype('bool'): 'bool',             # <<<<<<<<<<<<<<
 * }
 * 
 */
  __pyx_tuple__237 = PyTuple_Pack(1, __pyx_n_s_bool_2); if (unlikely(!__pyx_tuple__237)) __PYX_ERR(1, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__237);
  __Pyx_GIVEREF(__pyx_tuple__237);

  /* "cupy/core/elementwise.pxi":290
 * 
 * @util.memoize()
 * def _get_param_info(s, is_const):             # <<<<<<<<<<<<<<
 *     if len(s) == 0:
 *         return ()
 */
  __pyx_tuple__238 = PyTuple_Pack(3, __pyx_n_s_s_2, __pyx_n_s_is_const, __pyx_n_s_i); if (unlikely(!__pyx_tuple__238)) __PYX_ERR(1, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__238);
  __Pyx_GIVEREF(__pyx_tuple__238);
  __pyx_codeobj__239 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__238, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_elementwise_pxi, __pyx_n_s_get_param_info, 290, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__239)) __PYX_ERR(1, 290, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":297
 * 
 * @util.memoize()
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):             # <<<<<<<<<<<<<<
 *     type_dict = {}
 *     if out_args_dtype:
 */
  __pyx_tuple__240 = PyTuple_Pack(11, __pyx_n_s_in_params, __pyx_n_s_out_params, __pyx_n_s_in_args_dtype, __pyx_n_s_out_args_dtype, __pyx_n_s_type_dict, __pyx_n_s_p, __pyx_n_s_a, __pyx_n_s_t, __pyx_n_s_unknown_ctype, __pyx_n_s_in_types, __pyx_n_s_out_types); if (unlikely(!__pyx_tuple__240)) __PYX_ERR(1, 297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__240);
  __Pyx_GIVEREF(__pyx_tuple__240);
  __pyx_codeobj__241 = (PyObject*)__Pyx_PyCode_New(4, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__240, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_elementwise_pxi, __pyx_n_s_decide_params_type, 297, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__241)) __PYX_ERR(1, 297, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":423
 * 
 * @util.memoize(for_each_device=True)
 * def _get_elementwise_kernel(args_info, types, params, operation, name,             # <<<<<<<<<<<<<<
 *                             preamble, kwargs):
 *     kernel_params = _get_kernel_params(params, args_info)
 */
  __pyx_tuple__242 = PyTuple_Pack(15, __pyx_n_s_args_info, __pyx_n_s_types, __pyx_n_s_params, __pyx_n_s_operation, __pyx_n_s_name, __pyx_n_s_preamble, __pyx_n_s_kwargs, __pyx_n_s_kernel_params, __pyx_n_s_types_preamble, __pyx_n_s_op, __pyx_n_s_p, __pyx_n_s_a, __pyx_n_s_fmt, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__242)) __PYX_ERR(1, 423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__242);
  __Pyx_GIVEREF(__pyx_tuple__242);
  __pyx_codeobj__243 = (PyObject*)__Pyx_PyCode_New(7, 0, 15, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__242, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_elementwise_pxi, __pyx_n_s_get_elementwise_kernel, 423, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__243)) __PYX_ERR(1, 423, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":598
 * 
 * @util.memoize(for_each_device=True)
 * def _get_ufunc_kernel(             # <<<<<<<<<<<<<<
 *         in_types, out_types, routine, args_info, params, name, preamble):
 *     kernel_params = _get_kernel_params(params, args_info)
 */
  __pyx_tuple__244 = PyTuple_Pack(13, __pyx_n_s_in_types, __pyx_n_s_out_types, __pyx_n_s_routine, __pyx_n_s_args_info, __pyx_n_s_params, __pyx_n_s_name, __pyx_n_s_preamble, __pyx_n_s_kernel_params, __pyx_n_s_types, __pyx_n_s_op, __pyx_n_s_i, __pyx_n_s_x, __pyx_n_s_operation); if (unlikely(!__pyx_tuple__244)) __PYX_ERR(1, 598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__244);
  __Pyx_GIVEREF(__pyx_tuple__244);
  __pyx_codeobj__245 = (PyObject*)__Pyx_PyCode_New(7, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__244, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_elementwise_pxi, __pyx_n_s_get_ufunc_kernel, 598, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__245)) __PYX_ERR(1, 598, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":711
 *     """
 * 
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                  default_casting=None):
 *         self.name = name
 */
  __pyx_tuple__246 = PyTuple_Pack(13, __pyx_n_s_self, __pyx_n_s_name, __pyx_n_s_nin, __pyx_n_s_nout, __pyx_n_s_ops, __pyx_n_s_preamble, __pyx_n_s_doc, __pyx_n_s_default_casting, __pyx_n_s_in_params_2, __pyx_n_s_out_params_2, __pyx_n_s_genexpr, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__246)) __PYX_ERR(1, 711, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__246);
  __Pyx_GIVEREF(__pyx_tuple__246);
  __pyx_codeobj__247 = (PyObject*)__Pyx_PyCode_New(8, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__246, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_elementwise_pxi, __pyx_n_s_init, 711, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__247)) __PYX_ERR(1, 711, __pyx_L1_error)
  __pyx_tuple__248 = PyTuple_Pack(3, ((PyObject*)__pyx_kp_s__5), ((PyObject*)__pyx_kp_s__5), ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__248)) __PYX_ERR(1, 711, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__248);
  __Pyx_GIVEREF(__pyx_tuple__248);

  /* "cupy/core/elementwise.pxi":734
 *         self._routine_cache = {}
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<ufunc '%s'>" % self.name
 * 
 */
  __pyx_tuple__249 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__249)) __PYX_ERR(1, 734, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__249);
  __Pyx_GIVEREF(__pyx_tuple__249);
  __pyx_codeobj__250 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__249, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_elementwise_pxi, __pyx_n_s_repr, 734, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__250)) __PYX_ERR(1, 734, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":738
 * 
 *     @property
 *     def types(self):             # <<<<<<<<<<<<<<
 *         """A list of type signatures.
 * 
 */
  __pyx_tuple__252 = PyTuple_Pack(8, __pyx_n_s_self, __pyx_n_s_types, __pyx_n_s_in_types, __pyx_n_s_out_types, __pyx_n_s__251, __pyx_n_s_in_str, __pyx_n_s_out_str, __pyx_n_s_t); if (unlikely(!__pyx_tuple__252)) __PYX_ERR(1, 738, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__252);
  __Pyx_GIVEREF(__pyx_tuple__252);
  __pyx_codeobj__253 = (PyObject*)__Pyx_PyCode_New(1, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__252, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_elementwise_pxi, __pyx_n_s_types, 738, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__253)) __PYX_ERR(1, 738, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":752
 *         return types
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Applies the universal function to arguments elementwise.
 * 
 */
  __pyx_tuple__254 = PyTuple_Pack(22, __pyx_n_s_self, __pyx_n_s_args, __pyx_n_s_kwargs, __pyx_n_s_kern, __pyx_n_s_out, __pyx_n_s_dtype, __pyx_n_s_casting, __pyx_n_s_n_args, __pyx_n_s_in_args, __pyx_n_s_out_args, __pyx_n_s_broad, __pyx_n_s_shape, __pyx_n_s_in_types, __pyx_n_s_out_types, __pyx_n_s_routine, __pyx_n_s_ret, __pyx_n_s_inout_args, __pyx_n_s_i, __pyx_n_s_t, __pyx_n_s_x, __pyx_n_s_indexer, __pyx_n_s_args_info); if (unlikely(!__pyx_tuple__254)) __PYX_ERR(1, 752, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__254);
  __Pyx_GIVEREF(__pyx_tuple__254);
  __pyx_codeobj__255 = (PyObject*)__Pyx_PyCode_New(1, 0, 22, 0, CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__254, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_elementwise_pxi, __pyx_n_s_call, 752, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__255)) __PYX_ERR(1, 752, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":166
 * 
 * @util.memoize(for_each_device=True)
 * def _get_simple_reduction_function(             # <<<<<<<<<<<<<<
 *         routine, params, args_info, in_arg_dtype, out_arg_dtype, out_types,
 *         name, block_size, identity, input_expr, output_expr, _preamble,
 */
  __pyx_tuple__256 = PyTuple_Pack(16, __pyx_n_s_routine, __pyx_n_s_params, __pyx_n_s_args_info, __pyx_n_s_in_arg_dtype, __pyx_n_s_out_arg_dtype, __pyx_n_s_out_types, __pyx_n_s_name, __pyx_n_s_block_size, __pyx_n_s_identity, __pyx_n_s_input_expr, __pyx_n_s_output_expr, __pyx_n_s_preamble_2, __pyx_n_s_options, __pyx_n_s_reduce_type, __pyx_n_s_t, __pyx_n_s_type_preamble); if (unlikely(!__pyx_tuple__256)) __PYX_ERR(5, 166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__256);
  __Pyx_GIVEREF(__pyx_tuple__256);
  __pyx_codeobj__257 = (PyObject*)__Pyx_PyCode_New(13, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__256, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_reduction_pxi, __pyx_n_s_get_simple_reduction_function, 166, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__257)) __PYX_ERR(5, 166, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":188
 *     _block_size = 512
 * 
 *     def __init__(self, name, ops, identity, preamble):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self._ops = ops
 */
  __pyx_tuple__258 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_name, __pyx_n_s_ops, __pyx_n_s_identity, __pyx_n_s_preamble, __pyx_n_s_in_params, __pyx_n_s_out_params); if (unlikely(!__pyx_tuple__258)) __PYX_ERR(5, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__258);
  __Pyx_GIVEREF(__pyx_tuple__258);
  __pyx_codeobj__259 = (PyObject*)__Pyx_PyCode_New(5, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__258, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_reduction_pxi, __pyx_n_s_init, 188, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__259)) __PYX_ERR(5, 188, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":206
 *         self._routine_cache = {}
 * 
 *     def __call__(self, ndarray a, axis=None, dtype=None, ndarray out=None,             # <<<<<<<<<<<<<<
 *                  bint keepdims=False):
 *         cdef list in_args, out_args
 */
  __pyx_tuple__260 = PyTuple_Pack(26, __pyx_n_s_self, __pyx_n_s_a, __pyx_n_s_axis, __pyx_n_s_dtype, __pyx_n_s_out, __pyx_n_s_keepdims, __pyx_n_s_in_args, __pyx_n_s_out_args, __pyx_n_s_in_sahpe, __pyx_n_s_laxis, __pyx_n_s_raxis, __pyx_n_s_a_shape, __pyx_n_s_in_types, __pyx_n_s_out_types, __pyx_n_s_routine, __pyx_n_s_out_shape, __pyx_n_s_in_shape, __pyx_n_s_block_size, __pyx_n_s_in_indexer, __pyx_n_s_out_indexer, __pyx_n_s_clp2_count, __pyx_n_s_block_stride, __pyx_n_s_inout_args, __pyx_n_s_args_info, __pyx_n_s_kern, __pyx_n_s_shared_mem); if (unlikely(!__pyx_tuple__260)) __PYX_ERR(5, 206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__260);
  __Pyx_GIVEREF(__pyx_tuple__260);
  __pyx_codeobj__261 = (PyObject*)__Pyx_PyCode_New(6, 0, 26, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__260, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_reduction_pxi, __pyx_n_s_call, 206, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__261)) __PYX_ERR(5, 206, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":273
 * 
 * @util.memoize(for_each_device=True)
 * def _get_reduction_kernel(             # <<<<<<<<<<<<<<
 *         params, args_info, types,
 *         name, block_size, reduce_type, identity, map_expr, reduce_expr,
 */
  __pyx_tuple__262 = PyTuple_Pack(21, __pyx_n_s_params, __pyx_n_s_args_info, __pyx_n_s_types, __pyx_n_s_name, __pyx_n_s_block_size, __pyx_n_s_reduce_type, __pyx_n_s_identity, __pyx_n_s_map_expr, __pyx_n_s_reduce_expr, __pyx_n_s_post_map_expr, __pyx_n_s_preamble, __pyx_n_s_options, __pyx_n_s_kernel_params, __pyx_n_s_arrays, __pyx_n_s_type_preamble, __pyx_n_s_input_expr, __pyx_n_s_output_expr, __pyx_n_s_p, __pyx_n_s_a, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__262)) __PYX_ERR(5, 273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__262);
  __Pyx_GIVEREF(__pyx_tuple__262);
  __pyx_codeobj__263 = (PyObject*)__Pyx_PyCode_New(12, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__262, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_reduction_pxi, __pyx_n_s_get_reduction_kernel, 273, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__263)) __PYX_ERR(5, 273, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":327
 * 
 *     """
 *     def __init__(self, in_params, out_params,             # <<<<<<<<<<<<<<
 *                  map_expr, reduce_expr, post_map_expr,
 *                  identity, name='reduce_kernel', reduce_type=None,
 */
  __pyx_tuple__264 = PyTuple_Pack(12, __pyx_n_s_self, __pyx_n_s_in_params, __pyx_n_s_out_params, __pyx_n_s_map_expr, __pyx_n_s_reduce_expr, __pyx_n_s_post_map_expr, __pyx_n_s_identity, __pyx_n_s_name, __pyx_n_s_reduce_type, __pyx_n_s_reduce_dims, __pyx_n_s_preamble, __pyx_n_s_options); if (unlikely(!__pyx_tuple__264)) __PYX_ERR(5, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__264);
  __Pyx_GIVEREF(__pyx_tuple__264);
  __pyx_codeobj__265 = (PyObject*)__Pyx_PyCode_New(12, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__264, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_reduction_pxi, __pyx_n_s_init, 327, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__265)) __PYX_ERR(5, 327, __pyx_L1_error)
  __pyx_tuple__266 = PyTuple_Pack(5, ((PyObject*)__pyx_n_s_reduce_kernel), ((PyObject *)Py_None), ((PyObject *)Py_True), ((PyObject*)__pyx_kp_s__5), ((PyObject*)__pyx_empty_tuple)); if (unlikely(!__pyx_tuple__266)) __PYX_ERR(5, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__266);
  __Pyx_GIVEREF(__pyx_tuple__266);

  /* "cupy/core/reduction.pxi":357
 *         self.preamble = preamble
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Compiles and invokes the reduction kernel.
 * 
 */
  __pyx_tuple__267 = PyTuple_Pack(31, __pyx_n_s_self, __pyx_n_s_args, __pyx_n_s_kwargs, __pyx_n_s_out, __pyx_n_s_axis, __pyx_n_s_keepdims, __pyx_n_s_stream, __pyx_n_s_n_args, __pyx_n_s_out_args, __pyx_n_s_in_args, __pyx_n_s_broad_shape, __pyx_n_s_in_ndarray_types, __pyx_n_s_out_ndarray_types, __pyx_n_s_in_types, __pyx_n_s_out_types, __pyx_n_s_types, __pyx_n_s_raxis, __pyx_n_s_out_shape, __pyx_n_s_in_shape, __pyx_n_s_block_size, __pyx_n_s_in_indexer, __pyx_n_s_out_indexer, __pyx_n_s_clp2_count, __pyx_n_s_block_stride, __pyx_n_s_inout_args, __pyx_n_s_args_info, __pyx_n_s_kern, __pyx_n_s_shared_mem, __pyx_n_s_a, __pyx_n_s_x, __pyx_n_s_t); if (unlikely(!__pyx_tuple__267)) __PYX_ERR(5, 357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__267);
  __Pyx_GIVEREF(__pyx_tuple__267);
  __pyx_codeobj__268 = (PyObject*)__Pyx_PyCode_New(1, 0, 31, 0, CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__267, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_reduction_pxi, __pyx_n_s_call, 357, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__268)) __PYX_ERR(5, 357, __pyx_L1_error)

  /* "cupy/core/core.pyx":1886
 * elementwise_copy = create_ufunc(
 *     'cupy_copy',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d', 'F->F', 'D->D'),
 *     'out0 = out0_type(in0)', default_casting='unsafe')
 */
  __pyx_tuple__270 = PyTuple_Pack(16, __pyx_kp_s__269, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_kp_s_F_F, __pyx_kp_s_D_D); if (unlikely(!__pyx_tuple__270)) __PYX_ERR(0, 1886, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__270);
  __Pyx_GIVEREF(__pyx_tuple__270);

  /* "cupy/core/core.pyx":1884
 * cdef _id = 'out0 = in0'
 * 
 * elementwise_copy = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_copy',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_tuple__271 = PyTuple_Pack(3, __pyx_n_s_cupy_copy, __pyx_tuple__270, __pyx_kp_s_out0_out0_type_in0); if (unlikely(!__pyx_tuple__271)) __PYX_ERR(0, 1884, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__271);
  __Pyx_GIVEREF(__pyx_tuple__271);

  /* "cupy/core/core.pyx":1893
 * elementwise_copy_where = create_ufunc(
 *     'cupy_copy_where',
 *     ('??->?', 'b?->b', 'B?->B', 'h?->h', 'H?->H', 'i?->i', 'I?->I', 'l?->l',             # <<<<<<<<<<<<<<
 *      'L?->L', 'q?->q', 'Q?->Q', 'e?->e', 'f?->f', 'd?->d', 'F?->F', 'D?->D'),
 *     'if (in1) out0 = in0', default_casting='unsafe')
 */
  __pyx_tuple__272 = PyTuple_Pack(16, __pyx_kp_s__128, __pyx_kp_s_b_b_2, __pyx_kp_s_B_B_2, __pyx_kp_s_h_h_2, __pyx_kp_s_H_H_2, __pyx_kp_s_i_i_2, __pyx_kp_s_I_I_2, __pyx_kp_s_l_l_2, __pyx_kp_s_L_L_2, __pyx_kp_s_q_q_2, __pyx_kp_s_Q_Q_2, __pyx_kp_s_e_e_2, __pyx_kp_s_f_f_2, __pyx_kp_s_d_d_2, __pyx_kp_s_F_F_2, __pyx_kp_s_D_D_2); if (unlikely(!__pyx_tuple__272)) __PYX_ERR(0, 1893, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__272);
  __Pyx_GIVEREF(__pyx_tuple__272);

  /* "cupy/core/core.pyx":1891
 * # complex numbers requires out0 = complex<T>(in0)
 * 
 * elementwise_copy_where = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_copy_where',
 *     ('??->?', 'b?->b', 'B?->B', 'h?->h', 'H?->H', 'i?->i', 'I?->I', 'l?->l',
 */
  __pyx_tuple__273 = PyTuple_Pack(3, __pyx_n_s_cupy_copy_where, __pyx_tuple__272, __pyx_kp_s_if_in1_out0_in0); if (unlikely(!__pyx_tuple__273)) __PYX_ERR(0, 1891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__273);
  __Pyx_GIVEREF(__pyx_tuple__273);

  /* "cupy/core/core.pyx":2019
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, 'my_min_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('f->f', (None, 'my_min_float(a, b)', None, None)),
 *      ('d->d', (None, 'my_min_float(a, b)', None, None))),
 */
  __pyx_tuple__274 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_min_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__274)) __PYX_ERR(0, 2019, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__274);
  __Pyx_GIVEREF(__pyx_tuple__274);
  __pyx_tuple__275 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__274); if (unlikely(!__pyx_tuple__275)) __PYX_ERR(0, 2019, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__275);
  __Pyx_GIVEREF(__pyx_tuple__275);

  /* "cupy/core/core.pyx":2020
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, 'my_min_float(a, b)', None, None)),
 *      ('f->f', (None, 'my_min_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('d->d', (None, 'my_min_float(a, b)', None, None))),
 *     ('min_max_st<type_in0_raw>(in0)', 'my_min(a, b)', 'out0 = a.value',
 */
  __pyx_tuple__276 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_min_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__276)) __PYX_ERR(0, 2020, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__276);
  __Pyx_GIVEREF(__pyx_tuple__276);
  __pyx_tuple__277 = PyTuple_Pack(2, __pyx_kp_s_f_f, __pyx_tuple__276); if (unlikely(!__pyx_tuple__277)) __PYX_ERR(0, 2020, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__277);
  __Pyx_GIVEREF(__pyx_tuple__277);

  /* "cupy/core/core.pyx":2021
 *      ('e->e', (None, 'my_min_float(a, b)', None, None)),
 *      ('f->f', (None, 'my_min_float(a, b)', None, None)),
 *      ('d->d', (None, 'my_min_float(a, b)', None, None))),             # <<<<<<<<<<<<<<
 *     ('min_max_st<type_in0_raw>(in0)', 'my_min(a, b)', 'out0 = a.value',
 *      'min_max_st<type_in0_raw>'),
 */
  __pyx_tuple__278 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_min_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__278)) __PYX_ERR(0, 2021, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__278);
  __Pyx_GIVEREF(__pyx_tuple__278);
  __pyx_tuple__279 = PyTuple_Pack(2, __pyx_kp_s_d_d, __pyx_tuple__278); if (unlikely(!__pyx_tuple__279)) __PYX_ERR(0, 2021, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__279);
  __Pyx_GIVEREF(__pyx_tuple__279);

  /* "cupy/core/core.pyx":2017
 * _amin = create_reduction_func(
 *     'cupy_min',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, 'my_min_float(a, b)', None, None)),
 */
  __pyx_tuple__280 = PyTuple_Pack(14, __pyx_kp_s__269, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_tuple__275, __pyx_tuple__277, __pyx_tuple__279); if (unlikely(!__pyx_tuple__280)) __PYX_ERR(0, 2017, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__280);
  __Pyx_GIVEREF(__pyx_tuple__280);

  /* "cupy/core/core.pyx":2022
 *      ('f->f', (None, 'my_min_float(a, b)', None, None)),
 *      ('d->d', (None, 'my_min_float(a, b)', None, None))),
 *     ('min_max_st<type_in0_raw>(in0)', 'my_min(a, b)', 'out0 = a.value',             # <<<<<<<<<<<<<<
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)
 */
  __pyx_tuple__281 = PyTuple_Pack(4, __pyx_kp_s_min_max_st_type_in0_raw_in0, __pyx_kp_s_my_min_a_b, __pyx_kp_s_out0_a_value, __pyx_kp_s_min_max_st_type_in0_raw); if (unlikely(!__pyx_tuple__281)) __PYX_ERR(0, 2022, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__281);
  __Pyx_GIVEREF(__pyx_tuple__281);

  /* "cupy/core/core.pyx":2031
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, 'my_max_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('f->f', (None, 'my_max_float(a, b)', None, None)),
 *      ('d->d', (None, 'my_max_float(a, b)', None, None))),
 */
  __pyx_tuple__282 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_max_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__282)) __PYX_ERR(0, 2031, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__282);
  __Pyx_GIVEREF(__pyx_tuple__282);
  __pyx_tuple__283 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__282); if (unlikely(!__pyx_tuple__283)) __PYX_ERR(0, 2031, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__283);
  __Pyx_GIVEREF(__pyx_tuple__283);

  /* "cupy/core/core.pyx":2032
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, 'my_max_float(a, b)', None, None)),
 *      ('f->f', (None, 'my_max_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('d->d', (None, 'my_max_float(a, b)', None, None))),
 *     ('min_max_st<type_in0_raw>(in0)', 'my_max(a, b)', 'out0 = a.value',
 */
  __pyx_tuple__284 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_max_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__284)) __PYX_ERR(0, 2032, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__284);
  __Pyx_GIVEREF(__pyx_tuple__284);
  __pyx_tuple__285 = PyTuple_Pack(2, __pyx_kp_s_f_f, __pyx_tuple__284); if (unlikely(!__pyx_tuple__285)) __PYX_ERR(0, 2032, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__285);
  __Pyx_GIVEREF(__pyx_tuple__285);

  /* "cupy/core/core.pyx":2033
 *      ('e->e', (None, 'my_max_float(a, b)', None, None)),
 *      ('f->f', (None, 'my_max_float(a, b)', None, None)),
 *      ('d->d', (None, 'my_max_float(a, b)', None, None))),             # <<<<<<<<<<<<<<
 *     ('min_max_st<type_in0_raw>(in0)', 'my_max(a, b)', 'out0 = a.value',
 *      'min_max_st<type_in0_raw>'),
 */
  __pyx_tuple__286 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_max_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__286)) __PYX_ERR(0, 2033, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__286);
  __Pyx_GIVEREF(__pyx_tuple__286);
  __pyx_tuple__287 = PyTuple_Pack(2, __pyx_kp_s_d_d, __pyx_tuple__286); if (unlikely(!__pyx_tuple__287)) __PYX_ERR(0, 2033, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__287);
  __Pyx_GIVEREF(__pyx_tuple__287);

  /* "cupy/core/core.pyx":2029
 * _amax = create_reduction_func(
 *     'cupy_max',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, 'my_max_float(a, b)', None, None)),
 */
  __pyx_tuple__288 = PyTuple_Pack(14, __pyx_kp_s__269, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_tuple__283, __pyx_tuple__285, __pyx_tuple__287); if (unlikely(!__pyx_tuple__288)) __PYX_ERR(0, 2029, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__288);
  __Pyx_GIVEREF(__pyx_tuple__288);

  /* "cupy/core/core.pyx":2034
 *      ('f->f', (None, 'my_max_float(a, b)', None, None)),
 *      ('d->d', (None, 'my_max_float(a, b)', None, None))),
 *     ('min_max_st<type_in0_raw>(in0)', 'my_max(a, b)', 'out0 = a.value',             # <<<<<<<<<<<<<<
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)
 */
  __pyx_tuple__289 = PyTuple_Pack(4, __pyx_kp_s_min_max_st_type_in0_raw_in0, __pyx_kp_s_my_max_a_b, __pyx_kp_s_out0_a_value, __pyx_kp_s_min_max_st_type_in0_raw); if (unlikely(!__pyx_tuple__289)) __PYX_ERR(0, 2034, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__289);
  __Pyx_GIVEREF(__pyx_tuple__289);

  /* "cupy/core/core.pyx":2041
 * nanmin = create_reduction_func(
 *     'cupy_nanmin',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d'),
 *     ('min_max_st<type_in0_raw>(in0)', 'my_min(a, b)', 'out0 = a.value',
 */
  __pyx_tuple__290 = PyTuple_Pack(14, __pyx_kp_s__269, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d); if (unlikely(!__pyx_tuple__290)) __PYX_ERR(0, 2041, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__290);
  __Pyx_GIVEREF(__pyx_tuple__290);

  /* "cupy/core/core.pyx":2043
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d'),
 *     ('min_max_st<type_in0_raw>(in0)', 'my_min(a, b)', 'out0 = a.value',             # <<<<<<<<<<<<<<
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)
 */
  __pyx_tuple__291 = PyTuple_Pack(4, __pyx_kp_s_min_max_st_type_in0_raw_in0, __pyx_kp_s_my_min_a_b, __pyx_kp_s_out0_a_value, __pyx_kp_s_min_max_st_type_in0_raw); if (unlikely(!__pyx_tuple__291)) __PYX_ERR(0, 2043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__291);
  __Pyx_GIVEREF(__pyx_tuple__291);

  /* "cupy/core/core.pyx":2050
 * nanmax = create_reduction_func(
 *     'cupy_nanmax',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d'),
 *     ('min_max_st<type_in0_raw>(in0)', 'my_max(a, b)', 'out0 = a.value',
 */
  __pyx_tuple__292 = PyTuple_Pack(14, __pyx_kp_s__269, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d); if (unlikely(!__pyx_tuple__292)) __PYX_ERR(0, 2050, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__292);
  __Pyx_GIVEREF(__pyx_tuple__292);

  /* "cupy/core/core.pyx":2052
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d'),
 *     ('min_max_st<type_in0_raw>(in0)', 'my_max(a, b)', 'out0 = a.value',             # <<<<<<<<<<<<<<
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)
 */
  __pyx_tuple__293 = PyTuple_Pack(4, __pyx_kp_s_min_max_st_type_in0_raw_in0, __pyx_kp_s_my_max_a_b, __pyx_kp_s_out0_a_value, __pyx_kp_s_min_max_st_type_in0_raw); if (unlikely(!__pyx_tuple__293)) __PYX_ERR(0, 2052, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__293);
  __Pyx_GIVEREF(__pyx_tuple__293);

  /* "cupy/core/core.pyx":2061
 *     ('?->q', 'B->q', 'h->q', 'H->q', 'i->q', 'I->q', 'l->q', 'L->q',
 *      'q->q', 'Q->q',
 *      ('e->q', (None, 'my_argmin_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('f->q', (None, 'my_argmin_float(a, b)', None, None)),
 *      ('d->q', (None, 'my_argmin_float(a, b)', None, None))),
 */
  __pyx_tuple__294 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmin_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__294)) __PYX_ERR(0, 2061, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__294);
  __Pyx_GIVEREF(__pyx_tuple__294);
  __pyx_tuple__295 = PyTuple_Pack(2, __pyx_kp_s_e_q, __pyx_tuple__294); if (unlikely(!__pyx_tuple__295)) __PYX_ERR(0, 2061, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__295);
  __Pyx_GIVEREF(__pyx_tuple__295);

  /* "cupy/core/core.pyx":2062
 *      'q->q', 'Q->q',
 *      ('e->q', (None, 'my_argmin_float(a, b)', None, None)),
 *      ('f->q', (None, 'my_argmin_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('d->q', (None, 'my_argmin_float(a, b)', None, None))),
 *     ('min_max_st<type_in0_raw>(in0, _J)', 'my_argmin(a, b)', 'out0 = a.index',
 */
  __pyx_tuple__296 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmin_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__296)) __PYX_ERR(0, 2062, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__296);
  __Pyx_GIVEREF(__pyx_tuple__296);
  __pyx_tuple__297 = PyTuple_Pack(2, __pyx_kp_s_f_q, __pyx_tuple__296); if (unlikely(!__pyx_tuple__297)) __PYX_ERR(0, 2062, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__297);
  __Pyx_GIVEREF(__pyx_tuple__297);

  /* "cupy/core/core.pyx":2063
 *      ('e->q', (None, 'my_argmin_float(a, b)', None, None)),
 *      ('f->q', (None, 'my_argmin_float(a, b)', None, None)),
 *      ('d->q', (None, 'my_argmin_float(a, b)', None, None))),             # <<<<<<<<<<<<<<
 *     ('min_max_st<type_in0_raw>(in0, _J)', 'my_argmin(a, b)', 'out0 = a.index',
 *      'min_max_st<type_in0_raw>'),
 */
  __pyx_tuple__298 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmin_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__298)) __PYX_ERR(0, 2063, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__298);
  __Pyx_GIVEREF(__pyx_tuple__298);
  __pyx_tuple__299 = PyTuple_Pack(2, __pyx_kp_s_d_q, __pyx_tuple__298); if (unlikely(!__pyx_tuple__299)) __PYX_ERR(0, 2063, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__299);
  __Pyx_GIVEREF(__pyx_tuple__299);

  /* "cupy/core/core.pyx":2059
 * cdef _argmin = create_reduction_func(
 *     'cupy_argmin',
 *     ('?->q', 'B->q', 'h->q', 'H->q', 'i->q', 'I->q', 'l->q', 'L->q',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->q',
 *      ('e->q', (None, 'my_argmin_float(a, b)', None, None)),
 */
  __pyx_tuple__300 = PyTuple_Pack(13, __pyx_kp_s_q, __pyx_kp_s_B_q, __pyx_kp_s_h_q, __pyx_kp_s_H_q, __pyx_kp_s_i_q, __pyx_kp_s_I_q, __pyx_kp_s_l_q, __pyx_kp_s_L_q, __pyx_kp_s_q_q, __pyx_kp_s_Q_q, __pyx_tuple__295, __pyx_tuple__297, __pyx_tuple__299); if (unlikely(!__pyx_tuple__300)) __PYX_ERR(0, 2059, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__300);
  __Pyx_GIVEREF(__pyx_tuple__300);

  /* "cupy/core/core.pyx":2064
 *      ('f->q', (None, 'my_argmin_float(a, b)', None, None)),
 *      ('d->q', (None, 'my_argmin_float(a, b)', None, None))),
 *     ('min_max_st<type_in0_raw>(in0, _J)', 'my_argmin(a, b)', 'out0 = a.index',             # <<<<<<<<<<<<<<
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)
 */
  __pyx_tuple__301 = PyTuple_Pack(4, __pyx_kp_s_min_max_st_type_in0_raw_in0__J, __pyx_kp_s_my_argmin_a_b, __pyx_kp_s_out0_a_index, __pyx_kp_s_min_max_st_type_in0_raw); if (unlikely(!__pyx_tuple__301)) __PYX_ERR(0, 2064, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__301);
  __Pyx_GIVEREF(__pyx_tuple__301);

  /* "cupy/core/core.pyx":2073
 *     ('?->q', 'B->q', 'h->q', 'H->q', 'i->q', 'I->q', 'l->q', 'L->q',
 *      'q->q', 'Q->q',
 *      ('e->q', (None, 'my_argmax_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('f->q', (None, 'my_argmax_float(a, b)', None, None)),
 *      ('d->q', (None, 'my_argmax_float(a, b)', None, None))),
 */
  __pyx_tuple__302 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmax_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__302)) __PYX_ERR(0, 2073, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__302);
  __Pyx_GIVEREF(__pyx_tuple__302);
  __pyx_tuple__303 = PyTuple_Pack(2, __pyx_kp_s_e_q, __pyx_tuple__302); if (unlikely(!__pyx_tuple__303)) __PYX_ERR(0, 2073, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__303);
  __Pyx_GIVEREF(__pyx_tuple__303);

  /* "cupy/core/core.pyx":2074
 *      'q->q', 'Q->q',
 *      ('e->q', (None, 'my_argmax_float(a, b)', None, None)),
 *      ('f->q', (None, 'my_argmax_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('d->q', (None, 'my_argmax_float(a, b)', None, None))),
 *     ('min_max_st<type_in0_raw>(in0, _J)', 'my_argmax(a, b)', 'out0 = a.index',
 */
  __pyx_tuple__304 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmax_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__304)) __PYX_ERR(0, 2074, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__304);
  __Pyx_GIVEREF(__pyx_tuple__304);
  __pyx_tuple__305 = PyTuple_Pack(2, __pyx_kp_s_f_q, __pyx_tuple__304); if (unlikely(!__pyx_tuple__305)) __PYX_ERR(0, 2074, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__305);
  __Pyx_GIVEREF(__pyx_tuple__305);

  /* "cupy/core/core.pyx":2075
 *      ('e->q', (None, 'my_argmax_float(a, b)', None, None)),
 *      ('f->q', (None, 'my_argmax_float(a, b)', None, None)),
 *      ('d->q', (None, 'my_argmax_float(a, b)', None, None))),             # <<<<<<<<<<<<<<
 *     ('min_max_st<type_in0_raw>(in0, _J)', 'my_argmax(a, b)', 'out0 = a.index',
 *      'min_max_st<type_in0_raw>'),
 */
  __pyx_tuple__306 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmax_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__306)) __PYX_ERR(0, 2075, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__306);
  __Pyx_GIVEREF(__pyx_tuple__306);
  __pyx_tuple__307 = PyTuple_Pack(2, __pyx_kp_s_d_q, __pyx_tuple__306); if (unlikely(!__pyx_tuple__307)) __PYX_ERR(0, 2075, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__307);
  __Pyx_GIVEREF(__pyx_tuple__307);

  /* "cupy/core/core.pyx":2071
 * cdef _argmax = create_reduction_func(
 *     'cupy_argmax',
 *     ('?->q', 'B->q', 'h->q', 'H->q', 'i->q', 'I->q', 'l->q', 'L->q',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->q',
 *      ('e->q', (None, 'my_argmax_float(a, b)', None, None)),
 */
  __pyx_tuple__308 = PyTuple_Pack(13, __pyx_kp_s_q, __pyx_kp_s_B_q, __pyx_kp_s_h_q, __pyx_kp_s_H_q, __pyx_kp_s_i_q, __pyx_kp_s_I_q, __pyx_kp_s_l_q, __pyx_kp_s_L_q, __pyx_kp_s_q_q, __pyx_kp_s_Q_q, __pyx_tuple__303, __pyx_tuple__305, __pyx_tuple__307); if (unlikely(!__pyx_tuple__308)) __PYX_ERR(0, 2071, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__308);
  __Pyx_GIVEREF(__pyx_tuple__308);

  /* "cupy/core/core.pyx":2076
 *      ('f->q', (None, 'my_argmax_float(a, b)', None, None)),
 *      ('d->q', (None, 'my_argmax_float(a, b)', None, None))),
 *     ('min_max_st<type_in0_raw>(in0, _J)', 'my_argmax(a, b)', 'out0 = a.index',             # <<<<<<<<<<<<<<
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)
 */
  __pyx_tuple__309 = PyTuple_Pack(4, __pyx_kp_s_min_max_st_type_in0_raw_in0__J, __pyx_kp_s_my_argmax_a_b, __pyx_kp_s_out0_a_index, __pyx_kp_s_min_max_st_type_in0_raw); if (unlikely(!__pyx_tuple__309)) __PYX_ERR(0, 2076, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__309);
  __Pyx_GIVEREF(__pyx_tuple__309);

  /* "cupy/core/core.pyx":2188
 * # -----------------------------------------------------------------------------
 * 
 * def _has_element(vector.vector[Py_ssize_t] source, Py_ssize_t n):             # <<<<<<<<<<<<<<
 *     for elem in source:
 *         if elem == n:
 */
  __pyx_tuple__310 = PyTuple_Pack(3, __pyx_n_s_source, __pyx_n_s_n, __pyx_n_s_elem); if (unlikely(!__pyx_tuple__310)) __PYX_ERR(0, 2188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__310);
  __Pyx_GIVEREF(__pyx_tuple__310);
  __pyx_codeobj__311 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__310, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_core_pyx, __pyx_n_s_has_element, 2188, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__311)) __PYX_ERR(0, 2188, __pyx_L1_error)

  /* "cupy/core/core.pyx":2258
 * 
 * 
 * def array_split(ndarray ary, indices_or_sections, Py_ssize_t axis):             # <<<<<<<<<<<<<<
 * 
 *     cdef Py_ssize_t i, ndim, size, each_size, index, prev, offset, stride
 */
  __pyx_tuple__312 = PyTuple_Pack(15, __pyx_n_s_ary, __pyx_n_s_indices_or_sections, __pyx_n_s_axis, __pyx_n_s_i, __pyx_n_s_ndim, __pyx_n_s_size, __pyx_n_s_each_size, __pyx_n_s_index, __pyx_n_s_prev, __pyx_n_s_offset, __pyx_n_s_stride, __pyx_n_s_shape, __pyx_n_s_indices, __pyx_n_s_ret, __pyx_n_s_v); if (unlikely(!__pyx_tuple__312)) __PYX_ERR(0, 2258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__312);
  __Pyx_GIVEREF(__pyx_tuple__312);
  __pyx_codeobj__313 = (PyObject*)__Pyx_PyCode_New(3, 0, 15, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__312, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_core_pyx, __pyx_n_s_array_split, 2258, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__313)) __PYX_ERR(0, 2258, __pyx_L1_error)

  /* "cupy/core/core.pyx":2604
 *     return ret
 * 
 * cdef _concatenate_kernel_one = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw P x, int32 base',
 *     'T y',
 */
  __pyx_tuple__314 = PyTuple_Pack(4, __pyx_kp_s_raw_P_x_int32_base, __pyx_kp_s_T_y, __pyx_kp_s_int_middle_i_base_int_top_middl, __pyx_n_s_cupy_concatenate_one); if (unlikely(!__pyx_tuple__314)) __PYX_ERR(0, 2604, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__314);
  __Pyx_GIVEREF(__pyx_tuple__314);

  /* "cupy/core/core.pyx":2618
 * 
 * 
 * cdef _concatenate_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     '''raw P x, int32 axis, raw int32 cum_sizes,
 *     raw int32 x_strides''',
 */
  __pyx_tuple__315 = PyTuple_Pack(4, __pyx_kp_s_raw_P_x_int32_axis_raw_int32_cum, __pyx_kp_s_T_y, __pyx_kp_s_int_axis_ind__ind_get_axis_int, __pyx_n_s_cupy_concatenate); if (unlikely(!__pyx_tuple__315)) __PYX_ERR(0, 2618, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__315);
  __Pyx_GIVEREF(__pyx_tuple__315);

  /* "cupy/core/core.pyx":2730
 * 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__319 = PyTuple_Pack(2, __pyx_kp_s__269, __pyx_kp_s_out0_in0_2); if (unlikely(!__pyx_tuple__319)) __PYX_ERR(0, 2730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__319);
  __Pyx_GIVEREF(__pyx_tuple__319);
  __pyx_tuple__320 = PyTuple_Pack(11, __pyx_tuple__319, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q); if (unlikely(!__pyx_tuple__320)) __PYX_ERR(0, 2730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__320);
  __Pyx_GIVEREF(__pyx_tuple__320);

  /* "cupy/core/core.pyx":2728
 * 
 * 
 * invert = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_invert',
 *     (('?->?', 'out0 = !in0'), 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I',
 */
  __pyx_tuple__321 = PyTuple_Pack(3, __pyx_n_s_cupy_invert, __pyx_tuple__320, __pyx_kp_s_out0_in0_3); if (unlikely(!__pyx_tuple__321)) __PYX_ERR(0, 2728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__321);
  __Pyx_GIVEREF(__pyx_tuple__321);

  /* "cupy/core/core.pyx":2767
 * # -----------------------------------------------------------------------------
 * 
 * cdef _take_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T a, S indices, int32 cdim, int32 rdim, int32 adim, S index_range',
 *     'T out',
 */
  __pyx_tuple__324 = PyTuple_Pack(4, __pyx_kp_s_raw_T_a_S_indices_int32_cdim_int, __pyx_kp_s_T_out, __pyx_kp_s_S_wrap_indices_indices_index_ra, __pyx_n_s_cupy_take); if (unlikely(!__pyx_tuple__324)) __PYX_ERR(0, 2767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__324);
  __Pyx_GIVEREF(__pyx_tuple__324);

  /* "cupy/core/core.pyx":2781
 * 
 * 
 * cdef _take_kernel_0axis = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T a, S indices, int32 rdim, S index_range',
 *     'T out',
 */
  __pyx_tuple__325 = PyTuple_Pack(4, __pyx_kp_s_raw_T_a_S_indices_int32_rdim_S_i, __pyx_kp_s_T_out, __pyx_kp_s_S_wrap_indices_indices_index_ra_2, __pyx_n_s_cupy_take_0axis); if (unlikely(!__pyx_tuple__325)) __PYX_ERR(0, 2781, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__325);
  __Pyx_GIVEREF(__pyx_tuple__325);

  /* "cupy/core/core.pyx":2793
 * 
 * 
 * cdef _choose_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'S a, raw T choices, int32 n_channel',
 *     'T y',
 */
  __pyx_tuple__326 = PyTuple_Pack(4, __pyx_kp_s_S_a_raw_T_choices_int32_n_channe, __pyx_kp_s_T_y, __pyx_kp_s_y_choices_i_n_channel_a, __pyx_n_s_cupy_choose); if (unlikely(!__pyx_tuple__326)) __PYX_ERR(0, 2793, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__326);
  __Pyx_GIVEREF(__pyx_tuple__326);

  /* "cupy/core/core.pyx":2800
 * 
 * 
 * cdef _choose_clip_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'S a, raw T choices, int32 n_channel, int32 n',
 *     'T y',
 */
  __pyx_tuple__327 = PyTuple_Pack(4, __pyx_kp_s_S_a_raw_T_choices_int32_n_channe_2, __pyx_kp_s_T_y, __pyx_kp_s_S_x_a_if_a_0_x_0_else_if_a_n_x, __pyx_n_s_cupy_choose_clip); if (unlikely(!__pyx_tuple__327)) __PYX_ERR(0, 2800, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__327);
  __Pyx_GIVEREF(__pyx_tuple__327);

  /* "cupy/core/core.pyx":2815
 * 
 * 
 * cdef _scatter_update_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'T v, S indices, int32 cdim, int32 rdim, int32 adim',
 *     'raw T a',
 */
  __pyx_tuple__328 = PyTuple_Pack(4, __pyx_kp_s_T_v_S_indices_int32_cdim_int32_r, __pyx_kp_s_raw_T_a, __pyx_kp_s_S_wrap_indices_indices_adim_if, __pyx_n_s_cupy_scatter_update); if (unlikely(!__pyx_tuple__328)) __PYX_ERR(0, 2815, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__328);
  __Pyx_GIVEREF(__pyx_tuple__328);

  /* "cupy/core/core.pyx":2828
 * 
 * 
 * cdef _scatter_add_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T v, S indices, int32 cdim, int32 rdim, int32 adim',
 *     'raw T a',
 */
  __pyx_tuple__329 = PyTuple_Pack(4, __pyx_kp_s_raw_T_v_S_indices_int32_cdim_int, __pyx_kp_s_raw_T_a, __pyx_kp_s_S_wrap_indices_indices_adim_if_2, __pyx_n_s_cupy_scatter_add); if (unlikely(!__pyx_tuple__329)) __PYX_ERR(0, 2828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__329);
  __Pyx_GIVEREF(__pyx_tuple__329);

  /* "cupy/core/core.pyx":2841
 * 
 * 
 * cdef _scatter_update_mask_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T v, bool mask, S mask_scanned',
 *     'T a',
 */
  __pyx_tuple__330 = PyTuple_Pack(4, __pyx_kp_s_raw_T_v_bool_mask_S_mask_scanned, __pyx_kp_s_T_a, __pyx_kp_s_if_mask_a_v_mask_scanned_1, __pyx_n_s_cupy_scatter_update_mask); if (unlikely(!__pyx_tuple__330)) __PYX_ERR(0, 2841, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__330);
  __Pyx_GIVEREF(__pyx_tuple__330);

  /* "cupy/core/core.pyx":2848
 * 
 * 
 * cdef _scatter_add_mask_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T v, bool mask, S mask_scanned',
 *     'T a',
 */
  __pyx_tuple__331 = PyTuple_Pack(4, __pyx_kp_s_raw_T_v_bool_mask_S_mask_scanned, __pyx_kp_s_T_a, __pyx_kp_s_if_mask_a_a_v_mask_scanned_1, __pyx_n_s_cupy_scatter_add_mask); if (unlikely(!__pyx_tuple__331)) __PYX_ERR(0, 2848, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__331);
  __Pyx_GIVEREF(__pyx_tuple__331);

  /* "cupy/core/core.pyx":2855
 * 
 * 
 * cdef _getitem_mask_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'T a, bool mask, S mask_scanned',
 *     'raw T out',
 */
  __pyx_tuple__332 = PyTuple_Pack(4, __pyx_kp_s_T_a_bool_mask_S_mask_scanned, __pyx_kp_s_raw_T_out, __pyx_kp_s_if_mask_out_mask_scanned_1_a, __pyx_n_s_cupy_getitem_mask); if (unlikely(!__pyx_tuple__332)) __PYX_ERR(0, 2855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__332);
  __Pyx_GIVEREF(__pyx_tuple__332);

  /* "cupy/core/core.pyx":3626
 * 
 * cdef _cuda_runtime_version = None
 * cdef _tensordot_core_mul_sum = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T y', 'U out',
 *     'static_cast<U>(x) * static_cast<U>(y)',
 */
  __pyx_tuple__333 = PyTuple_Pack(7, __pyx_kp_s_S_x_T_y, __pyx_kp_s_U_out, __pyx_kp_s_static_cast_U_x_static_cast_U_y, __pyx_kp_s_a_b, __pyx_kp_s_out_a, __pyx_kp_s_0, __pyx_n_s_tensordot_core_mul_sum); if (unlikely(!__pyx_tuple__333)) __PYX_ERR(0, 3626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__333);
  __Pyx_GIVEREF(__pyx_tuple__333);

  /* "cupy/core/core.pyx":3852
 * _all = create_reduction_func(
 *     'cupy_all',
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',             # <<<<<<<<<<<<<<
 *      'q->?', 'Q->?', 'e->?', 'f->?', 'd->?', 'F->?', 'D->?'),
 *     ('in0 != type_in0_raw(0)', 'a & b', 'out0 = a', 'bool'),
 */
  __pyx_tuple__340 = PyTuple_Pack(15, __pyx_kp_s__269, __pyx_kp_s_B, __pyx_kp_s_h, __pyx_kp_s_H, __pyx_kp_s_i_2, __pyx_kp_s_I_2, __pyx_kp_s_l, __pyx_kp_s_L, __pyx_kp_s_q_2, __pyx_kp_s_Q, __pyx_kp_s_e_2, __pyx_kp_s_f_2, __pyx_kp_s_d_2, __pyx_kp_s_F_2, __pyx_kp_s_D_2); if (unlikely(!__pyx_tuple__340)) __PYX_ERR(0, 3852, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__340);
  __Pyx_GIVEREF(__pyx_tuple__340);

  /* "cupy/core/core.pyx":3854
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',
 *      'q->?', 'Q->?', 'e->?', 'f->?', 'd->?', 'F->?', 'D->?'),
 *     ('in0 != type_in0_raw(0)', 'a & b', 'out0 = a', 'bool'),             # <<<<<<<<<<<<<<
 *     'true', '')
 * 
 */
  __pyx_tuple__341 = PyTuple_Pack(4, __pyx_kp_s_in0_type_in0_raw_0, __pyx_kp_s_a_b_2, __pyx_kp_s_out0_a, __pyx_n_s_bool_2); if (unlikely(!__pyx_tuple__341)) __PYX_ERR(0, 3854, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__341);
  __Pyx_GIVEREF(__pyx_tuple__341);

  /* "cupy/core/core.pyx":3860
 * _any = create_reduction_func(
 *     'cupy_any',
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',             # <<<<<<<<<<<<<<
 *      'q->?', 'Q->?', 'e->?', 'f->?', 'd->?', 'F->?', 'D->?'),
 *     ('in0 != type_in0_raw(0)', 'a | b', 'out0 = a', 'bool'),
 */
  __pyx_tuple__342 = PyTuple_Pack(15, __pyx_kp_s__269, __pyx_kp_s_B, __pyx_kp_s_h, __pyx_kp_s_H, __pyx_kp_s_i_2, __pyx_kp_s_I_2, __pyx_kp_s_l, __pyx_kp_s_L, __pyx_kp_s_q_2, __pyx_kp_s_Q, __pyx_kp_s_e_2, __pyx_kp_s_f_2, __pyx_kp_s_d_2, __pyx_kp_s_F_2, __pyx_kp_s_D_2); if (unlikely(!__pyx_tuple__342)) __PYX_ERR(0, 3860, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__342);
  __Pyx_GIVEREF(__pyx_tuple__342);

  /* "cupy/core/core.pyx":3862
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',
 *      'q->?', 'Q->?', 'e->?', 'f->?', 'd->?', 'F->?', 'D->?'),
 *     ('in0 != type_in0_raw(0)', 'a | b', 'out0 = a', 'bool'),             # <<<<<<<<<<<<<<
 *     'false', '')
 * 
 */
  __pyx_tuple__343 = PyTuple_Pack(4, __pyx_kp_s_in0_type_in0_raw_0, __pyx_kp_s_a_b_3, __pyx_kp_s_out0_a, __pyx_n_s_bool_2); if (unlikely(!__pyx_tuple__343)) __PYX_ERR(0, 3862, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__343);
  __Pyx_GIVEREF(__pyx_tuple__343);

  /* "cupy/core/core.pyx":3874
 *     ('?->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L',
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, None, None, 'float')),             # <<<<<<<<<<<<<<
 *      'f->f', 'd->d', 'F->F', 'D->D'),
 *     ('in0', 'a + b', 'out0 = type_out0_raw(a)', None), 0)
 */
  __pyx_tuple__344 = PyTuple_Pack(4, Py_None, Py_None, Py_None, __pyx_n_s_float); if (unlikely(!__pyx_tuple__344)) __PYX_ERR(0, 3874, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__344);
  __Pyx_GIVEREF(__pyx_tuple__344);
  __pyx_tuple__345 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__344); if (unlikely(!__pyx_tuple__345)) __PYX_ERR(0, 3874, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__345);
  __Pyx_GIVEREF(__pyx_tuple__345);

  /* "cupy/core/core.pyx":3872
 * _sum = create_reduction_func(
 *     'cupy_sum',
 *     ('?->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, None, None, 'float')),
 */
  __pyx_tuple__346 = PyTuple_Pack(15, __pyx_kp_s_l_2, __pyx_kp_s_B_L, __pyx_kp_s_h_l, __pyx_kp_s_H_L, __pyx_kp_s_i_l, __pyx_kp_s_I_L, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_tuple__345, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_kp_s_F_F, __pyx_kp_s_D_D); if (unlikely(!__pyx_tuple__346)) __PYX_ERR(0, 3872, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__346);
  __Pyx_GIVEREF(__pyx_tuple__346);

  /* "cupy/core/core.pyx":3876
 *      ('e->e', (None, None, None, 'float')),
 *      'f->f', 'd->d', 'F->F', 'D->D'),
 *     ('in0', 'a + b', 'out0 = type_out0_raw(a)', None), 0)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__347 = PyTuple_Pack(4, __pyx_n_s_in0, __pyx_kp_s_a_b, __pyx_kp_s_out0_type_out0_raw_a, Py_None); if (unlikely(!__pyx_tuple__347)) __PYX_ERR(0, 3876, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__347);
  __Pyx_GIVEREF(__pyx_tuple__347);

  /* "cupy/core/core.pyx":3883
 *     ['?->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L',
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, None, None, 'float')),             # <<<<<<<<<<<<<<
 *      'f->f', 'd->d', 'F->F', 'D->D'],
 *     ('in0', 'a * b', 'out0 = type_out0_raw(a)', None), 1)
 */
  __pyx_tuple__348 = PyTuple_Pack(4, Py_None, Py_None, Py_None, __pyx_n_s_float); if (unlikely(!__pyx_tuple__348)) __PYX_ERR(0, 3883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__348);
  __Pyx_GIVEREF(__pyx_tuple__348);
  __pyx_tuple__349 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__348); if (unlikely(!__pyx_tuple__349)) __PYX_ERR(0, 3883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__349);
  __Pyx_GIVEREF(__pyx_tuple__349);

  /* "cupy/core/core.pyx":3885
 *      ('e->e', (None, None, None, 'float')),
 *      'f->f', 'd->d', 'F->F', 'D->D'],
 *     ('in0', 'a * b', 'out0 = type_out0_raw(a)', None), 1)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__350 = PyTuple_Pack(4, __pyx_n_s_in0, __pyx_kp_s_a_b_4, __pyx_kp_s_out0_type_out0_raw_a, Py_None); if (unlikely(!__pyx_tuple__350)) __PYX_ERR(0, 3885, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__350);
  __Pyx_GIVEREF(__pyx_tuple__350);

  /* "cupy/core/core.pyx":3912
 *     ('b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L', 'q->q',
 *      'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->F', 'out0 = conj(in0)'),             # <<<<<<<<<<<<<<
 *      ('D->D', 'out0 = conj(in0)')),
 *     'out0 = in0',
 */
  __pyx_tuple__352 = PyTuple_Pack(2, __pyx_kp_s_F_F, __pyx_kp_s_out0_conj_in0); if (unlikely(!__pyx_tuple__352)) __PYX_ERR(0, 3912, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__352);
  __Pyx_GIVEREF(__pyx_tuple__352);

  /* "cupy/core/core.pyx":3913
 *      'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->F', 'out0 = conj(in0)'),
 *      ('D->D', 'out0 = conj(in0)')),             # <<<<<<<<<<<<<<
 *     'out0 = in0',
 *     doc='''Returns the complex conjugate, element-wise.
 */
  __pyx_tuple__353 = PyTuple_Pack(2, __pyx_kp_s_D_D, __pyx_kp_s_out0_conj_in0); if (unlikely(!__pyx_tuple__353)) __PYX_ERR(0, 3913, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__353);
  __Pyx_GIVEREF(__pyx_tuple__353);

  /* "cupy/core/core.pyx":3910
 * conj = create_ufunc(
 *     'cupy_conj',
 *     ('b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L', 'q->q',             # <<<<<<<<<<<<<<
 *      'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->F', 'out0 = conj(in0)'),
 */
  __pyx_tuple__354 = PyTuple_Pack(15, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_tuple__352, __pyx_tuple__353); if (unlikely(!__pyx_tuple__354)) __PYX_ERR(0, 3910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__354);
  __Pyx_GIVEREF(__pyx_tuple__354);

  /* "cupy/core/core.pyx":3908
 * 
 * 
 * conj = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_conj',
 *     ('b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L', 'q->q',
 */
  __pyx_tuple__355 = PyTuple_Pack(3, __pyx_n_s_cupy_conj, __pyx_tuple__354, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__355)) __PYX_ERR(0, 3908, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__355);
  __Pyx_GIVEREF(__pyx_tuple__355);

  /* "cupy/core/core.pyx":3925
 *     'cupy_angle',
 *     ('?->d', 'e->e', 'f->f', 'd->d',
 *      ('F->f', 'out0 = arg(in0)'),             # <<<<<<<<<<<<<<
 *      ('D->d', 'out0 = arg(in0)')),
 *     'out0 = in0 >= 0 ? 0 : M_PI',
 */
  __pyx_tuple__356 = PyTuple_Pack(2, __pyx_kp_s_F_f, __pyx_kp_s_out0_arg_in0); if (unlikely(!__pyx_tuple__356)) __PYX_ERR(0, 3925, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__356);
  __Pyx_GIVEREF(__pyx_tuple__356);

  /* "cupy/core/core.pyx":3926
 *     ('?->d', 'e->e', 'f->f', 'd->d',
 *      ('F->f', 'out0 = arg(in0)'),
 *      ('D->d', 'out0 = arg(in0)')),             # <<<<<<<<<<<<<<
 *     'out0 = in0 >= 0 ? 0 : M_PI',
 *     doc='''Returns the angle of the complex argument.
 */
  __pyx_tuple__357 = PyTuple_Pack(2, __pyx_kp_s_D_d, __pyx_kp_s_out0_arg_in0); if (unlikely(!__pyx_tuple__357)) __PYX_ERR(0, 3926, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__357);
  __Pyx_GIVEREF(__pyx_tuple__357);

  /* "cupy/core/core.pyx":3924
 * angle = create_ufunc(
 *     'cupy_angle',
 *     ('?->d', 'e->e', 'f->f', 'd->d',             # <<<<<<<<<<<<<<
 *      ('F->f', 'out0 = arg(in0)'),
 *      ('D->d', 'out0 = arg(in0)')),
 */
  __pyx_tuple__358 = PyTuple_Pack(6, __pyx_kp_s_d_3, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_tuple__356, __pyx_tuple__357); if (unlikely(!__pyx_tuple__358)) __PYX_ERR(0, 3924, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__358);
  __Pyx_GIVEREF(__pyx_tuple__358);

  /* "cupy/core/core.pyx":3922
 * 
 * 
 * angle = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_angle',
 *     ('?->d', 'e->e', 'f->f', 'd->d',
 */
  __pyx_tuple__359 = PyTuple_Pack(3, __pyx_n_s_cupy_angle, __pyx_tuple__358, __pyx_kp_s_out0_in0_0_0_M_PI); if (unlikely(!__pyx_tuple__359)) __PYX_ERR(0, 3922, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__359);
  __Pyx_GIVEREF(__pyx_tuple__359);

  /* "cupy/core/core.pyx":3939
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->f', 'out0 = in0.real()'),             # <<<<<<<<<<<<<<
 *      ('D->d', 'out0 = in0.real()')),
 *     'out0 = in0',
 */
  __pyx_tuple__360 = PyTuple_Pack(2, __pyx_kp_s_F_f, __pyx_kp_s_out0_in0_real); if (unlikely(!__pyx_tuple__360)) __PYX_ERR(0, 3939, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__360);
  __Pyx_GIVEREF(__pyx_tuple__360);

  /* "cupy/core/core.pyx":3940
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->f', 'out0 = in0.real()'),
 *      ('D->d', 'out0 = in0.real()')),             # <<<<<<<<<<<<<<
 *     'out0 = in0',
 *     doc='''Returns the real part of the elements of the array.
 */
  __pyx_tuple__361 = PyTuple_Pack(2, __pyx_kp_s_D_d, __pyx_kp_s_out0_in0_real); if (unlikely(!__pyx_tuple__361)) __PYX_ERR(0, 3940, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__361);
  __Pyx_GIVEREF(__pyx_tuple__361);

  /* "cupy/core/core.pyx":3937
 * real = create_ufunc(
 *     'cupy_real',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->f', 'out0 = in0.real()'),
 */
  __pyx_tuple__362 = PyTuple_Pack(16, __pyx_kp_s__269, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_tuple__360, __pyx_tuple__361); if (unlikely(!__pyx_tuple__362)) __PYX_ERR(0, 3937, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__362);
  __Pyx_GIVEREF(__pyx_tuple__362);

  /* "cupy/core/core.pyx":3935
 * 
 * 
 * real = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_real',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_tuple__363 = PyTuple_Pack(3, __pyx_n_s_cupy_real, __pyx_tuple__362, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__363)) __PYX_ERR(0, 3935, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__363);
  __Pyx_GIVEREF(__pyx_tuple__363);

  /* "cupy/core/core.pyx":3951
 * _real_setter = create_ufunc(
 *     'cupy_real_setter',
 *     ('f->F', 'd->D'),             # <<<<<<<<<<<<<<
 *     'out0.real(in0)',
 *     doc='''Sets the real part of the elements of the array.
 */
  __pyx_tuple__364 = PyTuple_Pack(2, __pyx_kp_s_f_F, __pyx_kp_s_d_D); if (unlikely(!__pyx_tuple__364)) __PYX_ERR(0, 3951, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__364);
  __Pyx_GIVEREF(__pyx_tuple__364);

  /* "cupy/core/core.pyx":3949
 * 
 * 
 * _real_setter = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_real_setter',
 *     ('f->F', 'd->D'),
 */
  __pyx_tuple__365 = PyTuple_Pack(3, __pyx_n_s_cupy_real_setter, __pyx_tuple__364, __pyx_kp_s_out0_real_in0); if (unlikely(!__pyx_tuple__365)) __PYX_ERR(0, 3949, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__365);
  __Pyx_GIVEREF(__pyx_tuple__365);

  /* "cupy/core/core.pyx":3961
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->f', 'out0 = in0.imag()'),             # <<<<<<<<<<<<<<
 *      ('D->d', 'out0 = in0.imag()')),
 *     'out0 = 0',
 */
  __pyx_tuple__366 = PyTuple_Pack(2, __pyx_kp_s_F_f, __pyx_kp_s_out0_in0_imag); if (unlikely(!__pyx_tuple__366)) __PYX_ERR(0, 3961, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__366);
  __Pyx_GIVEREF(__pyx_tuple__366);

  /* "cupy/core/core.pyx":3962
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->f', 'out0 = in0.imag()'),
 *      ('D->d', 'out0 = in0.imag()')),             # <<<<<<<<<<<<<<
 *     'out0 = 0',
 *     doc='''Returns the imaginary part of the elements of the array.
 */
  __pyx_tuple__367 = PyTuple_Pack(2, __pyx_kp_s_D_d, __pyx_kp_s_out0_in0_imag); if (unlikely(!__pyx_tuple__367)) __PYX_ERR(0, 3962, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__367);
  __Pyx_GIVEREF(__pyx_tuple__367);

  /* "cupy/core/core.pyx":3959
 * imag = create_ufunc(
 *     'cupy_imag',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->f', 'out0 = in0.imag()'),
 */
  __pyx_tuple__368 = PyTuple_Pack(16, __pyx_kp_s__269, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_tuple__366, __pyx_tuple__367); if (unlikely(!__pyx_tuple__368)) __PYX_ERR(0, 3959, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__368);
  __Pyx_GIVEREF(__pyx_tuple__368);

  /* "cupy/core/core.pyx":3957
 * 
 * 
 * imag = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_imag',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_tuple__369 = PyTuple_Pack(3, __pyx_n_s_cupy_imag, __pyx_tuple__368, __pyx_kp_s_out0_0); if (unlikely(!__pyx_tuple__369)) __PYX_ERR(0, 3957, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__369);
  __Pyx_GIVEREF(__pyx_tuple__369);

  /* "cupy/core/core.pyx":3973
 * _imag_setter = create_ufunc(
 *     'cupy_imag_setter',
 *     ('f->F', 'd->D'),             # <<<<<<<<<<<<<<
 *     'out0.imag(in0)',
 *     doc='''Sets the imaginary part of the elements of the array.
 */
  __pyx_tuple__370 = PyTuple_Pack(2, __pyx_kp_s_f_F, __pyx_kp_s_d_D); if (unlikely(!__pyx_tuple__370)) __PYX_ERR(0, 3973, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__370);
  __Pyx_GIVEREF(__pyx_tuple__370);

  /* "cupy/core/core.pyx":3971
 * 
 * 
 * _imag_setter = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_imag_setter',
 *     ('f->F', 'd->D'),
 */
  __pyx_tuple__371 = PyTuple_Pack(3, __pyx_n_s_cupy_imag_setter, __pyx_tuple__370, __pyx_kp_s_out0_imag_in0); if (unlikely(!__pyx_tuple__371)) __PYX_ERR(0, 3971, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__371);
  __Pyx_GIVEREF(__pyx_tuple__371);

  /* "cupy/core/core.pyx":3981
 * negative = create_ufunc(
 *     'cupy_negative',
 *     (('?->?', 'out0 = !in0'),             # <<<<<<<<<<<<<<
 *      'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d', 'F->F', 'D->D'),
 */
  __pyx_tuple__372 = PyTuple_Pack(2, __pyx_kp_s__269, __pyx_kp_s_out0_in0_2); if (unlikely(!__pyx_tuple__372)) __PYX_ERR(0, 3981, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__372);
  __Pyx_GIVEREF(__pyx_tuple__372);
  __pyx_tuple__373 = PyTuple_Pack(16, __pyx_tuple__372, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_kp_s_F_F, __pyx_kp_s_D_D); if (unlikely(!__pyx_tuple__373)) __PYX_ERR(0, 3981, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__373);
  __Pyx_GIVEREF(__pyx_tuple__373);

  /* "cupy/core/core.pyx":3979
 * 
 * 
 * negative = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_negative',
 *     (('?->?', 'out0 = !in0'),
 */
  __pyx_tuple__374 = PyTuple_Pack(3, __pyx_n_s_cupy_negative, __pyx_tuple__373, __pyx_kp_s_out0_in0_4); if (unlikely(!__pyx_tuple__374)) __PYX_ERR(0, 3979, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__374);
  __Pyx_GIVEREF(__pyx_tuple__374);

  /* "cupy/core/core.pyx":4005
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = in0 / in1'),             # <<<<<<<<<<<<<<
 *      ('ff->f', 'out0 = in0 / in1'),
 *      ('dd->d', 'out0 = in0 / in1'),
 */
  __pyx_tuple__376 = PyTuple_Pack(2, __pyx_kp_s_ee_e, __pyx_kp_s_out0_in0_in1); if (unlikely(!__pyx_tuple__376)) __PYX_ERR(0, 4005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__376);
  __Pyx_GIVEREF(__pyx_tuple__376);

  /* "cupy/core/core.pyx":4006
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = in0 / in1'),
 *      ('ff->f', 'out0 = in0 / in1'),             # <<<<<<<<<<<<<<
 *      ('dd->d', 'out0 = in0 / in1'),
 *      ('FF->F', 'out0 = in0 / in1'),
 */
  __pyx_tuple__377 = PyTuple_Pack(2, __pyx_kp_s_ff_f, __pyx_kp_s_out0_in0_in1); if (unlikely(!__pyx_tuple__377)) __PYX_ERR(0, 4006, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__377);
  __Pyx_GIVEREF(__pyx_tuple__377);

  /* "cupy/core/core.pyx":4007
 *      ('ee->e', 'out0 = in0 / in1'),
 *      ('ff->f', 'out0 = in0 / in1'),
 *      ('dd->d', 'out0 = in0 / in1'),             # <<<<<<<<<<<<<<
 *      ('FF->F', 'out0 = in0 / in1'),
 *      ('DD->D', 'out0 = in0 / in1')),
 */
  __pyx_tuple__378 = PyTuple_Pack(2, __pyx_kp_s_dd_d, __pyx_kp_s_out0_in0_in1); if (unlikely(!__pyx_tuple__378)) __PYX_ERR(0, 4007, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__378);
  __Pyx_GIVEREF(__pyx_tuple__378);

  /* "cupy/core/core.pyx":4008
 *      ('ff->f', 'out0 = in0 / in1'),
 *      ('dd->d', 'out0 = in0 / in1'),
 *      ('FF->F', 'out0 = in0 / in1'),             # <<<<<<<<<<<<<<
 *      ('DD->D', 'out0 = in0 / in1')),
 *     'out0 = in1 == 0 ? 0 : floor((double)in0 / (double)in1)',
 */
  __pyx_tuple__379 = PyTuple_Pack(2, __pyx_kp_s_FF_F, __pyx_kp_s_out0_in0_in1); if (unlikely(!__pyx_tuple__379)) __PYX_ERR(0, 4008, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__379);
  __Pyx_GIVEREF(__pyx_tuple__379);

  /* "cupy/core/core.pyx":4009
 *      ('dd->d', 'out0 = in0 / in1'),
 *      ('FF->F', 'out0 = in0 / in1'),
 *      ('DD->D', 'out0 = in0 / in1')),             # <<<<<<<<<<<<<<
 *     'out0 = in1 == 0 ? 0 : floor((double)in0 / (double)in1)',
 *     doc='''Divides arguments elementwise.
 */
  __pyx_tuple__380 = PyTuple_Pack(2, __pyx_kp_s_DD_D, __pyx_kp_s_out0_in0_in1); if (unlikely(!__pyx_tuple__380)) __PYX_ERR(0, 4009, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__380);
  __Pyx_GIVEREF(__pyx_tuple__380);

  /* "cupy/core/core.pyx":4003
 * divide = create_ufunc(
 *     'cupy_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',             # <<<<<<<<<<<<<<
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = in0 / in1'),
 */
  __pyx_tuple__381 = PyTuple_Pack(15, __pyx_kp_s_bb_b, __pyx_kp_s_BB_B, __pyx_kp_s_hh_h, __pyx_kp_s_HH_H, __pyx_kp_s_ii_i, __pyx_kp_s_II_I, __pyx_kp_s_ll_l, __pyx_kp_s_LL_L, __pyx_kp_s_qq_q, __pyx_kp_s_QQ_Q, __pyx_tuple__376, __pyx_tuple__377, __pyx_tuple__378, __pyx_tuple__379, __pyx_tuple__380); if (unlikely(!__pyx_tuple__381)) __PYX_ERR(0, 4003, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__381);
  __Pyx_GIVEREF(__pyx_tuple__381);

  /* "cupy/core/core.pyx":4001
 * 
 * 
 * divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_tuple__382 = PyTuple_Pack(3, __pyx_n_s_cupy_divide, __pyx_tuple__381, __pyx_kp_s_out0_in1_0_0_floor_double_in0_do); if (unlikely(!__pyx_tuple__382)) __PYX_ERR(0, 4001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__382);
  __Pyx_GIVEREF(__pyx_tuple__382);

  /* "cupy/core/core.pyx":4022
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = powf(in0, in1)'),             # <<<<<<<<<<<<<<
 *      ('ff->f', 'out0 = powf(in0, in1)'),
 *      ('dd->d', 'out0 = pow(in0, in1)'),
 */
  __pyx_tuple__383 = PyTuple_Pack(2, __pyx_kp_s_ee_e, __pyx_kp_s_out0_powf_in0_in1); if (unlikely(!__pyx_tuple__383)) __PYX_ERR(0, 4022, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__383);
  __Pyx_GIVEREF(__pyx_tuple__383);

  /* "cupy/core/core.pyx":4023
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = powf(in0, in1)'),
 *      ('ff->f', 'out0 = powf(in0, in1)'),             # <<<<<<<<<<<<<<
 *      ('dd->d', 'out0 = pow(in0, in1)'),
 *      ('FF->F', 'out0 = pow(in0, in1)'),
 */
  __pyx_tuple__384 = PyTuple_Pack(2, __pyx_kp_s_ff_f, __pyx_kp_s_out0_powf_in0_in1); if (unlikely(!__pyx_tuple__384)) __PYX_ERR(0, 4023, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__384);
  __Pyx_GIVEREF(__pyx_tuple__384);

  /* "cupy/core/core.pyx":4024
 *      ('ee->e', 'out0 = powf(in0, in1)'),
 *      ('ff->f', 'out0 = powf(in0, in1)'),
 *      ('dd->d', 'out0 = pow(in0, in1)'),             # <<<<<<<<<<<<<<
 *      ('FF->F', 'out0 = pow(in0, in1)'),
 *      ('DD->D', 'out0 = pow(in0, in1)')),
 */
  __pyx_tuple__385 = PyTuple_Pack(2, __pyx_kp_s_dd_d, __pyx_kp_s_out0_pow_in0_in1); if (unlikely(!__pyx_tuple__385)) __PYX_ERR(0, 4024, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__385);
  __Pyx_GIVEREF(__pyx_tuple__385);

  /* "cupy/core/core.pyx":4025
 *      ('ff->f', 'out0 = powf(in0, in1)'),
 *      ('dd->d', 'out0 = pow(in0, in1)'),
 *      ('FF->F', 'out0 = pow(in0, in1)'),             # <<<<<<<<<<<<<<
 *      ('DD->D', 'out0 = pow(in0, in1)')),
 *     'out0 = rint(pow((double)in0, (double)in1))',
 */
  __pyx_tuple__386 = PyTuple_Pack(2, __pyx_kp_s_FF_F, __pyx_kp_s_out0_pow_in0_in1); if (unlikely(!__pyx_tuple__386)) __PYX_ERR(0, 4025, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__386);
  __Pyx_GIVEREF(__pyx_tuple__386);

  /* "cupy/core/core.pyx":4026
 *      ('dd->d', 'out0 = pow(in0, in1)'),
 *      ('FF->F', 'out0 = pow(in0, in1)'),
 *      ('DD->D', 'out0 = pow(in0, in1)')),             # <<<<<<<<<<<<<<
 *     'out0 = rint(pow((double)in0, (double)in1))',
 *     doc='''Computes ``x1 ** x2`` elementwise.
 */
  __pyx_tuple__387 = PyTuple_Pack(2, __pyx_kp_s_DD_D, __pyx_kp_s_out0_pow_in0_in1); if (unlikely(!__pyx_tuple__387)) __PYX_ERR(0, 4026, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__387);
  __Pyx_GIVEREF(__pyx_tuple__387);

  /* "cupy/core/core.pyx":4020
 * power = create_ufunc(
 *     'cupy_power',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',             # <<<<<<<<<<<<<<
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = powf(in0, in1)'),
 */
  __pyx_tuple__388 = PyTuple_Pack(15, __pyx_kp_s_bb_b, __pyx_kp_s_BB_B, __pyx_kp_s_hh_h, __pyx_kp_s_HH_H, __pyx_kp_s_ii_i, __pyx_kp_s_II_I, __pyx_kp_s_ll_l, __pyx_kp_s_LL_L, __pyx_kp_s_qq_q, __pyx_kp_s_QQ_Q, __pyx_tuple__383, __pyx_tuple__384, __pyx_tuple__385, __pyx_tuple__386, __pyx_tuple__387); if (unlikely(!__pyx_tuple__388)) __PYX_ERR(0, 4020, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__388);
  __Pyx_GIVEREF(__pyx_tuple__388);

  /* "cupy/core/core.pyx":4018
 * 
 * 
 * power = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_power',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_tuple__389 = PyTuple_Pack(3, __pyx_n_s_cupy_power, __pyx_tuple__388, __pyx_kp_s_out0_rint_pow_double_in0_double); if (unlikely(!__pyx_tuple__389)) __PYX_ERR(0, 4018, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__389);
  __Pyx_GIVEREF(__pyx_tuple__389);

  /* "cupy/core/core.pyx":4046
 * true_divide = create_ufunc(
 *     'cupy_true_divide',
 *     ('bb->d', 'BB->d', 'hh->d', 'HH->d', 'ii->d', 'II->d', 'll->d', 'LL->d',             # <<<<<<<<<<<<<<
 *      'qq->d', 'QQ->d', 'ee->e', 'ff->f', 'dd->d', 'FF->F', 'DD->D'),
 *     'out0 = (out0_type)in0 / (out0_type)in1',
 */
  __pyx_tuple__391 = PyTuple_Pack(15, __pyx_kp_s_bb_d, __pyx_kp_s_BB_d, __pyx_kp_s_hh_d, __pyx_kp_s_HH_d, __pyx_kp_s_ii_d, __pyx_kp_s_II_d, __pyx_kp_s_ll_d, __pyx_kp_s_LL_d, __pyx_kp_s_qq_d, __pyx_kp_s_QQ_d, __pyx_kp_s_ee_e, __pyx_kp_s_ff_f, __pyx_kp_s_dd_d, __pyx_kp_s_FF_F, __pyx_kp_s_DD_D); if (unlikely(!__pyx_tuple__391)) __PYX_ERR(0, 4046, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__391);
  __Pyx_GIVEREF(__pyx_tuple__391);

  /* "cupy/core/core.pyx":4044
 * 
 * 
 * true_divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_true_divide',
 *     ('bb->d', 'BB->d', 'hh->d', 'HH->d', 'ii->d', 'II->d', 'll->d', 'LL->d',
 */
  __pyx_tuple__392 = PyTuple_Pack(3, __pyx_n_s_cupy_true_divide, __pyx_tuple__391, __pyx_kp_s_out0_out0_type_in0_out0_type_in1); if (unlikely(!__pyx_tuple__392)) __PYX_ERR(0, 4044, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__392);
  __Pyx_GIVEREF(__pyx_tuple__392);

  /* "cupy/core/core.pyx":4062
 * floor_divide = create_ufunc(
 *     'cupy_floor_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',             # <<<<<<<<<<<<<<
 *      'qq->q', 'QQ->Q', 'ee->e', 'ff->f', 'dd->d'),
 *     'out0 = _floor_divide(in0, in1)',
 */
  __pyx_tuple__393 = PyTuple_Pack(13, __pyx_kp_s_bb_b, __pyx_kp_s_BB_B, __pyx_kp_s_hh_h, __pyx_kp_s_HH_H, __pyx_kp_s_ii_i, __pyx_kp_s_II_I, __pyx_kp_s_ll_l, __pyx_kp_s_LL_L, __pyx_kp_s_qq_q, __pyx_kp_s_QQ_Q, __pyx_kp_s_ee_e, __pyx_kp_s_ff_f, __pyx_kp_s_dd_d); if (unlikely(!__pyx_tuple__393)) __PYX_ERR(0, 4062, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__393);
  __Pyx_GIVEREF(__pyx_tuple__393);

  /* "cupy/core/core.pyx":4060
 * 
 * 
 * floor_divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_floor_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_tuple__394 = PyTuple_Pack(3, __pyx_n_s_cupy_floor_divide, __pyx_tuple__393, __pyx_kp_s_out0__floor_divide_in0_in1); if (unlikely(!__pyx_tuple__394)) __PYX_ERR(0, 4060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__394);
  __Pyx_GIVEREF(__pyx_tuple__394);

  /* "cupy/core/core.pyx":4076
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = in0 - _floor_divide(in0, in1) * in1'),             # <<<<<<<<<<<<<<
 *      ('ff->f', 'out0 = in0 - _floor_divide(in0, in1) * in1'),
 *      ('dd->d', 'out0 = in0 - _floor_divide(in0, in1) * in1')),
 */
  __pyx_tuple__395 = PyTuple_Pack(2, __pyx_kp_s_ee_e, __pyx_kp_s_out0_in0__floor_divide_in0_in1_i); if (unlikely(!__pyx_tuple__395)) __PYX_ERR(0, 4076, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__395);
  __Pyx_GIVEREF(__pyx_tuple__395);

  /* "cupy/core/core.pyx":4077
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = in0 - _floor_divide(in0, in1) * in1'),
 *      ('ff->f', 'out0 = in0 - _floor_divide(in0, in1) * in1'),             # <<<<<<<<<<<<<<
 *      ('dd->d', 'out0 = in0 - _floor_divide(in0, in1) * in1')),
 *     'out0 = (in0 - _floor_divide(in0, in1) * in1) * (in1 != 0)',
 */
  __pyx_tuple__396 = PyTuple_Pack(2, __pyx_kp_s_ff_f, __pyx_kp_s_out0_in0__floor_divide_in0_in1_i); if (unlikely(!__pyx_tuple__396)) __PYX_ERR(0, 4077, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__396);
  __Pyx_GIVEREF(__pyx_tuple__396);

  /* "cupy/core/core.pyx":4078
 *      ('ee->e', 'out0 = in0 - _floor_divide(in0, in1) * in1'),
 *      ('ff->f', 'out0 = in0 - _floor_divide(in0, in1) * in1'),
 *      ('dd->d', 'out0 = in0 - _floor_divide(in0, in1) * in1')),             # <<<<<<<<<<<<<<
 *     'out0 = (in0 - _floor_divide(in0, in1) * in1) * (in1 != 0)',
 *     doc='''Computes the remainder of Python division elementwise.
 */
  __pyx_tuple__397 = PyTuple_Pack(2, __pyx_kp_s_dd_d, __pyx_kp_s_out0_in0__floor_divide_in0_in1_i); if (unlikely(!__pyx_tuple__397)) __PYX_ERR(0, 4078, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__397);
  __Pyx_GIVEREF(__pyx_tuple__397);

  /* "cupy/core/core.pyx":4074
 * remainder = create_ufunc(
 *     'cupy_remainder',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',             # <<<<<<<<<<<<<<
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = in0 - _floor_divide(in0, in1) * in1'),
 */
  __pyx_tuple__398 = PyTuple_Pack(13, __pyx_kp_s_bb_b, __pyx_kp_s_BB_B, __pyx_kp_s_hh_h, __pyx_kp_s_HH_H, __pyx_kp_s_ii_i, __pyx_kp_s_II_I, __pyx_kp_s_ll_l, __pyx_kp_s_LL_L, __pyx_kp_s_qq_q, __pyx_kp_s_QQ_Q, __pyx_tuple__395, __pyx_tuple__396, __pyx_tuple__397); if (unlikely(!__pyx_tuple__398)) __PYX_ERR(0, 4074, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__398);
  __Pyx_GIVEREF(__pyx_tuple__398);

  /* "cupy/core/core.pyx":4072
 * 
 * 
 * remainder = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_remainder',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_tuple__399 = PyTuple_Pack(3, __pyx_n_s_cupy_remainder, __pyx_tuple__398, __pyx_kp_s_out0_in0__floor_divide_in0_in1_i_2); if (unlikely(!__pyx_tuple__399)) __PYX_ERR(0, 4072, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__399);
  __Pyx_GIVEREF(__pyx_tuple__399);

  /* "cupy/core/core.pyx":4089
 * absolute = create_ufunc(
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),             # <<<<<<<<<<<<<<
 *      'b->b', ('B->B', 'out0 = in0'), 'h->h', ('H->H', 'out0 = in0'),
 *      'i->i', ('I->I', 'out0 = in0'), 'l->l', ('L->L', 'out0 = in0'),
 */
  __pyx_tuple__400 = PyTuple_Pack(2, __pyx_kp_s__269, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__400)) __PYX_ERR(0, 4089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__400);
  __Pyx_GIVEREF(__pyx_tuple__400);

  /* "cupy/core/core.pyx":4090
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),
 *      'b->b', ('B->B', 'out0 = in0'), 'h->h', ('H->H', 'out0 = in0'),             # <<<<<<<<<<<<<<
 *      'i->i', ('I->I', 'out0 = in0'), 'l->l', ('L->L', 'out0 = in0'),
 *      'q->q', ('Q->Q', 'out0 = in0'),
 */
  __pyx_tuple__401 = PyTuple_Pack(2, __pyx_kp_s_B_B, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__401)) __PYX_ERR(0, 4090, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__401);
  __Pyx_GIVEREF(__pyx_tuple__401);
  __pyx_tuple__402 = PyTuple_Pack(2, __pyx_kp_s_H_H, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__402)) __PYX_ERR(0, 4090, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__402);
  __Pyx_GIVEREF(__pyx_tuple__402);

  /* "cupy/core/core.pyx":4091
 *     (('?->?', 'out0 = in0'),
 *      'b->b', ('B->B', 'out0 = in0'), 'h->h', ('H->H', 'out0 = in0'),
 *      'i->i', ('I->I', 'out0 = in0'), 'l->l', ('L->L', 'out0 = in0'),             # <<<<<<<<<<<<<<
 *      'q->q', ('Q->Q', 'out0 = in0'),
 *      ('e->e', 'out0 = fabsf(in0)'),
 */
  __pyx_tuple__403 = PyTuple_Pack(2, __pyx_kp_s_I_I, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__403)) __PYX_ERR(0, 4091, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__403);
  __Pyx_GIVEREF(__pyx_tuple__403);
  __pyx_tuple__404 = PyTuple_Pack(2, __pyx_kp_s_L_L, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__404)) __PYX_ERR(0, 4091, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__404);
  __Pyx_GIVEREF(__pyx_tuple__404);

  /* "cupy/core/core.pyx":4092
 *      'b->b', ('B->B', 'out0 = in0'), 'h->h', ('H->H', 'out0 = in0'),
 *      'i->i', ('I->I', 'out0 = in0'), 'l->l', ('L->L', 'out0 = in0'),
 *      'q->q', ('Q->Q', 'out0 = in0'),             # <<<<<<<<<<<<<<
 *      ('e->e', 'out0 = fabsf(in0)'),
 *      ('f->f', 'out0 = fabsf(in0)'),
 */
  __pyx_tuple__405 = PyTuple_Pack(2, __pyx_kp_s_Q_Q, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__405)) __PYX_ERR(0, 4092, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__405);
  __Pyx_GIVEREF(__pyx_tuple__405);

  /* "cupy/core/core.pyx":4093
 *      'i->i', ('I->I', 'out0 = in0'), 'l->l', ('L->L', 'out0 = in0'),
 *      'q->q', ('Q->Q', 'out0 = in0'),
 *      ('e->e', 'out0 = fabsf(in0)'),             # <<<<<<<<<<<<<<
 *      ('f->f', 'out0 = fabsf(in0)'),
 *      ('d->d', 'out0 = fabs(in0)'),
 */
  __pyx_tuple__406 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_kp_s_out0_fabsf_in0); if (unlikely(!__pyx_tuple__406)) __PYX_ERR(0, 4093, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__406);
  __Pyx_GIVEREF(__pyx_tuple__406);

  /* "cupy/core/core.pyx":4094
 *      'q->q', ('Q->Q', 'out0 = in0'),
 *      ('e->e', 'out0 = fabsf(in0)'),
 *      ('f->f', 'out0 = fabsf(in0)'),             # <<<<<<<<<<<<<<
 *      ('d->d', 'out0 = fabs(in0)'),
 *      ('F->f', 'out0 = abs(in0)'),
 */
  __pyx_tuple__407 = PyTuple_Pack(2, __pyx_kp_s_f_f, __pyx_kp_s_out0_fabsf_in0); if (unlikely(!__pyx_tuple__407)) __PYX_ERR(0, 4094, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__407);
  __Pyx_GIVEREF(__pyx_tuple__407);

  /* "cupy/core/core.pyx":4095
 *      ('e->e', 'out0 = fabsf(in0)'),
 *      ('f->f', 'out0 = fabsf(in0)'),
 *      ('d->d', 'out0 = fabs(in0)'),             # <<<<<<<<<<<<<<
 *      ('F->f', 'out0 = abs(in0)'),
 *      ('D->d', 'out0 = abs(in0)')),
 */
  __pyx_tuple__408 = PyTuple_Pack(2, __pyx_kp_s_d_d, __pyx_kp_s_out0_fabs_in0); if (unlikely(!__pyx_tuple__408)) __PYX_ERR(0, 4095, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__408);
  __Pyx_GIVEREF(__pyx_tuple__408);

  /* "cupy/core/core.pyx":4096
 *      ('f->f', 'out0 = fabsf(in0)'),
 *      ('d->d', 'out0 = fabs(in0)'),
 *      ('F->f', 'out0 = abs(in0)'),             # <<<<<<<<<<<<<<
 *      ('D->d', 'out0 = abs(in0)')),
 *     'out0 = in0 > 0 ? in0 : -in0',
 */
  __pyx_tuple__409 = PyTuple_Pack(2, __pyx_kp_s_F_f, __pyx_kp_s_out0_abs_in0); if (unlikely(!__pyx_tuple__409)) __PYX_ERR(0, 4096, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__409);
  __Pyx_GIVEREF(__pyx_tuple__409);

  /* "cupy/core/core.pyx":4097
 *      ('d->d', 'out0 = fabs(in0)'),
 *      ('F->f', 'out0 = abs(in0)'),
 *      ('D->d', 'out0 = abs(in0)')),             # <<<<<<<<<<<<<<
 *     'out0 = in0 > 0 ? in0 : -in0',
 *     doc='''Elementwise absolute value function.
 */
  __pyx_tuple__410 = PyTuple_Pack(2, __pyx_kp_s_D_d, __pyx_kp_s_out0_abs_in0); if (unlikely(!__pyx_tuple__410)) __PYX_ERR(0, 4097, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__410);
  __Pyx_GIVEREF(__pyx_tuple__410);

  /* "cupy/core/core.pyx":4089
 * absolute = create_ufunc(
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),             # <<<<<<<<<<<<<<
 *      'b->b', ('B->B', 'out0 = in0'), 'h->h', ('H->H', 'out0 = in0'),
 *      'i->i', ('I->I', 'out0 = in0'), 'l->l', ('L->L', 'out0 = in0'),
 */
  __pyx_tuple__411 = PyTuple_Pack(16, __pyx_tuple__400, __pyx_kp_s_b_b, __pyx_tuple__401, __pyx_kp_s_h_h, __pyx_tuple__402, __pyx_kp_s_i_i, __pyx_tuple__403, __pyx_kp_s_l_l, __pyx_tuple__404, __pyx_kp_s_q_q, __pyx_tuple__405, __pyx_tuple__406, __pyx_tuple__407, __pyx_tuple__408, __pyx_tuple__409, __pyx_tuple__410); if (unlikely(!__pyx_tuple__411)) __PYX_ERR(0, 4089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__411);
  __Pyx_GIVEREF(__pyx_tuple__411);

  /* "cupy/core/core.pyx":4087
 * 
 * 
 * absolute = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),
 */
  __pyx_tuple__412 = PyTuple_Pack(3, __pyx_n_s_cupy_absolute, __pyx_tuple__411, __pyx_kp_s_out0_in0_0_in0_in0); if (unlikely(!__pyx_tuple__412)) __PYX_ERR(0, 4087, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__412);
  __Pyx_GIVEREF(__pyx_tuple__412);

  /* "cupy/core/core.pyx":4108
 * sqrt = create_ufunc(
 *     'cupy_sqrt',
 *     ('e->e', 'f->f', 'd->d', 'F->F', 'D->D'),             # <<<<<<<<<<<<<<
 *     'out0 = sqrt(in0)')
 * 
 */
  __pyx_tuple__413 = PyTuple_Pack(5, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_kp_s_F_F, __pyx_kp_s_D_D); if (unlikely(!__pyx_tuple__413)) __PYX_ERR(0, 4108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__413);
  __Pyx_GIVEREF(__pyx_tuple__413);

  /* "cupy/core/core.pyx":4114
 * _clip = create_ufunc(
 *     'cupy_clip',
 *     ('???->?', 'bbb->b', 'BBB->B', 'hhh->h', 'HHH->H', 'iii->i', 'III->I',             # <<<<<<<<<<<<<<
 *      'lll->l', 'LLL->L', 'qqq->q', 'QQQ->Q', 'eee->e', 'fff->f', 'ddd->d'),
 *     'out0 = in0 < in1 ? in1 : (in0 > in2 ? in2 : in0)')
 */
  __pyx_tuple__415 = PyTuple_Pack(14, __pyx_kp_s__414, __pyx_kp_s_bbb_b, __pyx_kp_s_BBB_B, __pyx_kp_s_hhh_h, __pyx_kp_s_HHH_H, __pyx_kp_s_iii_i, __pyx_kp_s_III_I, __pyx_kp_s_lll_l, __pyx_kp_s_LLL_L, __pyx_kp_s_qqq_q, __pyx_kp_s_QQQ_Q, __pyx_kp_s_eee_e, __pyx_kp_s_fff_f, __pyx_kp_s_ddd_d); if (unlikely(!__pyx_tuple__415)) __PYX_ERR(0, 4114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__415);
  __Pyx_GIVEREF(__pyx_tuple__415);

  /* "cupy/core/core.pyx":4155
 * 
 * 
 * cdef _var_core = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T mean, T alpha', 'T out',
 *     '(x - mean) * (x - mean)',
 */
  __pyx_tuple__416 = PyTuple_Pack(7, __pyx_kp_s_S_x_T_mean_T_alpha, __pyx_kp_s_T_out, __pyx_kp_s_x_mean_x_mean, __pyx_kp_s_a_b, __pyx_kp_s_out_alpha_a, __pyx_kp_s_0, __pyx_n_s_var_core); if (unlikely(!__pyx_tuple__416)) __PYX_ERR(0, 4155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__416);
  __Pyx_GIVEREF(__pyx_tuple__416);

  /* "cupy/core/core.pyx":4160
 *     'a + b', 'out = alpha * a', '0', '_var_core')
 * 
 * cdef _var_core_out = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T mean, T alpha', 'U out',
 *     '(x - mean) * (x - mean)',
 */
  __pyx_tuple__417 = PyTuple_Pack(7, __pyx_kp_s_S_x_T_mean_T_alpha, __pyx_kp_s_U_out, __pyx_kp_s_x_mean_x_mean, __pyx_kp_s_a_b, __pyx_kp_s_out_alpha_a, __pyx_kp_s_0, __pyx_n_s_var_core); if (unlikely(!__pyx_tuple__417)) __PYX_ERR(0, 4160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__417);
  __Pyx_GIVEREF(__pyx_tuple__417);

  /* "cupy/core/core.pyx":4170
 *     ('?->d', 'B->d', 'h->d', 'H->d', 'i->d', 'I->d', 'l->d', 'L->d',
 *      'q->d', 'Q->d',
 *      ('e->e', (None, None, None, 'float')),             # <<<<<<<<<<<<<<
 *      'f->f', 'd->d', 'F->F', 'D->D'),
 *     ('in0', 'a + b',
 */
  __pyx_tuple__418 = PyTuple_Pack(4, Py_None, Py_None, Py_None, __pyx_n_s_float); if (unlikely(!__pyx_tuple__418)) __PYX_ERR(0, 4170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__418);
  __Pyx_GIVEREF(__pyx_tuple__418);
  __pyx_tuple__419 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__418); if (unlikely(!__pyx_tuple__419)) __PYX_ERR(0, 4170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__419);
  __Pyx_GIVEREF(__pyx_tuple__419);

  /* "cupy/core/core.pyx":4168
 * cdef _mean = create_reduction_func(
 *     'cupy_mean',
 *     ('?->d', 'B->d', 'h->d', 'H->d', 'i->d', 'I->d', 'l->d', 'L->d',             # <<<<<<<<<<<<<<
 *      'q->d', 'Q->d',
 *      ('e->e', (None, None, None, 'float')),
 */
  __pyx_tuple__420 = PyTuple_Pack(15, __pyx_kp_s_d_3, __pyx_kp_s_B_d, __pyx_kp_s_h_d, __pyx_kp_s_H_d, __pyx_kp_s_i_d, __pyx_kp_s_I_d, __pyx_kp_s_l_d, __pyx_kp_s_L_d, __pyx_kp_s_q_d, __pyx_kp_s_Q_d, __pyx_tuple__419, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_kp_s_F_F, __pyx_kp_s_D_D); if (unlikely(!__pyx_tuple__420)) __PYX_ERR(0, 4168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__420);
  __Pyx_GIVEREF(__pyx_tuple__420);

  /* "cupy/core/core.pyx":4172
 *      ('e->e', (None, None, None, 'float')),
 *      'f->f', 'd->d', 'F->F', 'D->D'),
 *     ('in0', 'a + b',             # <<<<<<<<<<<<<<
 *      'out0 = a / _type_reduce(_in_ind.size() / _out_ind.size())', None))
 * 
 */
  __pyx_tuple__421 = PyTuple_Pack(4, __pyx_n_s_in0, __pyx_kp_s_a_b, __pyx_kp_s_out0_a__type_reduce__in_ind_size, Py_None); if (unlikely(!__pyx_tuple__421)) __PYX_ERR(0, 4172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__421);
  __Pyx_GIVEREF(__pyx_tuple__421);

  /* "cupy/core/core.pyx":4181
 * 
 * @util.memoize(for_each_device=True)
 * def _inclusive_scan_kernel(dtype, block_size):             # <<<<<<<<<<<<<<
 *     """return Prefix Sum(Scan) cuda kernel
 * 
 */
  __pyx_tuple__422 = PyTuple_Pack(5, __pyx_n_s_dtype, __pyx_n_s_block_size, __pyx_n_s_name, __pyx_n_s_source, __pyx_n_s_module_2); if (unlikely(!__pyx_tuple__422)) __PYX_ERR(0, 4181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__422);
  __Pyx_GIVEREF(__pyx_tuple__422);
  __pyx_codeobj__423 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__422, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_core_pyx, __pyx_n_s_inclusive_scan_kernel_2, 4181, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__423)) __PYX_ERR(0, 4181, __pyx_L1_error)

  /* "cupy/core/core.pyx":4248
 * 
 * @util.memoize(for_each_device=True)
 * def _add_scan_blocked_sum_kernel(dtype):             # <<<<<<<<<<<<<<
 *     name = "add_scan_blocked_sum_kernel"
 *     dtype = _get_typename(dtype)
 */
  __pyx_tuple__424 = PyTuple_Pack(4, __pyx_n_s_dtype, __pyx_n_s_name, __pyx_n_s_source, __pyx_n_s_module_2); if (unlikely(!__pyx_tuple__424)) __PYX_ERR(0, 4248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__424);
  __Pyx_GIVEREF(__pyx_tuple__424);
  __pyx_codeobj__425 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__424, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_core_pyx, __pyx_n_s_add_scan_blocked_sum_kernel_2, 4248, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__425)) __PYX_ERR(0, 4248, __pyx_L1_error)

  /* "cupy/core/core.pyx":4268
 * 
 * @util.memoize(for_each_device=True)
 * def _nonzero_1d_kernel(src_dtype, index_dtype):             # <<<<<<<<<<<<<<
 *     name = "nonzero_1d_kernel"
 *     src_dtype = _get_typename(src_dtype)
 */
  __pyx_tuple__426 = PyTuple_Pack(5, __pyx_n_s_src_dtype, __pyx_n_s_index_dtype, __pyx_n_s_name, __pyx_n_s_source, __pyx_n_s_module_2); if (unlikely(!__pyx_tuple__426)) __PYX_ERR(0, 4268, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__426);
  __Pyx_GIVEREF(__pyx_tuple__426);
  __pyx_codeobj__427 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__426, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_core_pyx, __pyx_n_s_nonzero_1d_kernel, 4268, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__427)) __PYX_ERR(0, 4268, __pyx_L1_error)

  /* "cupy/core/core.pyx":4291
 * 
 * @util.memoize(for_each_device=True)
 * def _nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype):             # <<<<<<<<<<<<<<
 *     name = "nonzero_kernel"
 *     src_dtype = _get_typename(src_dtype)
 */
  __pyx_tuple__428 = PyTuple_Pack(7, __pyx_n_s_src_dtype, __pyx_n_s_src_ndim, __pyx_n_s_index_dtype, __pyx_n_s_dst_dtype, __pyx_n_s_name, __pyx_n_s_source, __pyx_n_s_module_2); if (unlikely(!__pyx_tuple__428)) __PYX_ERR(0, 4291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__428);
  __Pyx_GIVEREF(__pyx_tuple__428);
  __pyx_codeobj__429 = (PyObject*)__Pyx_PyCode_New(4, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__428, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_core_pyx, __pyx_n_s_nonzero_kernel, 4291, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__429)) __PYX_ERR(0, 4291, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __pyx_unpickle_Indexer(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x6d47339:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_tuple__430 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__430)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__430);
  __Pyx_GIVEREF(__pyx_tuple__430);
  __pyx_codeobj__431 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__430, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Indexer, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__431)) __PYX_ERR(4, 1, __pyx_L1_error)
  __pyx_tuple__432 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__432)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__432);
  __Pyx_GIVEREF(__pyx_tuple__432);
  __pyx_codeobj__433 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__432, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_ParameterInfo, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__433)) __PYX_ERR(4, 1, __pyx_L1_error)
  __pyx_tuple__434 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__434)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__434);
  __Pyx_GIVEREF(__pyx_tuple__434);
  __pyx_codeobj__435 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__434, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_ElementwiseKernel, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__435)) __PYX_ERR(4, 1, __pyx_L1_error)
  __pyx_tuple__436 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__436)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__436);
  __Pyx_GIVEREF(__pyx_tuple__436);
  __pyx_codeobj__437 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__436, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_broadcast, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__437)) __PYX_ERR(4, 1, __pyx_L1_error)

  /* "View.MemoryView":284
 *         return self.name
 * 
 * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
 * cdef strided = Enum("<strided and direct>") # default
 * cdef indirect = Enum("<strided and indirect>")
 */
  __pyx_tuple__438 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__438)) __PYX_ERR(4, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__438);
  __Pyx_GIVEREF(__pyx_tuple__438);

  /* "View.MemoryView":285
 * 
 * cdef generic = Enum("<strided and direct or indirect>")
 * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
 * cdef indirect = Enum("<strided and indirect>")
 * 
 */
  __pyx_tuple__439 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__439)) __PYX_ERR(4, 285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__439);
  __Pyx_GIVEREF(__pyx_tuple__439);

  /* "View.MemoryView":286
 * cdef generic = Enum("<strided and direct or indirect>")
 * cdef strided = Enum("<strided and direct>") # default
 * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__440 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__440)) __PYX_ERR(4, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__440);
  __Pyx_GIVEREF(__pyx_tuple__440);

  /* "View.MemoryView":289
 * 
 * 
 * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
 * cdef indirect_contiguous = Enum("<contiguous and indirect>")
 * 
 */
  __pyx_tuple__441 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__441)) __PYX_ERR(4, 289, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__441);
  __Pyx_GIVEREF(__pyx_tuple__441);

  /* "View.MemoryView":290
 * 
 * cdef contiguous = Enum("<contiguous and direct>")
 * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__442 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__442)) __PYX_ERR(4, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__442);
  __Pyx_GIVEREF(__pyx_tuple__442);

  /* "(tree fragment)":1
 * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xb068931:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_tuple__443 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__443)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__443);
  __Pyx_GIVEREF(__pyx_tuple__443);
  __pyx_codeobj__444 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__443, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Enum, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__444)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  __pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type;
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_float_0_ = PyFloat_FromDouble(0.); if (unlikely(!__pyx_float_0_)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_1_ = PyFloat_FromDouble(1.); if (unlikely(!__pyx_float_1_)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_0_0 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_float_0_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_1_0 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_float_1_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_32 = PyInt_FromLong(32); if (unlikely(!__pyx_int_32)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_70 = PyInt_FromLong(70); if (unlikely(!__pyx_int_70)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_100 = PyInt_FromLong(100); if (unlikely(!__pyx_int_100)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_256 = PyInt_FromLong(256); if (unlikely(!__pyx_int_256)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_512 = PyInt_FromLong(512); if (unlikely(!__pyx_int_512)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_7500 = PyInt_FromLong(7500); if (unlikely(!__pyx_int_7500)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_9000 = PyInt_FromLong(9000); if (unlikely(!__pyx_int_9000)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_524288 = PyInt_FromLong(524288L); if (unlikely(!__pyx_int_524288)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_5472103 = PyInt_FromLong(5472103L); if (unlikely(!__pyx_int_5472103)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_114586425 = PyInt_FromLong(114586425L); if (unlikely(!__pyx_int_114586425)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_121017544 = PyInt_FromLong(121017544L); if (unlikely(!__pyx_int_121017544)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_131642003 = PyInt_FromLong(131642003L); if (unlikely(!__pyx_int_131642003)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_184977713 = PyInt_FromLong(184977713L); if (unlikely(!__pyx_int_184977713)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2147483647 = PyInt_FromLong(2147483647L); if (unlikely(!__pyx_int_2147483647)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_9223372036854775808 = PyInt_FromString((char *)"9223372036854775808", 0, 0); if (unlikely(!__pyx_int_9223372036854775808)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_neg_2 = PyInt_FromLong(-2); if (unlikely(!__pyx_int_neg_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initcore(void); /*proto*/
PyMODINIT_FUNC initcore(void)
#else
PyMODINIT_FUNC PyInit_core(void); /*proto*/
PyMODINIT_FUNC PyInit_core(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  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;
  int __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  int __pyx_t_19;
  Py_ssize_t __pyx_t_20;
  PyObject *(*__pyx_t_21)(PyObject *);
  struct __pyx_opt_args_4cupy_4core_4core_create_ufunc __pyx_t_22;
  struct __pyx_opt_args_4cupy_4core_4core_create_reduction_func __pyx_t_23;
  struct __pyx_opt_args_4cupy_4core_4core__create_bit_op __pyx_t_24;
  struct __pyx_opt_args_4cupy_4core_4core_create_comparison __pyx_t_25;
  static PyThread_type_lock __pyx_t_26[8];
  __Pyx_RefNannyDeclarations
  #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("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_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 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)
  __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 init code ---*/
  __pyx_v_4cupy_4core_4core_newaxis = 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__cuda_path = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__typenames_base = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__all_type_chars = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__typenames = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__python_scalar_type = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__numpy_scalar_type = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__python_scalar_type_set = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__numpy_scalar_type_set = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__kind_score = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__python_type_to_numpy_type = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__id = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__divmod_float = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__min_max_preamble = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__argmin = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__argmax = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__concatenate_kernel_one = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__concatenate_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__take_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__take_kernel_0axis = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__choose_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__choose_clip_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__scatter_update_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__scatter_add_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__scatter_update_mask_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__scatter_add_mask_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__getitem_mask_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__cuda_runtime_version = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__tensordot_core_mul_sum = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__var_core = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__var_core_out = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__mean = Py_None; Py_INCREF(Py_None);
  generic = Py_None; Py_INCREF(Py_None);
  strided = Py_None; Py_INCREF(Py_None);
  indirect = Py_None; Py_INCREF(Py_None);
  contiguous = Py_None; Py_INCREF(Py_None);
  indirect_contiguous = Py_None; Py_INCREF(Py_None);
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  if (__Pyx_ExportFunction("ascontiguousarray", (void (*)(void))__pyx_f_4cupy_4core_4core_ascontiguousarray, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Type init code ---*/
  __pyx_vtabptr_4cupy_4core_4core_ndarray = &__pyx_vtable_4cupy_4core_4core_ndarray;
  __pyx_vtable_4cupy_4core_4core_ndarray.tolist = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_tolist;
  __pyx_vtable_4cupy_4core_4core_ndarray.tofile = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tofile *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_tofile;
  __pyx_vtable_4cupy_4core_4core_ndarray.dump = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_dump;
  __pyx_vtable_4cupy_4core_4core_ndarray.dumps = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_dumps;
  __pyx_vtable_4cupy_4core_4core_ndarray.astype = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_astype;
  __pyx_vtable_4cupy_4core_4core_ndarray.copy = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_copy;
  __pyx_vtable_4cupy_4core_4core_ndarray.view = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_view;
  __pyx_vtable_4cupy_4core_4core_ndarray.fill = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_fill;
  __pyx_vtable_4cupy_4core_4core_ndarray._reshape = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t> , int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray__reshape;
  __pyx_vtable_4cupy_4core_4core_ndarray._transpose = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t> , int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray__transpose;
  __pyx_vtable_4cupy_4core_4core_ndarray.swapaxes = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, Py_ssize_t, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_swapaxes;
  __pyx_vtable_4cupy_4core_4core_ndarray.flatten = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_flatten;
  __pyx_vtable_4cupy_4core_4core_ndarray.ravel = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_ravel;
  __pyx_vtable_4cupy_4core_4core_ndarray.squeeze = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_squeeze *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_squeeze;
  __pyx_vtable_4cupy_4core_4core_ndarray.take = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_take *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_take;
  __pyx_vtable_4cupy_4core_4core_ndarray.repeat = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_repeat *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_repeat;
  __pyx_vtable_4cupy_4core_4core_ndarray.choose = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_choose *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_choose;
  __pyx_vtable_4cupy_4core_4core_ndarray.diagonal = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_diagonal *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_diagonal;
  __pyx_vtable_4cupy_4core_4core_ndarray.max = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_max *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_max;
  __pyx_vtable_4cupy_4core_4core_ndarray.argmax = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmax *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_argmax;
  __pyx_vtable_4cupy_4core_4core_ndarray.min = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_min *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_min;
  __pyx_vtable_4cupy_4core_4core_ndarray.argmin = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmin *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_argmin;
  __pyx_vtable_4cupy_4core_4core_ndarray.clip = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_clip *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_clip;
  __pyx_vtable_4cupy_4core_4core_ndarray.trace = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_trace *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_trace;
  __pyx_vtable_4cupy_4core_4core_ndarray.sum = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sum *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_sum;
  __pyx_vtable_4cupy_4core_4core_ndarray.mean = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_mean *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_mean;
  __pyx_vtable_4cupy_4core_4core_ndarray.var = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_var *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_var;
  __pyx_vtable_4cupy_4core_4core_ndarray.std = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_std *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_std;
  __pyx_vtable_4cupy_4core_4core_ndarray.prod = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_prod *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_prod;
  __pyx_vtable_4cupy_4core_4core_ndarray.all = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_all *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_all;
  __pyx_vtable_4cupy_4core_4core_ndarray.any = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_any *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_any;
  __pyx_vtable_4cupy_4core_4core_ndarray.conj = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_conj;
  __pyx_vtable_4cupy_4core_4core_ndarray.get = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_get *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_get;
  __pyx_vtable_4cupy_4core_4core_ndarray.set = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_set;
  __pyx_vtable_4cupy_4core_4core_ndarray.reduced_view = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_reduced_view *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_reduced_view;
  __pyx_vtable_4cupy_4core_4core_ndarray._update_c_contiguity = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray__update_c_contiguity;
  __pyx_vtable_4cupy_4core_4core_ndarray._update_f_contiguity = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray__update_f_contiguity;
  __pyx_vtable_4cupy_4core_4core_ndarray._update_contiguity = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray__update_contiguity;
  __pyx_vtable_4cupy_4core_4core_ndarray._set_shape_and_strides = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t>  &, std::vector<Py_ssize_t>  &, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray__set_shape_and_strides;
  __pyx_vtable_4cupy_4core_4core_ndarray.get_pointer = (struct __pyx_obj_4cupy_4cuda_8function_CPointer *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *))__pyx_f_4cupy_4core_4core_7ndarray_get_pointer;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_ndarray) < 0) __PYX_ERR(0, 52, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_ndarray.tp_print = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_4cupy_4core_4core_ndarray, "__getitem__"); if (unlikely(!wrapper)) __PYX_ERR(0, 52, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_4cupy_4core_4core_7ndarray_158__getitem__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_4cupy_4core_4core_7ndarray_158__getitem__.doc = __pyx_doc_4cupy_4core_4core_7ndarray_158__getitem__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_4cupy_4core_4core_7ndarray_158__getitem__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_4cupy_4core_4core_ndarray, "__setitem__"); if (unlikely(!wrapper)) __PYX_ERR(0, 52, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_4cupy_4core_4core_7ndarray_160__setitem__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_4cupy_4core_4core_7ndarray_160__setitem__.doc = __pyx_doc_4cupy_4core_4core_7ndarray_160__setitem__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_4cupy_4core_4core_7ndarray_160__setitem__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_4cupy_4core_4core_ndarray.tp_dict, __pyx_vtabptr_4cupy_4core_4core_ndarray) < 0) __PYX_ERR(0, 52, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "ndarray", (PyObject *)&__pyx_type_4cupy_4core_4core_ndarray) < 0) __PYX_ERR(0, 52, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_ndarray = &__pyx_type_4cupy_4core_4core_ndarray;
  __pyx_vtabptr_4cupy_4core_4core_Indexer = &__pyx_vtable_4cupy_4core_4core_Indexer;
  __pyx_vtable_4cupy_4core_4core_Indexer.get_pointer = (struct __pyx_obj_4cupy_4cuda_8function_CPointer *(*)(struct __pyx_obj_4cupy_4core_4core_Indexer *))__pyx_f_4cupy_4core_4core_7Indexer_get_pointer;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_Indexer) < 0) __PYX_ERR(2, 50, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_Indexer.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_4cupy_4core_4core_Indexer.tp_dict, __pyx_vtabptr_4cupy_4core_4core_Indexer) < 0) __PYX_ERR(2, 50, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Indexer", (PyObject *)&__pyx_type_4cupy_4core_4core_Indexer) < 0) __PYX_ERR(2, 50, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4cupy_4core_4core_Indexer) < 0) __PYX_ERR(2, 50, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_Indexer = &__pyx_type_4cupy_4core_4core_Indexer;
  __pyx_ptype_4cupy_4cuda_8function_CPointer = __Pyx_ImportType("cupy.cuda.function", "CPointer", sizeof(struct __pyx_obj_4cupy_4cuda_8function_CPointer), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_8function_CPointer)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_CArray.tp_base = __pyx_ptype_4cupy_4cuda_8function_CPointer;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_CArray) < 0) __PYX_ERR(2, 17, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_CArray.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "CArray", (PyObject *)&__pyx_type_4cupy_4core_4core_CArray) < 0) __PYX_ERR(2, 17, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4cupy_4core_4core_CArray) < 0) __PYX_ERR(2, 17, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_CArray = &__pyx_type_4cupy_4core_4core_CArray;
  __pyx_type_4cupy_4core_4core_CIndexer.tp_base = __pyx_ptype_4cupy_4cuda_8function_CPointer;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_CIndexer) < 0) __PYX_ERR(2, 38, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_CIndexer.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "CIndexer", (PyObject *)&__pyx_type_4cupy_4core_4core_CIndexer) < 0) __PYX_ERR(2, 38, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4cupy_4core_4core_CIndexer) < 0) __PYX_ERR(2, 38, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_CIndexer = &__pyx_type_4cupy_4core_4core_CIndexer;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_ParameterInfo) < 0) __PYX_ERR(1, 252, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_ParameterInfo.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "ParameterInfo", (PyObject *)&__pyx_type_4cupy_4core_4core_ParameterInfo) < 0) __PYX_ERR(1, 252, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4cupy_4core_4core_ParameterInfo) < 0) __PYX_ERR(1, 252, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_ParameterInfo = &__pyx_type_4cupy_4core_4core_ParameterInfo;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_ElementwiseKernel) < 0) __PYX_ERR(1, 445, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_ElementwiseKernel.tp_print = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_4cupy_4core_4core_ElementwiseKernel, "__call__"); if (unlikely(!wrapper)) __PYX_ERR(1, 445, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_4cupy_4core_4core_17ElementwiseKernel_2__call__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_4cupy_4core_4core_17ElementwiseKernel_2__call__.doc = __pyx_doc_4cupy_4core_4core_17ElementwiseKernel_2__call__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_4cupy_4core_4core_17ElementwiseKernel_2__call__;
    }
  }
  #endif
  if (PyObject_SetAttrString(__pyx_m, "ElementwiseKernel", (PyObject *)&__pyx_type_4cupy_4core_4core_ElementwiseKernel) < 0) __PYX_ERR(1, 445, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4cupy_4core_4core_ElementwiseKernel) < 0) __PYX_ERR(1, 445, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_ElementwiseKernel = &__pyx_type_4cupy_4core_4core_ElementwiseKernel;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_broadcast) < 0) __PYX_ERR(0, 2307, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_broadcast.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "broadcast", (PyObject *)&__pyx_type_4cupy_4core_4core_broadcast) < 0) __PYX_ERR(0, 2307, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4cupy_4core_4core_broadcast) < 0) __PYX_ERR(0, 2307, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_broadcast = &__pyx_type_4cupy_4core_4core_broadcast;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel) < 0) __PYX_ERR(1, 423, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel.tp_print = 0;
  __pyx_ptype_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel = &__pyx_type_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core___pyx_scope_struct_1_genexpr) < 0) __PYX_ERR(1, 427, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core___pyx_scope_struct_1_genexpr.tp_print = 0;
  __pyx_ptype_4cupy_4core_4core___pyx_scope_struct_1_genexpr = &__pyx_type_4cupy_4core_4core___pyx_scope_struct_1_genexpr;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core___pyx_scope_struct_2___init__) < 0) __PYX_ERR(1, 711, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core___pyx_scope_struct_2___init__.tp_print = 0;
  __pyx_ptype_4cupy_4core_4core___pyx_scope_struct_2___init__ = &__pyx_type_4cupy_4core_4core___pyx_scope_struct_2___init__;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core___pyx_scope_struct_3_genexpr) < 0) __PYX_ERR(1, 725, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core___pyx_scope_struct_3_genexpr.tp_print = 0;
  __pyx_ptype_4cupy_4core_4core___pyx_scope_struct_3_genexpr = &__pyx_type_4cupy_4core_4core___pyx_scope_struct_3_genexpr;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core___pyx_scope_struct_4_genexpr) < 0) __PYX_ERR(1, 728, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core___pyx_scope_struct_4_genexpr.tp_print = 0;
  __pyx_ptype_4cupy_4core_4core___pyx_scope_struct_4_genexpr = &__pyx_type_4cupy_4core_4core___pyx_scope_struct_4_genexpr;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel) < 0) __PYX_ERR(5, 273, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel.tp_print = 0;
  __pyx_ptype_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel = &__pyx_type_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core___pyx_scope_struct_6_genexpr) < 0) __PYX_ERR(5, 281, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core___pyx_scope_struct_6_genexpr.tp_print = 0;
  __pyx_ptype_4cupy_4core_4core___pyx_scope_struct_6_genexpr = &__pyx_type_4cupy_4core_4core___pyx_scope_struct_6_genexpr;
  __pyx_vtabptr_array = &__pyx_vtable_array;
  __pyx_vtable_array.get_memview = (PyObject *(*)(struct __pyx_array_obj *))__pyx_array_get_memview;
  if (PyType_Ready(&__pyx_type___pyx_array) < 0) __PYX_ERR(4, 103, __pyx_L1_error)
  __pyx_type___pyx_array.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type___pyx_array.tp_dict, __pyx_vtabptr_array) < 0) __PYX_ERR(4, 103, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_array) < 0) __PYX_ERR(4, 103, __pyx_L1_error)
  __pyx_array_type = &__pyx_type___pyx_array;
  if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(4, 277, __pyx_L1_error)
  __pyx_type___pyx_MemviewEnum.tp_print = 0;
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(4, 277, __pyx_L1_error)
  __pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum;
  __pyx_vtabptr_memoryview = &__pyx_vtable_memoryview;
  __pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer;
  __pyx_vtable_memoryview.is_slice = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_is_slice;
  __pyx_vtable_memoryview.setitem_slice_assignment = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_slice_assignment;
  __pyx_vtable_memoryview.setitem_slice_assign_scalar = (PyObject *(*)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_setitem_slice_assign_scalar;
  __pyx_vtable_memoryview.setitem_indexed = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_indexed;
  __pyx_vtable_memoryview.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryview_convert_item_to_object;
  __pyx_vtable_memoryview.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryview_assign_item_from_object;
  if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(4, 328, __pyx_L1_error)
  __pyx_type___pyx_memoryview.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) __PYX_ERR(4, 328, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(4, 328, __pyx_L1_error)
  __pyx_memoryview_type = &__pyx_type___pyx_memoryview;
  __pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice;
  __pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview;
  __pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object;
  __pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object;
  __pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type;
  if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(4, 953, __pyx_L1_error)
  __pyx_type___pyx_memoryviewslice.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) __PYX_ERR(4, 953, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(4, 953, __pyx_L1_error)
  __pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice;
  /*--- Type import code ---*/
  __pyx_ptype_4cupy_4cuda_6device_Device = __Pyx_ImportType("cupy.cuda.device", "Device", sizeof(struct __pyx_obj_4cupy_4cuda_6device_Device), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6device_Device)) __PYX_ERR(6, 7, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_6device_Device = (struct __pyx_vtabstruct_4cupy_4cuda_6device_Device*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_6device_Device->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_6device_Device)) __PYX_ERR(6, 7, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_Chunk = __Pyx_ImportType("cupy.cuda.memory", "Chunk", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_Chunk), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_Chunk)) __PYX_ERR(7, 7, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer = __Pyx_ImportType("cupy.cuda.memory", "MemoryPointer", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_MemoryPointer)) __PYX_ERR(7, 19, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_6memory_MemoryPointer = (struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_6memory_MemoryPointer->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_6memory_MemoryPointer)) __PYX_ERR(7, 19, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_SingleDeviceMemoryPool = __Pyx_ImportType("cupy.cuda.memory", "SingleDeviceMemoryPool", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_SingleDeviceMemoryPool)) __PYX_ERR(7, 45, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_6memory_SingleDeviceMemoryPool = (struct __pyx_vtabstruct_4cupy_4cuda_6memory_SingleDeviceMemoryPool*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_6memory_SingleDeviceMemoryPool->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_6memory_SingleDeviceMemoryPool)) __PYX_ERR(7, 45, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_MemoryPool = __Pyx_ImportType("cupy.cuda.memory", "MemoryPool", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_MemoryPool)) __PYX_ERR(7, 79, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_6memory_MemoryPool = (struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPool*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_6memory_MemoryPool->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_6memory_MemoryPool)) __PYX_ERR(7, 79, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_8function_Function = __Pyx_ImportType("cupy.cuda.function", "Function", sizeof(struct __pyx_obj_4cupy_4cuda_8function_Function), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_8function_Function)) __PYX_ERR(8, 5, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_8function_Function = (struct __pyx_vtabstruct_4cupy_4cuda_8function_Function*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_8function_Function->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_8function_Function)) __PYX_ERR(8, 5, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_8function_Module = __Pyx_ImportType("cupy.cuda.function", "Module", sizeof(struct __pyx_obj_4cupy_4cuda_8function_Module), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_8function_Module)) __PYX_ERR(8, 15, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_8function_Module = (struct __pyx_vtabstruct_4cupy_4cuda_8function_Module*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_8function_Module->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_8function_Module)) __PYX_ERR(8, 15, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_8function_LinkState = __Pyx_ImportType("cupy.cuda.function", "LinkState", sizeof(struct __pyx_obj_4cupy_4cuda_8function_LinkState), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_8function_LinkState)) __PYX_ERR(8, 26, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_8function_LinkState = (struct __pyx_vtabstruct_4cupy_4cuda_8function_LinkState*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_8function_LinkState->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_8function_LinkState)) __PYX_ERR(8, 26, __pyx_L1_error)
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", 
  #if CYTHON_COMPILING_IN_PYPY
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(9, 9, __pyx_L1_error)
  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) __PYX_ERR(10, 8, __pyx_L1_error)
  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) __PYX_ERR(11, 15, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer = __Pyx_ImportType("cupy.cuda.pinned_memory", "PinnedMemoryPointer", sizeof(struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer)) __PYX_ERR(12, 2, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer = (struct __pyx_vtabstruct_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer)) __PYX_ERR(12, 2, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_13pinned_memory_PinnedMemoryPool = __Pyx_ImportType("cupy.cuda.pinned_memory", "PinnedMemoryPool", sizeof(struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPool), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_13pinned_memory_PinnedMemoryPool)) __PYX_ERR(12, 22, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_13pinned_memory_PinnedMemoryPool = (struct __pyx_vtabstruct_4cupy_4cuda_13pinned_memory_PinnedMemoryPool*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_13pinned_memory_PinnedMemoryPool->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_13pinned_memory_PinnedMemoryPool)) __PYX_ERR(12, 22, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_7runtime_PointerAttributes = __Pyx_ImportType("cupy.cuda.runtime", "PointerAttributes", sizeof(struct __pyx_obj_4cupy_4cuda_7runtime_PointerAttributes), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_7runtime_PointerAttributes)) __PYX_ERR(13, 5, __pyx_L1_error)
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("cupy.cuda.device"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "get_device_id", (void (**)(void))&__pyx_f_4cupy_4cuda_6device_get_device_id, "int (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "get_cublas_handle", (void (**)(void))&__pyx_f_4cupy_4cuda_6device_get_cublas_handle, "size_t (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "get_compute_capability", (void (**)(void))&__pyx_f_4cupy_4cuda_6device_get_compute_capability, "PyObject *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = __Pyx_ImportModule("cupy.cuda.memory"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_2, "alloc", (void (**)(void))&__pyx_f_4cupy_4cuda_6memory_alloc, "struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *(Py_ssize_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_ImportModule("cupy.core.internal"); if (!__pyx_t_3) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_3, "prod", (void (**)(void))&__pyx_f_4cupy_4core_8internal_prod, "Py_ssize_t (PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_8internal_prod *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_3, "prod_ssize_t", (void (**)(void))&__pyx_f_4cupy_4core_8internal_prod_ssize_t, "Py_ssize_t (std::vector<Py_ssize_t>  &, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_8internal_prod_ssize_t *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_3, "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_3, "vector_equal", (void (**)(void))&__pyx_f_4cupy_4core_8internal_vector_equal, "int (std::vector<Py_ssize_t>  &, std::vector<Py_ssize_t>  &, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_3, "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_3, "get_contiguous_strides", (void (**)(void))&__pyx_f_4cupy_4core_8internal_get_contiguous_strides, "std::vector<Py_ssize_t>  (std::vector<Py_ssize_t>  &, Py_ssize_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_3, "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_3, "infer_unknown_dimension", (void (**)(void))&__pyx_f_4cupy_4core_8internal_infer_unknown_dimension, "std::vector<Py_ssize_t>  (std::vector<Py_ssize_t>  &, Py_ssize_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_3, "complete_slice", (void (**)(void))&__pyx_f_4cupy_4core_8internal_complete_slice, "PyObject *(PyObject *, Py_ssize_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_ImportModule("cupy.cuda.cublas"); if (!__pyx_t_4) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "setMathMode", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_setMathMode, "PyObject *(size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "sgemm", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_sgemm, "PyObject *(size_t, int, int, int, int, int, float, size_t, int, size_t, int, float, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "dgemm", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_dgemm, "PyObject *(size_t, int, int, int, int, int, double, size_t, int, size_t, int, double, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "cgemm", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_cgemm, "PyObject *(size_t, int, int, int, int, int, __pyx_t_float_complex, size_t, int, size_t, int, __pyx_t_float_complex, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "zgemm", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_zgemm, "PyObject *(size_t, int, int, int, int, int, __pyx_t_double_complex, size_t, int, size_t, int, __pyx_t_double_complex, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "sgemmEx", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_sgemmEx, "PyObject *(size_t, int, int, int, int, int, float, size_t, int, int, size_t, int, int, float, size_t, int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "gemmEx", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_gemmEx, "PyObject *(size_t, int, int, int, int, int, size_t, size_t, int, int, size_t, int, int, size_t, size_t, int, int, int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = __Pyx_ImportModule("cupy.cuda.pinned_memory"); if (!__pyx_t_5) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_5, "_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_5, "alloc_pinned_memory", (void (**)(void))&__pyx_f_4cupy_4cuda_13pinned_memory_alloc_pinned_memory, "struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer *(Py_ssize_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_ImportModule("cupy.cuda.runtime"); if (!__pyx_t_6) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_6, "runtimeGetVersion", (void (**)(void))&__pyx_f_4cupy_4cuda_7runtime_runtimeGetVersion, "int (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_7 = __Pyx_ImportModule("cupy.cuda.stream"); if (!__pyx_t_7) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_7, "get_current_stream_ptr", (void (**)(void))&__pyx_f_4cupy_4cuda_6stream_get_current_stream_ptr, "size_t (void)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "cupy/core/core.pyx":4
 * 
 * from __future__ import division
 * import sys             # <<<<<<<<<<<<<<
 * 
 * import numpy
 */
  __pyx_t_8 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_8) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":6
 * import sys
 * 
 * import numpy             # <<<<<<<<<<<<<<
 * import six
 * 
 */
  __pyx_t_8 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_8) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":7
 * 
 * import numpy
 * import six             # <<<<<<<<<<<<<<
 * 
 * import cupy
 */
  __pyx_t_8 = __Pyx_Import(__pyx_n_s_six, 0, -1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_six, __pyx_t_8) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":9
 * import six
 * 
 * import cupy             # <<<<<<<<<<<<<<
 * from cupy.core import flags
 * from cupy.cuda import device
 */
  __pyx_t_8 = __Pyx_Import(__pyx_n_s_cupy, 0, -1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_cupy, __pyx_t_8) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":10
 * 
 * import cupy
 * from cupy.core import flags             # <<<<<<<<<<<<<<
 * from cupy.cuda import device
 * from cupy.cuda import stream
 */
  __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_n_s_flags);
  __Pyx_GIVEREF(__pyx_n_s_flags);
  PyList_SET_ITEM(__pyx_t_8, 0, __pyx_n_s_flags);
  __pyx_t_9 = __Pyx_Import(__pyx_n_s_cupy_core, __pyx_t_8, -1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_flags); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_flags, __pyx_t_8) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":11
 * import cupy
 * from cupy.core import flags
 * from cupy.cuda import device             # <<<<<<<<<<<<<<
 * from cupy.cuda import stream
 * try:
 */
  __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_n_s_device);
  __Pyx_GIVEREF(__pyx_n_s_device);
  PyList_SET_ITEM(__pyx_t_9, 0, __pyx_n_s_device);
  __pyx_t_8 = __Pyx_Import(__pyx_n_s_cupy_cuda, __pyx_t_9, -1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_8, __pyx_n_s_device); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_device, __pyx_t_9) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":12
 * from cupy.core import flags
 * from cupy.cuda import device
 * from cupy.cuda import stream             # <<<<<<<<<<<<<<
 * try:
 *     from cupy.cuda import thrust
 */
  __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_n_s_stream);
  __Pyx_GIVEREF(__pyx_n_s_stream);
  PyList_SET_ITEM(__pyx_t_8, 0, __pyx_n_s_stream);
  __pyx_t_9 = __Pyx_Import(__pyx_n_s_cupy_cuda, __pyx_t_8, -1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_stream); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_stream, __pyx_t_8) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":13
 * from cupy.cuda import device
 * from cupy.cuda import stream
 * try:             # <<<<<<<<<<<<<<
 *     from cupy.cuda import thrust
 * except ImportError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
    __Pyx_XGOTREF(__pyx_t_10);
    __Pyx_XGOTREF(__pyx_t_11);
    __Pyx_XGOTREF(__pyx_t_12);
    /*try:*/ {

      /* "cupy/core/core.pyx":14
 * from cupy.cuda import stream
 * try:
 *     from cupy.cuda import thrust             # <<<<<<<<<<<<<<
 * except ImportError:
 *     pass
 */
      __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 14, __pyx_L2_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_n_s_thrust);
      __Pyx_GIVEREF(__pyx_n_s_thrust);
      PyList_SET_ITEM(__pyx_t_9, 0, __pyx_n_s_thrust);
      __pyx_t_8 = __Pyx_Import(__pyx_n_s_cupy_cuda, __pyx_t_9, -1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 14, __pyx_L2_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_8, __pyx_n_s_thrust); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 14, __pyx_L2_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_thrust, __pyx_t_9) < 0) __PYX_ERR(0, 14, __pyx_L2_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":13
 * from cupy.cuda import device
 * from cupy.cuda import stream
 * try:             # <<<<<<<<<<<<<<
 *     from cupy.cuda import thrust
 * except ImportError:
 */
    }
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    goto __pyx_L7_try_end;
    __pyx_L2_error:;
    __Pyx_PyThreadState_assign
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":15
 * try:
 *     from cupy.cuda import thrust
 * except ImportError:             # <<<<<<<<<<<<<<
 *     pass
 * from cupy import util
 */
    __pyx_t_13 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError);
    if (__pyx_t_13) {
      __Pyx_ErrRestore(0,0,0);
      goto __pyx_L3_exception_handled;
    }
    goto __pyx_L4_except_error;
    __pyx_L4_except_error:;

    /* "cupy/core/core.pyx":13
 * from cupy.cuda import device
 * from cupy.cuda import stream
 * try:             # <<<<<<<<<<<<<<
 *     from cupy.cuda import thrust
 * except ImportError:
 */
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_10);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
    goto __pyx_L1_error;
    __pyx_L3_exception_handled:;
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_10);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
    __pyx_L7_try_end:;
  }

  /* "cupy/core/core.pyx":17
 * except ImportError:
 *     pass
 * from cupy import util             # <<<<<<<<<<<<<<
 * 
 * cimport cpython
 */
  __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_n_s_util);
  __Pyx_GIVEREF(__pyx_n_s_util);
  PyList_SET_ITEM(__pyx_t_8, 0, __pyx_n_s_util);
  __pyx_t_9 = __Pyx_Import(__pyx_n_s_cupy, __pyx_t_8, -1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_util); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_util, __pyx_t_8) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":41
 * 
 * 
 * try:             # <<<<<<<<<<<<<<
 *     _AxisError = numpy.AxisError
 * except AttributeError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
    __Pyx_XGOTREF(__pyx_t_12);
    __Pyx_XGOTREF(__pyx_t_11);
    __Pyx_XGOTREF(__pyx_t_10);
    /*try:*/ {

      /* "cupy/core/core.pyx":42
 * 
 * try:
 *     _AxisError = numpy.AxisError             # <<<<<<<<<<<<<<
 * except AttributeError:
 *     class IndexOrValueError(IndexError, ValueError):
 */
      __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 42, __pyx_L8_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_AxisError_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 42, __pyx_L8_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_AxisError, __pyx_t_8) < 0) __PYX_ERR(0, 42, __pyx_L8_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":41
 * 
 * 
 * try:             # <<<<<<<<<<<<<<
 *     _AxisError = numpy.AxisError
 * except AttributeError:
 */
    }
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    goto __pyx_L13_try_end;
    __pyx_L8_error:;
    __Pyx_PyThreadState_assign
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":43
 * try:
 *     _AxisError = numpy.AxisError
 * except AttributeError:             # <<<<<<<<<<<<<<
 *     class IndexOrValueError(IndexError, ValueError):
 * 
 */
    __pyx_t_13 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
    if (__pyx_t_13) {
      __Pyx_AddTraceback("cupy.core.core", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_14) < 0) __PYX_ERR(0, 43, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GOTREF(__pyx_t_14);

      /* "cupy/core/core.pyx":44
 *     _AxisError = numpy.AxisError
 * except AttributeError:
 *     class IndexOrValueError(IndexError, ValueError):             # <<<<<<<<<<<<<<
 * 
 *         def __init__(self, *args, **kwargs):
 */
      __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 44, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_INCREF(__pyx_builtin_IndexError);
      __Pyx_GIVEREF(__pyx_builtin_IndexError);
      PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_builtin_IndexError);
      __Pyx_INCREF(__pyx_builtin_ValueError);
      __Pyx_GIVEREF(__pyx_builtin_ValueError);
      PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_builtin_ValueError);
      __pyx_t_16 = __Pyx_CalculateMetaclass(NULL, __pyx_t_15); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 44, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_17 = __Pyx_Py3MetaclassPrepare(__pyx_t_16, __pyx_t_15, __pyx_n_s_IndexOrValueError, __pyx_n_s_IndexOrValueError, (PyObject *) NULL, __pyx_n_s_cupy_core_core, (PyObject *) NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 44, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_17);

      /* "cupy/core/core.pyx":46
 *     class IndexOrValueError(IndexError, ValueError):
 * 
 *         def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *             super(IndexOrValueError, self).__init__(*args, **kwargs)
 * 
 */
      __pyx_t_18 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_17IndexOrValueError_1__init__, 0, __pyx_n_s_IndexOrValueError___init, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__222)); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 46, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_18);
      if (PyObject_SetItem(__pyx_t_17, __pyx_n_s_init, __pyx_t_18) < 0) __PYX_ERR(0, 46, __pyx_L10_except_error)
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

      /* "cupy/core/core.pyx":44
 *     _AxisError = numpy.AxisError
 * except AttributeError:
 *     class IndexOrValueError(IndexError, ValueError):             # <<<<<<<<<<<<<<
 * 
 *         def __init__(self, *args, **kwargs):
 */
      __pyx_t_18 = __Pyx_Py3ClassCreate(__pyx_t_16, __pyx_n_s_IndexOrValueError, __pyx_t_15, __pyx_t_17, NULL, 0, 1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 44, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_18);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_IndexOrValueError, __pyx_t_18) < 0) __PYX_ERR(0, 44, __pyx_L10_except_error)
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

      /* "cupy/core/core.pyx":49
 *             super(IndexOrValueError, self).__init__(*args, **kwargs)
 * 
 *     _AxisError = IndexOrValueError             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_IndexOrValueError); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 49, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_15);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_AxisError, __pyx_t_15) < 0) __PYX_ERR(0, 49, __pyx_L10_except_error)
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      goto __pyx_L9_exception_handled;
    }
    goto __pyx_L10_except_error;
    __pyx_L10_except_error:;

    /* "cupy/core/core.pyx":41
 * 
 * 
 * try:             # <<<<<<<<<<<<<<
 *     _AxisError = numpy.AxisError
 * except AttributeError:
 */
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_10);
    __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_10);
    goto __pyx_L1_error;
    __pyx_L9_exception_handled:;
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_10);
    __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_10);
    __pyx_L13_try_end:;
  }

  /* "cupy/core/core.pyx":85
 *     """
 * 
 *     def __init__(self, shape, dtype=float, memptr=None, order='C'):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t x
 *         self._shape = internal.get_size(shape)
 */
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __pyx_k_ = ((PyObject *)(&PyFloat_Type));
  __Pyx_GIVEREF((&PyFloat_Type));

  /* "cupy/core/core.pyx":214
 *             return self._transpose(vector.vector[Py_ssize_t]())
 * 
 *     __array_priority__ = 100             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray->tp_dict, __pyx_n_s_array_priority, __pyx_int_100) < 0) __PYX_ERR(0, 214, __pyx_L1_error)
  PyType_Modified(__pyx_ptype_4cupy_4core_4core_ndarray);

  /* "cupy/core/core.pyx":1652
 *         return int(self.get())
 * 
 *     if sys.version_info < (3,):             # <<<<<<<<<<<<<<
 *         def __long__(self):
 *             # Avoid using long() for flake8
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1652, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_version_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1652, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = PyObject_RichCompare(__pyx_t_9, __pyx_tuple__223, Py_LT); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1652, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 1652, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (__pyx_t_19) {

    /* "cupy/core/core.pyx":1653
 * 
 *     if sys.version_info < (3,):
 *         def __long__(self):             # <<<<<<<<<<<<<<
 *             # Avoid using long() for flake8
 *             return self.get().__long__()
 */
  }

  /* "cupy/core/core.pyx":1834
 * 
 * 
 * cdef object newaxis = numpy.newaxis  # == None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1834, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_newaxis); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1834, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core_newaxis);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core_newaxis, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/carray.pxi":1
 * import os             # <<<<<<<<<<<<<<
 * 
 * from cupy import cuda
 */
  __pyx_t_9 = __Pyx_Import(__pyx_n_s_os, 0, -1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_9) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/carray.pxi":3
 * import os
 * 
 * from cupy import cuda             # <<<<<<<<<<<<<<
 * 
 * from cupy.cuda cimport function
 */
  __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_n_s_cuda);
  __Pyx_GIVEREF(__pyx_n_s_cuda);
  PyList_SET_ITEM(__pyx_t_9, 0, __pyx_n_s_cuda);
  __pyx_t_14 = __Pyx_Import(__pyx_n_s_cupy, __pyx_t_9, -1); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_14, __pyx_n_s_cuda); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_cuda, __pyx_t_9) < 0) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/carray.pxi":8
 * from cupy.cuda cimport runtime
 * 
 * import warnings             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_14 = __Pyx_Import(__pyx_n_s_warnings, 0, -1); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_warnings, __pyx_t_14) < 0) __PYX_ERR(2, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/carray.pxi":66
 * 
 * 
 * cdef list _cupy_header_list = [             # <<<<<<<<<<<<<<
 *     'cupy/complex.cuh',
 *     'cupy/carray.cuh',
 */
  __pyx_t_14 = PyList_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_cuh);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_cuh);
  PyList_SET_ITEM(__pyx_t_14, 0, __pyx_kp_s_cupy_complex_cuh);
  __Pyx_INCREF(__pyx_kp_s_cupy_carray_cuh);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_carray_cuh);
  PyList_SET_ITEM(__pyx_t_14, 1, __pyx_kp_s_cupy_carray_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_14));
  __Pyx_GIVEREF(__pyx_t_14);
  __pyx_t_14 = 0;

  /* "cupy/core/carray.pxi":71
 * ]
 * cdef str _cupy_header = ''.join(
 *     ['#include <%s>\n' % i for i in _cupy_header_list])             # <<<<<<<<<<<<<<
 * 
 * # This is indirect include header list.
 */
  __pyx_t_14 = PyList_New(0); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  if (unlikely(__pyx_v_4cupy_4core_4core__cupy_header_list == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(2, 71, __pyx_L1_error)
  }
  __pyx_t_9 = __pyx_v_4cupy_4core_4core__cupy_header_list; __Pyx_INCREF(__pyx_t_9); __pyx_t_20 = 0;
  for (;;) {
    if (__pyx_t_20 >= PyList_GET_SIZE(__pyx_t_9)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_8 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_20); __Pyx_INCREF(__pyx_t_8); __pyx_t_20++; if (unlikely(0 < 0)) __PYX_ERR(2, 71, __pyx_L1_error)
    #else
    __pyx_t_8 = PySequence_ITEM(__pyx_t_9, __pyx_t_20); __pyx_t_20++; if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 71, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    #endif
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_i, __pyx_t_8) < 0) __PYX_ERR(2, 71, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_i); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 71, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_15 = __Pyx_PyString_Format(__pyx_kp_s_include_s, __pyx_t_8); if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 71, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_14, (PyObject*)__pyx_t_15))) __PYX_ERR(2, 71, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/carray.pxi":70
 *     'cupy/carray.cuh',
 * ]
 * cdef str _cupy_header = ''.join(             # <<<<<<<<<<<<<<
 *     ['#include <%s>\n' % i for i in _cupy_header_list])
 * 
 */
  __pyx_t_9 = __Pyx_PyString_Join(__pyx_kp_s__5, __pyx_t_14); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 70, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (!(likely(PyString_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_9)->tp_name), 0))) __PYX_ERR(2, 70, __pyx_L1_error)
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cupy_header);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cupy_header, ((PyObject*)__pyx_t_9));
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/carray.pxi":75
 * # 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_9 = PyList_New(20); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_complex_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_complex_h);
  PyList_SET_ITEM(__pyx_t_9, 0, __pyx_kp_s_cupy_complex_complex_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_math_private_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_math_private_h);
  PyList_SET_ITEM(__pyx_t_9, 1, __pyx_kp_s_cupy_complex_math_private_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_complex_inl_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_complex_inl_h);
  PyList_SET_ITEM(__pyx_t_9, 2, __pyx_kp_s_cupy_complex_complex_inl_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_arithmetic_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_arithmetic_h);
  PyList_SET_ITEM(__pyx_t_9, 3, __pyx_kp_s_cupy_complex_arithmetic_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_cproj_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_cproj_h);
  PyList_SET_ITEM(__pyx_t_9, 4, __pyx_kp_s_cupy_complex_cproj_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_cexp_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_cexp_h);
  PyList_SET_ITEM(__pyx_t_9, 5, __pyx_kp_s_cupy_complex_cexp_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_cexpf_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_cexpf_h);
  PyList_SET_ITEM(__pyx_t_9, 6, __pyx_kp_s_cupy_complex_cexpf_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_clog_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_clog_h);
  PyList_SET_ITEM(__pyx_t_9, 7, __pyx_kp_s_cupy_complex_clog_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_clogf_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_clogf_h);
  PyList_SET_ITEM(__pyx_t_9, 8, __pyx_kp_s_cupy_complex_clogf_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_cpow_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_cpow_h);
  PyList_SET_ITEM(__pyx_t_9, 9, __pyx_kp_s_cupy_complex_cpow_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_ccosh_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_ccosh_h);
  PyList_SET_ITEM(__pyx_t_9, 10, __pyx_kp_s_cupy_complex_ccosh_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_ccoshf_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_ccoshf_h);
  PyList_SET_ITEM(__pyx_t_9, 11, __pyx_kp_s_cupy_complex_ccoshf_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_csinh_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_csinh_h);
  PyList_SET_ITEM(__pyx_t_9, 12, __pyx_kp_s_cupy_complex_csinh_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_csinhf_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_csinhf_h);
  PyList_SET_ITEM(__pyx_t_9, 13, __pyx_kp_s_cupy_complex_csinhf_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_ctanh_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_ctanh_h);
  PyList_SET_ITEM(__pyx_t_9, 14, __pyx_kp_s_cupy_complex_ctanh_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_ctanhf_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_ctanhf_h);
  PyList_SET_ITEM(__pyx_t_9, 15, __pyx_kp_s_cupy_complex_ctanhf_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_csqrt_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_csqrt_h);
  PyList_SET_ITEM(__pyx_t_9, 16, __pyx_kp_s_cupy_complex_csqrt_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_csqrtf_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_csqrtf_h);
  PyList_SET_ITEM(__pyx_t_9, 17, __pyx_kp_s_cupy_complex_csqrtf_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_catrig_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_catrig_h);
  PyList_SET_ITEM(__pyx_t_9, 18, __pyx_kp_s_cupy_complex_catrig_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_catrigf_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_catrigf_h);
  PyList_SET_ITEM(__pyx_t_9, 19, __pyx_kp_s_cupy_complex_catrigf_h);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cupy_extra_header_list);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cupy_extra_header_list, ((PyObject*)__pyx_t_9));
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/carray.pxi":98
 * ]
 * 
 * cdef str _header_path_cache = None             # <<<<<<<<<<<<<<
 * cdef str _header_source = None
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__header_path_cache);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__header_path_cache, ((PyObject*)Py_None));
  __Pyx_GIVEREF(Py_None);

  /* "cupy/core/carray.pxi":99
 * 
 * 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/carray.pxi":124
 * 
 * 
 * cdef str _cuda_path = None             # <<<<<<<<<<<<<<
 * 
 * cpdef str _get_cuda_path():
 */
  __Pyx_INCREF(Py_None);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cuda_path);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cuda_path, ((PyObject*)Py_None));
  __Pyx_GIVEREF(Py_None);

  /* "cupy/core/elementwise.pxi":1
 * import string             # <<<<<<<<<<<<<<
 * 
 * import numpy
 */
  __pyx_t_9 = __Pyx_Import(__pyx_n_s_string, 0, -1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_string, __pyx_t_9) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":3
 * import string
 * 
 * import numpy             # <<<<<<<<<<<<<<
 * import six
 * 
 */
  __pyx_t_9 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_9) < 0) __PYX_ERR(1, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":4
 * 
 * import numpy
 * import six             # <<<<<<<<<<<<<<
 * 
 * from cupy.cuda import compiler
 */
  __pyx_t_9 = __Pyx_Import(__pyx_n_s_six, 0, -1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_six, __pyx_t_9) < 0) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":6
 * import six
 * 
 * from cupy.cuda import compiler             # <<<<<<<<<<<<<<
 * from cupy import util
 * 
 */
  __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_n_s_compiler);
  __Pyx_GIVEREF(__pyx_n_s_compiler);
  PyList_SET_ITEM(__pyx_t_9, 0, __pyx_n_s_compiler);
  __pyx_t_14 = __Pyx_Import(__pyx_n_s_cupy_cuda, __pyx_t_9, -1); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_14, __pyx_n_s_compiler); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_compiler, __pyx_t_9) < 0) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/elementwise.pxi":7
 * 
 * from cupy.cuda import compiler
 * from cupy import util             # <<<<<<<<<<<<<<
 * 
 * from cupy.cuda cimport device
 */
  __pyx_t_14 = PyList_New(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_INCREF(__pyx_n_s_util);
  __Pyx_GIVEREF(__pyx_n_s_util);
  PyList_SET_ITEM(__pyx_t_14, 0, __pyx_n_s_util);
  __pyx_t_9 = __Pyx_Import(__pyx_n_s_cupy, __pyx_t_14, -1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_util); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_util, __pyx_t_14) < 0) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":38
 * 
 * cdef dict _typenames_base = {
 *     numpy.dtype('float64'): 'double',             # <<<<<<<<<<<<<<
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',
 */
  __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__224, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_t_9, __pyx_t_14, __pyx_n_s_double) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/elementwise.pxi":39
 * cdef dict _typenames_base = {
 *     numpy.dtype('float64'): 'double',
 *     numpy.dtype('float32'): 'float',             # <<<<<<<<<<<<<<
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('complex128'): 'complex<double>',
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__225, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_t_9, __pyx_t_14, __pyx_n_s_float) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/elementwise.pxi":40
 *     numpy.dtype('float64'): 'double',
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',             # <<<<<<<<<<<<<<
 *     numpy.dtype('complex128'): 'complex<double>',
 *     numpy.dtype('complex64'): 'complex<float>',
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__226, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_t_9, __pyx_t_14, __pyx_n_s_float16) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/elementwise.pxi":41
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('complex128'): 'complex<double>',             # <<<<<<<<<<<<<<
 *     numpy.dtype('complex64'): 'complex<float>',
 *     numpy.dtype('int64'): 'long long',
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__227, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_t_9, __pyx_t_14, __pyx_kp_s_complex_double) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/elementwise.pxi":42
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('complex128'): 'complex<double>',
 *     numpy.dtype('complex64'): 'complex<float>',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__228, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_t_9, __pyx_t_14, __pyx_kp_s_complex_float) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/elementwise.pxi":43
 *     numpy.dtype('complex128'): 'complex<double>',
 *     numpy.dtype('complex64'): 'complex<float>',
 *     numpy.dtype('int64'): 'long long',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int32'): 'int',
 *     numpy.dtype('int16'): 'short',
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__229, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_t_9, __pyx_t_14, __pyx_kp_s_long_long) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/elementwise.pxi":44
 *     numpy.dtype('complex64'): 'complex<float>',
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int16'): 'short',
 *     numpy.dtype('int8'): 'signed char',
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__230, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_t_9, __pyx_t_14, __pyx_n_s_int) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/elementwise.pxi":45
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',
 *     numpy.dtype('int16'): 'short',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int8'): 'signed char',
 *     numpy.dtype('uint64'): 'unsigned long long',
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__231, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_t_9, __pyx_t_14, __pyx_n_s_short) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/elementwise.pxi":46
 *     numpy.dtype('int32'): 'int',
 *     numpy.dtype('int16'): 'short',
 *     numpy.dtype('int8'): 'signed char',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint64'): 'unsigned long long',
 *     numpy.dtype('uint32'): 'unsigned int',
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__232, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_t_9, __pyx_t_14, __pyx_kp_s_signed_char) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/elementwise.pxi":47
 *     numpy.dtype('int16'): 'short',
 *     numpy.dtype('int8'): 'signed char',
 *     numpy.dtype('uint64'): 'unsigned long long',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint32'): 'unsigned int',
 *     numpy.dtype('uint16'): 'unsigned short',
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__233, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_t_9, __pyx_t_14, __pyx_kp_s_unsigned_long_long) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/elementwise.pxi":48
 *     numpy.dtype('int8'): 'signed char',
 *     numpy.dtype('uint64'): 'unsigned long long',
 *     numpy.dtype('uint32'): 'unsigned int',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__234, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_t_9, __pyx_t_14, __pyx_kp_s_unsigned_int) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/elementwise.pxi":49
 *     numpy.dtype('uint64'): 'unsigned long long',
 *     numpy.dtype('uint32'): 'unsigned int',
 *     numpy.dtype('uint16'): 'unsigned short',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint8'): 'unsigned char',
 *     numpy.dtype('bool'): 'bool',
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__235, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_t_9, __pyx_t_14, __pyx_kp_s_unsigned_short) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/elementwise.pxi":50
 *     numpy.dtype('uint32'): 'unsigned int',
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',             # <<<<<<<<<<<<<<
 *     numpy.dtype('bool'): 'bool',
 * }
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__236, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_t_9, __pyx_t_14, __pyx_kp_s_unsigned_char) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/elementwise.pxi":51
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',
 *     numpy.dtype('bool'): 'bool',             # <<<<<<<<<<<<<<
 * }
 * 
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__237, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_t_9, __pyx_t_14, __pyx_n_s_bool_2) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__typenames_base);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__typenames_base, ((PyObject*)__pyx_t_9));
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":54
 * }
 * 
 * cdef str _all_type_chars = 'dfDFeqlihbQLIHB?'             # <<<<<<<<<<<<<<
 * # for c in 'dDfFeqlihbQLIHB?':
 * #    print('#', c, '...', np.dtype(c).name)
 */
  __Pyx_INCREF(__pyx_kp_s_dfDFeqlihbQLIHB);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__all_type_chars);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__all_type_chars, __pyx_kp_s_dfDFeqlihbQLIHB);
  __Pyx_GIVEREF(__pyx_kp_s_dfDFeqlihbQLIHB);

  /* "cupy/core/elementwise.pxi":74
 * # ? ... bool
 * 
 * cdef dict _typenames = {             # <<<<<<<<<<<<<<
 *     numpy.dtype(i).type: _typenames_base[numpy.dtype(i)]
 *     for i in _all_type_chars}
 */
  { /* enter inner scope */
    PyObject *__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i = NULL;
    __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 74, __pyx_L21_error)
    __Pyx_GOTREF(__pyx_t_9);

    /* "cupy/core/elementwise.pxi":76
 * cdef dict _typenames = {
 *     numpy.dtype(i).type: _typenames_base[numpy.dtype(i)]
 *     for i in _all_type_chars}             # <<<<<<<<<<<<<<
 * 
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool, complex)
 */
    __pyx_t_14 = PyObject_GetIter(__pyx_v_4cupy_4core_4core__all_type_chars); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 76, __pyx_L21_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_21 = Py_TYPE(__pyx_t_14)->tp_iternext; if (unlikely(!__pyx_t_21)) __PYX_ERR(1, 76, __pyx_L21_error)
    for (;;) {
      {
        __pyx_t_15 = __pyx_t_21(__pyx_t_14);
        if (unlikely(!__pyx_t_15)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(1, 76, __pyx_L21_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_15);
      }
      __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i, __pyx_t_15);
      __pyx_t_15 = 0;

      /* "cupy/core/elementwise.pxi":75
 * 
 * cdef dict _typenames = {
 *     numpy.dtype(i).type: _typenames_base[numpy.dtype(i)]             # <<<<<<<<<<<<<<
 *     for i in _all_type_chars}
 * 
 */
      __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 75, __pyx_L21_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dtype); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 75, __pyx_L21_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_16);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_16, function);
        }
      }
      if (!__pyx_t_8) {
        __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 75, __pyx_L21_error)
        __Pyx_GOTREF(__pyx_t_15);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_16)) {
          PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i};
          __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_16, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 75, __pyx_L21_error)
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_15);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_16)) {
          PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i};
          __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_16, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 75, __pyx_L21_error)
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_15);
        } else
        #endif
        {
          __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 75, __pyx_L21_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_8); __pyx_t_8 = NULL;
          __Pyx_INCREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
          __Pyx_GIVEREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
          PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
          __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_17, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 75, __pyx_L21_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_type); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 75, __pyx_L21_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      if (unlikely(__pyx_v_4cupy_4core_4core__typenames_base == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(1, 75, __pyx_L21_error)
      }
      __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 75, __pyx_L21_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 75, __pyx_L21_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_t_17 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_17)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_17);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (!__pyx_t_17) {
        __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 75, __pyx_L21_error)
        __Pyx_GOTREF(__pyx_t_15);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i};
          __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 75, __pyx_L21_error)
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_GOTREF(__pyx_t_15);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i};
          __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 75, __pyx_L21_error)
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_GOTREF(__pyx_t_15);
        } else
        #endif
        {
          __pyx_t_18 = PyTuple_New(1+1); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 75, __pyx_L21_error)
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_17); __pyx_t_17 = NULL;
          __Pyx_INCREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
          __Pyx_GIVEREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
          PyTuple_SET_ITEM(__pyx_t_18, 0+1, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
          __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_18, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 75, __pyx_L21_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyDict_GetItem(__pyx_v_4cupy_4core_4core__typenames_base, __pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 75, __pyx_L21_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      if (unlikely(PyDict_SetItem(__pyx_t_9, (PyObject*)__pyx_t_16, (PyObject*)__pyx_t_8))) __PYX_ERR(1, 75, __pyx_L21_error)
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cupy/core/elementwise.pxi":76
 * cdef dict _typenames = {
 *     numpy.dtype(i).type: _typenames_base[numpy.dtype(i)]
 *     for i in _all_type_chars}             # <<<<<<<<<<<<<<
 * 
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool, complex)
 */
    }
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
    goto __pyx_L24_exit_scope;
    __pyx_L21_error:;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
    goto __pyx_L1_error;
    __pyx_L24_exit_scope:;
  } /* exit inner scope */
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__typenames);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__typenames, ((PyObject*)__pyx_t_9));
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":78
 *     for i in _all_type_chars}
 * 
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool, complex)             # <<<<<<<<<<<<<<
 * cdef tuple _numpy_scalar_type = tuple([numpy.dtype(i).type
 *                                        for i in _all_type_chars])
 */
  __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 78, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_integer_types); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 78, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 78, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)(&PyFloat_Type)));
  __Pyx_INCREF(((PyObject*)&PyBool_Type));
  __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
  PyTuple_SET_ITEM(__pyx_t_9, 1, ((PyObject*)&PyBool_Type));
  __Pyx_INCREF(((PyObject *)(&PyComplex_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyComplex_Type)));
  PyTuple_SET_ITEM(__pyx_t_9, 2, ((PyObject *)(&PyComplex_Type)));
  __pyx_t_8 = PyNumber_Add(__pyx_t_14, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 78, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_8))||((__pyx_t_8) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_8)->tp_name), 0))) __PYX_ERR(1, 78, __pyx_L1_error)
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__python_scalar_type);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__python_scalar_type, ((PyObject*)__pyx_t_8));
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":79
 * 
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool, complex)
 * cdef tuple _numpy_scalar_type = tuple([numpy.dtype(i).type             # <<<<<<<<<<<<<<
 *                                        for i in _all_type_chars])
 * 
 */
  __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 79, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "cupy/core/elementwise.pxi":80
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool, complex)
 * cdef tuple _numpy_scalar_type = tuple([numpy.dtype(i).type
 *                                        for i in _all_type_chars])             # <<<<<<<<<<<<<<
 * 
 * cdef set _python_scalar_type_set = set(_python_scalar_type)
 */
  __pyx_t_9 = PyObject_GetIter(__pyx_v_4cupy_4core_4core__all_type_chars); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 80, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_21 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_21)) __PYX_ERR(1, 80, __pyx_L1_error)
  for (;;) {
    {
      __pyx_t_14 = __pyx_t_21(__pyx_t_9);
      if (unlikely(!__pyx_t_14)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 80, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_14);
    }
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_i, __pyx_t_14) < 0) __PYX_ERR(1, 80, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

    /* "cupy/core/elementwise.pxi":79
 * 
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool, complex)
 * cdef tuple _numpy_scalar_type = tuple([numpy.dtype(i).type             # <<<<<<<<<<<<<<
 *                                        for i in _all_type_chars])
 * 
 */
    __pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 79, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 79, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s_i); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 79, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_18 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
      __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_15);
      if (likely(__pyx_t_18)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
        __Pyx_INCREF(__pyx_t_18);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_15, function);
      }
    }
    if (!__pyx_t_18) {
      __pyx_t_14 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_16); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 79, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_GOTREF(__pyx_t_14);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_15)) {
        PyObject *__pyx_temp[2] = {__pyx_t_18, __pyx_t_16};
        __pyx_t_14 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 79, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
        PyObject *__pyx_temp[2] = {__pyx_t_18, __pyx_t_16};
        __pyx_t_14 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 79, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      } else
      #endif
      {
        __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 79, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_18); __pyx_t_18 = NULL;
        __Pyx_GIVEREF(__pyx_t_16);
        PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_16);
        __pyx_t_16 = 0;
        __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_17, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 79, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_type); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 79, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_8, (PyObject*)__pyx_t_15))) __PYX_ERR(1, 79, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

    /* "cupy/core/elementwise.pxi":80
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool, complex)
 * cdef tuple _numpy_scalar_type = tuple([numpy.dtype(i).type
 *                                        for i in _all_type_chars])             # <<<<<<<<<<<<<<
 * 
 * cdef set _python_scalar_type_set = set(_python_scalar_type)
 */
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":79
 * 
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool, complex)
 * cdef tuple _numpy_scalar_type = tuple([numpy.dtype(i).type             # <<<<<<<<<<<<<<
 *                                        for i in _all_type_chars])
 * 
 */
  __pyx_t_9 = PyList_AsTuple(((PyObject*)__pyx_t_8)); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 79, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__numpy_scalar_type);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__numpy_scalar_type, ((PyObject*)__pyx_t_9));
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":82
 *                                        for i in _all_type_chars])
 * 
 * cdef set _python_scalar_type_set = set(_python_scalar_type)             # <<<<<<<<<<<<<<
 * cdef set _numpy_scalar_type_set = set(_numpy_scalar_type)
 * 
 */
  __pyx_t_9 = PySet_New(__pyx_v_4cupy_4core_4core__python_scalar_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 82, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__python_scalar_type_set);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__python_scalar_type_set, ((PyObject*)__pyx_t_9));
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":83
 * 
 * cdef set _python_scalar_type_set = set(_python_scalar_type)
 * cdef set _numpy_scalar_type_set = set(_numpy_scalar_type)             # <<<<<<<<<<<<<<
 * 
 * cdef dict _kind_score = {
 */
  __pyx_t_9 = PySet_New(__pyx_v_4cupy_4core_4core__numpy_scalar_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__numpy_scalar_type_set);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__numpy_scalar_type_set, ((PyObject*)__pyx_t_9));
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":86
 * 
 * cdef dict _kind_score = {
 *     'b': 0,             # <<<<<<<<<<<<<<
 *     'u': 1,
 *     'i': 1,
 */
  __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_b, __pyx_int_0) < 0) __PYX_ERR(1, 86, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_u, __pyx_int_1) < 0) __PYX_ERR(1, 86, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_i, __pyx_int_1) < 0) __PYX_ERR(1, 86, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_f, __pyx_int_2) < 0) __PYX_ERR(1, 86, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_c, __pyx_int_3) < 0) __PYX_ERR(1, 86, __pyx_L1_error)
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__kind_score);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__kind_score, ((PyObject*)__pyx_t_9));
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":95
 * 
 * cdef dict _python_type_to_numpy_type = {
 *     float: numpy.dtype(float).type,             # <<<<<<<<<<<<<<
 *     complex: numpy.dtype(complex).type,
 *     bool: numpy.dtype(bool).type,
 */
  __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 95, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 95, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_dtype); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 95, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_14, function);
    }
  }
  if (!__pyx_t_15) {
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_14, ((PyObject *)(&PyFloat_Type))); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 95, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_14)) {
      PyObject *__pyx_temp[2] = {__pyx_t_15, ((PyObject *)(&PyFloat_Type))};
      __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 95, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_GOTREF(__pyx_t_8);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
      PyObject *__pyx_temp[2] = {__pyx_t_15, ((PyObject *)(&PyFloat_Type))};
      __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 95, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_GOTREF(__pyx_t_8);
    } else
    #endif
    {
      __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 95, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_15); __pyx_t_15 = NULL;
      __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
      PyTuple_SET_ITEM(__pyx_t_17, 0+1, ((PyObject *)(&PyFloat_Type)));
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_17, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 95, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_type); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 95, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_9, ((PyObject *)(&PyFloat_Type)), __pyx_t_14) < 0) __PYX_ERR(1, 95, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "cupy/core/elementwise.pxi":96
 * cdef dict _python_type_to_numpy_type = {
 *     float: numpy.dtype(float).type,
 *     complex: numpy.dtype(complex).type,             # <<<<<<<<<<<<<<
 *     bool: numpy.dtype(bool).type,
 * }
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 96, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dtype); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 96, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_17))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_17);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_17, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_14 = __Pyx_PyObject_CallOneArg(__pyx_t_17, ((PyObject *)(&PyComplex_Type))); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 96, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_17)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, ((PyObject *)(&PyComplex_Type))};
      __pyx_t_14 = __Pyx_PyFunction_FastCall(__pyx_t_17, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 96, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_14);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_17)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, ((PyObject *)(&PyComplex_Type))};
      __pyx_t_14 = __Pyx_PyCFunction_FastCall(__pyx_t_17, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 96, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_14);
    } else
    #endif
    {
      __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 96, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_INCREF(((PyObject *)(&PyComplex_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyComplex_Type)));
      PyTuple_SET_ITEM(__pyx_t_15, 0+1, ((PyObject *)(&PyComplex_Type)));
      __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_15, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 96, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_type); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 96, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (PyDict_SetItem(__pyx_t_9, ((PyObject *)(&PyComplex_Type)), __pyx_t_17) < 0) __PYX_ERR(1, 95, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/elementwise.pxi":97
 *     float: numpy.dtype(float).type,
 *     complex: numpy.dtype(complex).type,
 *     bool: numpy.dtype(bool).type,             # <<<<<<<<<<<<<<
 * }
 * 
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 97, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 97, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_15);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_15, function);
    }
  }
  if (!__pyx_t_14) {
    __pyx_t_17 = __Pyx_PyObject_CallOneArg(__pyx_t_15, ((PyObject*)&PyBool_Type)); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 97, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, ((PyObject*)&PyBool_Type)};
      __pyx_t_17 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 97, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_17);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, ((PyObject*)&PyBool_Type)};
      __pyx_t_17 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 97, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_17);
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 97, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_14); __pyx_t_14 = NULL;
      __Pyx_INCREF(((PyObject*)&PyBool_Type));
      __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, ((PyObject*)&PyBool_Type));
      __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_8, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 97, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_type); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 97, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  if (PyDict_SetItem(__pyx_t_9, ((PyObject*)&PyBool_Type), __pyx_t_15) < 0) __PYX_ERR(1, 95, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__python_type_to_numpy_type);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__python_type_to_numpy_type, ((PyObject*)__pyx_t_9));
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":289
 * 
 * 
 * @util.memoize()             # <<<<<<<<<<<<<<
 * def _get_param_info(s, is_const):
 *     if len(s) == 0:
 */
  __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 289, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_memoize); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 289, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __pyx_t_17 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_17)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_17);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (__pyx_t_17) {
    __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_17); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 289, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  } else {
    __pyx_t_15 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 289, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":290
 * 
 * @util.memoize()
 * def _get_param_info(s, is_const):             # <<<<<<<<<<<<<<
 *     if len(s) == 0:
 *         return ()
 */
  __pyx_t_8 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_25_get_param_info, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_17 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
    __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_15);
    if (likely(__pyx_t_17)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_17);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_15, function);
    }
  }
  if (!__pyx_t_17) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 289, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_t_8};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 289, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_t_8};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 289, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 289, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_17); __pyx_t_17 = NULL;
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_14, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 289, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_param_info, __pyx_t_9) < 0) __PYX_ERR(1, 290, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":296
 * 
 * 
 * @util.memoize()             # <<<<<<<<<<<<<<
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):
 *     type_dict = {}
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_memoize); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (__pyx_t_14) {
    __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 296, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  } else {
    __pyx_t_15 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 296, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":297
 * 
 * @util.memoize()
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):             # <<<<<<<<<<<<<<
 *     type_dict = {}
 *     if out_args_dtype:
 */
  __pyx_t_8 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_27_decide_params_type, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_15);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_15, function);
    }
  }
  if (!__pyx_t_14) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 296, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_8};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 296, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_8};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 296, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 296, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_14); __pyx_t_14 = NULL;
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_17, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 296, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_decide_params_type, __pyx_t_9) < 0) __PYX_ERR(1, 297, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":422
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_elementwise_kernel(args_info, types, params, operation, name,
 *                             preamble, kwargs):
 */
  __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_memoize); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_15 = PyDict_New(); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(1, 422, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_empty_tuple, __pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/elementwise.pxi":423
 * 
 * @util.memoize(for_each_device=True)
 * def _get_elementwise_kernel(args_info, types, params, operation, name,             # <<<<<<<<<<<<<<
 *                             preamble, kwargs):
 *     kernel_params = _get_kernel_params(params, args_info)
 */
  __pyx_t_15 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_29_get_elementwise_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_17 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_17)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_17);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_17) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_15); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 422, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_t_15};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 422, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_t_15};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 422, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    } else
    #endif
    {
      __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 422, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_17); __pyx_t_17 = NULL;
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_15);
      __pyx_t_15 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_14, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 422, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_elementwise_kernel, __pyx_t_9) < 0) __PYX_ERR(1, 423, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":597
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_ufunc_kernel(
 *         in_types, out_types, routine, args_info, params, name, preamble):
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_memoize); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(1, 597, __pyx_L1_error)
  __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_empty_tuple, __pyx_t_8); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":598
 * 
 * @util.memoize(for_each_device=True)
 * def _get_ufunc_kernel(             # <<<<<<<<<<<<<<
 *         in_types, out_types, routine, args_info, params, name, preamble):
 *     kernel_params = _get_kernel_params(params, args_info)
 */
  __pyx_t_8 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_31_get_ufunc_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_15);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_15, function);
    }
  }
  if (!__pyx_t_14) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 597, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_8};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 597, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_8};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 597, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 597, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_14); __pyx_t_14 = NULL;
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_17, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 597, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_ufunc_kernel, __pyx_t_9) < 0) __PYX_ERR(1, 598, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":699
 * 
 * 
 * class ufunc(object):             # <<<<<<<<<<<<<<
 * 
 *     """Universal function.
 */
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 699, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_builtin_object);
  __Pyx_GIVEREF(__pyx_builtin_object);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_builtin_object);
  __pyx_t_15 = __Pyx_CalculateMetaclass(NULL, __pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 699, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_17 = __Pyx_Py3MetaclassPrepare(__pyx_t_15, __pyx_t_9, __pyx_n_s_ufunc, __pyx_n_s_ufunc, (PyObject *) NULL, __pyx_n_s_cupy_core_core, __pyx_kp_s_Universal_function_Attributes_uf); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 699, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);

  /* "cupy/core/elementwise.pxi":711
 *     """
 * 
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                  default_casting=None):
 *         self.name = name
 */
  __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_5ufunc_1__init__, 0, __pyx_n_s_ufunc___init, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__247)); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 711, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_tuple__248);
  if (PyObject_SetItem(__pyx_t_17, __pyx_n_s_init, __pyx_t_8) < 0) __PYX_ERR(1, 711, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":734
 *         self._routine_cache = {}
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<ufunc '%s'>" % self.name
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_5ufunc_3__repr__, 0, __pyx_n_s_ufunc___repr, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__250)); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 734, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyObject_SetItem(__pyx_t_17, __pyx_n_s_repr, __pyx_t_8) < 0) __PYX_ERR(1, 734, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":738
 * 
 *     @property
 *     def types(self):             # <<<<<<<<<<<<<<
 *         """A list of type signatures.
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_5ufunc_5types, 0, __pyx_n_s_ufunc_types, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__253)); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 738, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "cupy/core/elementwise.pxi":737
 *         return "<ufunc '%s'>" % self.name
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def types(self):
 *         """A list of type signatures.
 */
  __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 737, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_8);
  __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_property, __pyx_t_14, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 737, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (PyObject_SetItem(__pyx_t_17, __pyx_n_s_types, __pyx_t_8) < 0) __PYX_ERR(1, 738, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":752
 *         return types
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Applies the universal function to arguments elementwise.
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_5ufunc_7__call__, 0, __pyx_n_s_ufunc___call, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__255)); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 752, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyObject_SetItem(__pyx_t_17, __pyx_n_s_call, __pyx_t_8) < 0) __PYX_ERR(1, 752, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":699
 * 
 * 
 * class ufunc(object):             # <<<<<<<<<<<<<<
 * 
 *     """Universal function.
 */
  __pyx_t_8 = __Pyx_Py3ClassCreate(__pyx_t_15, __pyx_n_s_ufunc, __pyx_t_9, __pyx_t_17, NULL, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 699, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ufunc, __pyx_t_8) < 0) __PYX_ERR(1, 699, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":1
 * import collections             # <<<<<<<<<<<<<<
 * import string
 * 
 */
  __pyx_t_9 = __Pyx_Import(__pyx_n_s_collections, 0, -1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_collections, __pyx_t_9) < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":2
 * import collections
 * import string             # <<<<<<<<<<<<<<
 * 
 * import numpy
 */
  __pyx_t_9 = __Pyx_Import(__pyx_n_s_string, 0, -1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_string, __pyx_t_9) < 0) __PYX_ERR(5, 2, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":4
 * import string
 * 
 * import numpy             # <<<<<<<<<<<<<<
 * 
 * from cupy.cuda import compiler
 */
  __pyx_t_9 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_9) < 0) __PYX_ERR(5, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":6
 * import numpy
 * 
 * from cupy.cuda import compiler             # <<<<<<<<<<<<<<
 * from cupy import util
 * 
 */
  __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_n_s_compiler);
  __Pyx_GIVEREF(__pyx_n_s_compiler);
  PyList_SET_ITEM(__pyx_t_9, 0, __pyx_n_s_compiler);
  __pyx_t_15 = __Pyx_Import(__pyx_n_s_cupy_cuda, __pyx_t_9, -1); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_15, __pyx_n_s_compiler); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_compiler, __pyx_t_9) < 0) __PYX_ERR(5, 6, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/reduction.pxi":7
 * 
 * from cupy.cuda import compiler
 * from cupy import util             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_15 = PyList_New(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_INCREF(__pyx_n_s_util);
  __Pyx_GIVEREF(__pyx_n_s_util);
  PyList_SET_ITEM(__pyx_t_15, 0, __pyx_n_s_util);
  __pyx_t_9 = __Pyx_Import(__pyx_n_s_cupy, __pyx_t_15, -1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_15 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_util); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_util, __pyx_t_15) < 0) __PYX_ERR(5, 7, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":165
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_simple_reduction_function(
 *         routine, params, args_info, in_arg_dtype, out_arg_dtype, out_types,
 */
  __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_memoize); if (unlikely(!__pyx_t_17)) __PYX_ERR(5, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_15 = PyDict_New(); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(5, 165, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_empty_tuple, __pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/reduction.pxi":166
 * 
 * @util.memoize(for_each_device=True)
 * def _get_simple_reduction_function(             # <<<<<<<<<<<<<<
 *         routine, params, args_info, in_arg_dtype, out_arg_dtype, out_types,
 *         name, block_size, identity, input_expr, output_expr, _preamble,
 */
  __pyx_t_15 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_45_get_simple_reduction_function, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_17 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_17)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_17);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_17) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_15); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 165, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_t_15};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 165, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_t_15};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 165, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    } else
    #endif
    {
      __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 165, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_17); __pyx_t_17 = NULL;
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_15);
      __pyx_t_15 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_14, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 165, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_simple_reduction_function, __pyx_t_9) < 0) __PYX_ERR(5, 166, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":184
 * 
 * 
 * class simple_reduction_function(object):             # <<<<<<<<<<<<<<
 * 
 *     _block_size = 512
 */
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 184, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_builtin_object);
  __Pyx_GIVEREF(__pyx_builtin_object);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_builtin_object);
  __pyx_t_8 = __Pyx_CalculateMetaclass(NULL, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 184, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_14 = __Pyx_Py3MetaclassPrepare(__pyx_t_8, __pyx_t_9, __pyx_n_s_simple_reduction_function, __pyx_n_s_simple_reduction_function, (PyObject *) NULL, __pyx_n_s_cupy_core_core, (PyObject *) NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 184, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);

  /* "cupy/core/reduction.pxi":186
 * class simple_reduction_function(object):
 * 
 *     _block_size = 512             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, name, ops, identity, preamble):
 */
  if (PyObject_SetItem(__pyx_t_14, __pyx_n_s_block_size_2, __pyx_int_512) < 0) __PYX_ERR(5, 186, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":188
 *     _block_size = 512
 * 
 *     def __init__(self, name, ops, identity, preamble):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self._ops = ops
 */
  __pyx_t_15 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_25simple_reduction_function_1__init__, 0, __pyx_n_s_simple_reduction_function___init, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__259)); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyObject_SetItem(__pyx_t_14, __pyx_n_s_init, __pyx_t_15) < 0) __PYX_ERR(5, 188, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/reduction.pxi":207
 * 
 *     def __call__(self, ndarray a, axis=None, dtype=None, ndarray out=None,
 *                  bint keepdims=False):             # <<<<<<<<<<<<<<
 *         cdef list in_args, out_args
 *         cdef tuple in_sahpe, laxis, raxis
 */
  __pyx_t_15 = __Pyx_PyBool_FromLong(((int)0)); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);

  /* "cupy/core/reduction.pxi":206
 *         self._routine_cache = {}
 * 
 *     def __call__(self, ndarray a, axis=None, dtype=None, ndarray out=None,             # <<<<<<<<<<<<<<
 *                  bint keepdims=False):
 *         cdef list in_args, out_args
 */
  __pyx_t_17 = PyTuple_New(4); if (unlikely(!__pyx_t_17)) __PYX_ERR(5, 206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_INCREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_t_17, 0, ((PyObject *)Py_None));
  __Pyx_INCREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_t_17, 1, ((PyObject *)Py_None));
  __Pyx_INCREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_t_17, 2, ((PyObject *)Py_None));
  __Pyx_GIVEREF(__pyx_t_15);
  PyTuple_SET_ITEM(__pyx_t_17, 3, __pyx_t_15);
  __pyx_t_15 = 0;
  __pyx_t_15 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_25simple_reduction_function_3__call__, 0, __pyx_n_s_simple_reduction_function___call, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__261)); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_15, __pyx_t_17);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  if (PyObject_SetItem(__pyx_t_14, __pyx_n_s_call, __pyx_t_15) < 0) __PYX_ERR(5, 206, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/reduction.pxi":184
 * 
 * 
 * class simple_reduction_function(object):             # <<<<<<<<<<<<<<
 * 
 *     _block_size = 512
 */
  __pyx_t_15 = __Pyx_Py3ClassCreate(__pyx_t_8, __pyx_n_s_simple_reduction_function, __pyx_t_9, __pyx_t_14, NULL, 0, 1); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 184, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_simple_reduction_function, __pyx_t_15) < 0) __PYX_ERR(5, 184, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":272
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_reduction_kernel(
 *         params, args_info, types,
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_memoize); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(5, 272, __pyx_L1_error)
  __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_empty_tuple, __pyx_t_8); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/reduction.pxi":273
 * 
 * @util.memoize(for_each_device=True)
 * def _get_reduction_kernel(             # <<<<<<<<<<<<<<
 *         params, args_info, types,
 *         name, block_size, reduce_type, identity, map_expr, reduce_expr,
 */
  __pyx_t_8 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_47_get_reduction_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_15);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_15, function);
    }
  }
  if (!__pyx_t_14) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 272, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_8};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 272, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_8};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 272, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(5, 272, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_14); __pyx_t_14 = NULL;
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_17, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 272, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_reduction_kernel, __pyx_t_9) < 0) __PYX_ERR(5, 273, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":296
 * 
 * 
 * class ReductionKernel(object):             # <<<<<<<<<<<<<<
 * 
 *     """User-defined reduction kernel.
 */
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_builtin_object);
  __Pyx_GIVEREF(__pyx_builtin_object);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_builtin_object);
  __pyx_t_15 = __Pyx_CalculateMetaclass(NULL, __pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_17 = __Pyx_Py3MetaclassPrepare(__pyx_t_15, __pyx_t_9, __pyx_n_s_ReductionKernel, __pyx_n_s_ReductionKernel, (PyObject *) NULL, __pyx_n_s_cupy_core_core, __pyx_kp_s_User_defined_reduction_kernel_Th); if (unlikely(!__pyx_t_17)) __PYX_ERR(5, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);

  /* "cupy/core/reduction.pxi":327
 * 
 *     """
 *     def __init__(self, in_params, out_params,             # <<<<<<<<<<<<<<
 *                  map_expr, reduce_expr, post_map_expr,
 *                  identity, name='reduce_kernel', reduce_type=None,
 */
  __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_15ReductionKernel_1__init__, 0, __pyx_n_s_ReductionKernel___init, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__265)); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_tuple__266);
  if (PyObject_SetItem(__pyx_t_17, __pyx_n_s_init, __pyx_t_8) < 0) __PYX_ERR(5, 327, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/reduction.pxi":357
 *         self.preamble = preamble
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Compiles and invokes the reduction kernel.
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_15ReductionKernel_3__call__, 0, __pyx_n_s_ReductionKernel___call, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__268)); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyObject_SetItem(__pyx_t_17, __pyx_n_s_call, __pyx_t_8) < 0) __PYX_ERR(5, 357, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/reduction.pxi":296
 * 
 * 
 * class ReductionKernel(object):             # <<<<<<<<<<<<<<
 * 
 *     """User-defined reduction kernel.
 */
  __pyx_t_8 = __Pyx_Py3ClassCreate(__pyx_t_15, __pyx_n_s_ReductionKernel, __pyx_t_9, __pyx_t_17, NULL, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ReductionKernel, __pyx_t_8) < 0) __PYX_ERR(5, 296, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":1882
 * # =============================================================================
 * 
 * cdef _id = 'out0 = in0'             # <<<<<<<<<<<<<<
 * 
 * elementwise_copy = create_ufunc(
 */
  __Pyx_INCREF(__pyx_kp_s_out0_in0);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__id);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__id, __pyx_kp_s_out0_in0);
  __Pyx_GIVEREF(__pyx_kp_s_out0_in0);

  /* "cupy/core/core.pyx":1884
 * cdef _id = 'out0 = in0'
 * 
 * elementwise_copy = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_copy',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1884, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "cupy/core/core.pyx":1888
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d', 'F->F', 'D->D'),
 *     'out0 = out0_type(in0)', default_casting='unsafe')             # <<<<<<<<<<<<<<
 * # complex numbers requires out0 = complex<T>(in0)
 * 
 */
  __pyx_t_15 = PyDict_New(); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_default_casting, __pyx_n_s_unsafe) < 0) __PYX_ERR(0, 1888, __pyx_L1_error)

  /* "cupy/core/core.pyx":1884
 * cdef _id = 'out0 = in0'
 * 
 * elementwise_copy = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_copy',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__271, __pyx_t_15); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1884, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_elementwise_copy, __pyx_t_17) < 0) __PYX_ERR(0, 1884, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":1891
 * # complex numbers requires out0 = complex<T>(in0)
 * 
 * elementwise_copy_where = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_copy_where',
 *     ('??->?', 'b?->b', 'B?->B', 'h?->h', 'H?->H', 'i?->i', 'I?->I', 'l?->l',
 */
  __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);

  /* "cupy/core/core.pyx":1895
 *     ('??->?', 'b?->b', 'B?->B', 'h?->h', 'H?->H', 'i?->i', 'I?->I', 'l?->l',
 *      'L?->L', 'q?->q', 'Q?->Q', 'e?->e', 'f?->f', 'd?->d', 'F?->F', 'D?->D'),
 *     'if (in1) out0 = in0', default_casting='unsafe')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_15 = PyDict_New(); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1895, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_default_casting, __pyx_n_s_unsafe) < 0) __PYX_ERR(0, 1895, __pyx_L1_error)

  /* "cupy/core/core.pyx":1891
 * # complex numbers requires out0 = complex<T>(in0)
 * 
 * elementwise_copy_where = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_copy_where',
 *     ('??->?', 'b?->b', 'B?->B', 'h?->h', 'H?->H', 'i?->i', 'I?->I', 'l?->l',
 */
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_tuple__273, __pyx_t_15); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_elementwise_copy_where, __pyx_t_9) < 0) __PYX_ERR(0, 1891, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":1898
 * 
 * 
 * cdef _divmod_float = '''             # <<<<<<<<<<<<<<
 *     out0_type a = _floor_divide(in0, in1);
 *     out0 = a;
 */
  __Pyx_INCREF(__pyx_kp_s_out0_type_a__floor_divide_in0_i);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__divmod_float);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__divmod_float, __pyx_kp_s_out0_type_a__floor_divide_in0_i);
  __Pyx_GIVEREF(__pyx_kp_s_out0_type_a__floor_divide_in0_i);

  /* "cupy/core/core.pyx":1908
 *     ('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_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1908, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_kp_s_ee_ee);
  __Pyx_GIVEREF(__pyx_kp_s_ee_ee);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_kp_s_ee_ee);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__divmod_float);
  __Pyx_GIVEREF(__pyx_v_4cupy_4core_4core__divmod_float);
  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_4cupy_4core_4core__divmod_float);

  /* "cupy/core/core.pyx":1909
 *      'LL->LL', 'qq->qq', 'QQ->QQ',
 *      ('ee->ee', _divmod_float),
 *      ('ff->ff', _divmod_float),             # <<<<<<<<<<<<<<
 *      ('dd->dd', _divmod_float)),
 *     '''
 */
  __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1909, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_INCREF(__pyx_kp_s_ff_ff);
  __Pyx_GIVEREF(__pyx_kp_s_ff_ff);
  PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_kp_s_ff_ff);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__divmod_float);
  __Pyx_GIVEREF(__pyx_v_4cupy_4core_4core__divmod_float);
  PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_v_4cupy_4core_4core__divmod_float);

  /* "cupy/core/core.pyx":1910
 *      ('ee->ee', _divmod_float),
 *      ('ff->ff', _divmod_float),
 *      ('dd->dd', _divmod_float)),             # <<<<<<<<<<<<<<
 *     '''
 *     if (in1 == 0) {
 */
  __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_INCREF(__pyx_kp_s_dd_dd);
  __Pyx_GIVEREF(__pyx_kp_s_dd_dd);
  PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_kp_s_dd_dd);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__divmod_float);
  __Pyx_GIVEREF(__pyx_v_4cupy_4core_4core__divmod_float);
  PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_v_4cupy_4core_4core__divmod_float);

  /* "cupy/core/core.pyx":1906
 * 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_8 = PyTuple_New(13); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1906, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_kp_s_bb_bb);
  __Pyx_GIVEREF(__pyx_kp_s_bb_bb);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_kp_s_bb_bb);
  __Pyx_INCREF(__pyx_kp_s_BB_BB);
  __Pyx_GIVEREF(__pyx_kp_s_BB_BB);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_kp_s_BB_BB);
  __Pyx_INCREF(__pyx_kp_s_hh_hh);
  __Pyx_GIVEREF(__pyx_kp_s_hh_hh);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_kp_s_hh_hh);
  __Pyx_INCREF(__pyx_kp_s_HH_HH);
  __Pyx_GIVEREF(__pyx_kp_s_HH_HH);
  PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_kp_s_HH_HH);
  __Pyx_INCREF(__pyx_kp_s_ii_ii);
  __Pyx_GIVEREF(__pyx_kp_s_ii_ii);
  PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_kp_s_ii_ii);
  __Pyx_INCREF(__pyx_kp_s_II_II);
  __Pyx_GIVEREF(__pyx_kp_s_II_II);
  PyTuple_SET_ITEM(__pyx_t_8, 5, __pyx_kp_s_II_II);
  __Pyx_INCREF(__pyx_kp_s_ll_ll);
  __Pyx_GIVEREF(__pyx_kp_s_ll_ll);
  PyTuple_SET_ITEM(__pyx_t_8, 6, __pyx_kp_s_ll_ll);
  __Pyx_INCREF(__pyx_kp_s_LL_LL);
  __Pyx_GIVEREF(__pyx_kp_s_LL_LL);
  PyTuple_SET_ITEM(__pyx_t_8, 7, __pyx_kp_s_LL_LL);
  __Pyx_INCREF(__pyx_kp_s_qq_qq);
  __Pyx_GIVEREF(__pyx_kp_s_qq_qq);
  PyTuple_SET_ITEM(__pyx_t_8, 8, __pyx_kp_s_qq_qq);
  __Pyx_INCREF(__pyx_kp_s_QQ_QQ);
  __Pyx_GIVEREF(__pyx_kp_s_QQ_QQ);
  PyTuple_SET_ITEM(__pyx_t_8, 9, __pyx_kp_s_QQ_QQ);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_8, 10, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_15);
  PyTuple_SET_ITEM(__pyx_t_8, 11, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_17);
  PyTuple_SET_ITEM(__pyx_t_8, 12, __pyx_t_17);
  __pyx_t_9 = 0;
  __pyx_t_15 = 0;
  __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":1904
 * 
 * 
 * divmod = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_divmod',
 *     ('bb->bb', 'BB->BB', 'hh->hh', 'HH->HH', 'ii->ii', 'II->II', 'll->ll',
 */
  __pyx_t_22.__pyx_n = 1;
  __pyx_t_22.routine = __pyx_kp_s_if_in1_0_out0_0_out1_0_else_out;
  __pyx_t_17 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_n_s_cupy_divmod, __pyx_t_8, 0, &__pyx_t_22); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1904, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_divmod, __pyx_t_17) < 0) __PYX_ERR(0, 1904, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":1922
 * 
 * 
 * cdef _min_max_preamble = '''             # <<<<<<<<<<<<<<
 * template <typename T>
 * struct min_max_st{
 */
  __Pyx_INCREF(__pyx_kp_s_template_typename_T_struct_min);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__min_max_preamble);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__min_max_preamble, __pyx_kp_s_template_typename_T_struct_min);
  __Pyx_GIVEREF(__pyx_kp_s_template_typename_T_struct_min);

  /* "cupy/core/core.pyx":2024
 *     ('min_max_st<type_in0_raw>(in0)', 'my_min(a, b)', 'out0 = a.value',
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_17 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_17);

  /* "cupy/core/core.pyx":2015
 * 
 * 
 * _amin = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_min',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_23.__pyx_n = 3;
  __pyx_t_23.routine = __pyx_tuple__281;
  __pyx_t_23.identity = Py_None;
  __pyx_t_23.preamble = __pyx_t_17;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_min, __pyx_tuple__280, 0, &__pyx_t_23); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_amin, __pyx_t_8) < 0) __PYX_ERR(0, 2015, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2036
 *     ('min_max_st<type_in0_raw>(in0)', 'my_max(a, b)', 'out0 = a.value',
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_8 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_8);

  /* "cupy/core/core.pyx":2027
 * 
 * 
 * _amax = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_max',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_23.__pyx_n = 3;
  __pyx_t_23.routine = __pyx_tuple__289;
  __pyx_t_23.identity = Py_None;
  __pyx_t_23.preamble = __pyx_t_8;
  __pyx_t_17 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_max, __pyx_tuple__288, 0, &__pyx_t_23); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2027, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_amax, __pyx_t_17) < 0) __PYX_ERR(0, 2027, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":2045
 *     ('min_max_st<type_in0_raw>(in0)', 'my_min(a, b)', 'out0 = a.value',
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_17 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_17);

  /* "cupy/core/core.pyx":2039
 * 
 * 
 * nanmin = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_nanmin',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_23.__pyx_n = 3;
  __pyx_t_23.routine = __pyx_tuple__291;
  __pyx_t_23.identity = Py_None;
  __pyx_t_23.preamble = __pyx_t_17;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_nanmin, __pyx_tuple__290, 0, &__pyx_t_23); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2039, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_nanmin, __pyx_t_8) < 0) __PYX_ERR(0, 2039, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2054
 *     ('min_max_st<type_in0_raw>(in0)', 'my_max(a, b)', 'out0 = a.value',
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_8 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_8);

  /* "cupy/core/core.pyx":2048
 * 
 * 
 * nanmax = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_nanmax',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_23.__pyx_n = 3;
  __pyx_t_23.routine = __pyx_tuple__293;
  __pyx_t_23.identity = Py_None;
  __pyx_t_23.preamble = __pyx_t_8;
  __pyx_t_17 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_nanmax, __pyx_tuple__292, 0, &__pyx_t_23); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2048, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_nanmax, __pyx_t_17) < 0) __PYX_ERR(0, 2048, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":2066
 *     ('min_max_st<type_in0_raw>(in0, _J)', 'my_argmin(a, b)', 'out0 = a.index',
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_17 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_17);

  /* "cupy/core/core.pyx":2057
 * 
 * 
 * cdef _argmin = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_argmin',
 *     ('?->q', 'B->q', 'h->q', 'H->q', 'i->q', 'I->q', 'l->q', 'L->q',
 */
  __pyx_t_23.__pyx_n = 3;
  __pyx_t_23.routine = __pyx_tuple__301;
  __pyx_t_23.identity = Py_None;
  __pyx_t_23.preamble = __pyx_t_17;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_argmin, __pyx_tuple__300, 0, &__pyx_t_23); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2057, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__argmin);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__argmin, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2078
 *     ('min_max_st<type_in0_raw>(in0, _J)', 'my_argmax(a, b)', 'out0 = a.index',
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_8 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_8);

  /* "cupy/core/core.pyx":2069
 * 
 * 
 * cdef _argmax = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_argmax',
 *     ('?->q', 'B->q', 'h->q', 'H->q', 'i->q', 'I->q', 'l->q', 'L->q',
 */
  __pyx_t_23.__pyx_n = 3;
  __pyx_t_23.routine = __pyx_tuple__309;
  __pyx_t_23.identity = Py_None;
  __pyx_t_23.preamble = __pyx_t_8;
  __pyx_t_17 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_argmax, __pyx_tuple__308, 0, &__pyx_t_23); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2069, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__argmax);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__argmax, __pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_17);
  __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":2188
 * # -----------------------------------------------------------------------------
 * 
 * def _has_element(vector.vector[Py_ssize_t] source, Py_ssize_t n):             # <<<<<<<<<<<<<<
 *     for elem in source:
 *         if elem == n:
 */
  __pyx_t_17 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_57_has_element, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_has_element, __pyx_t_17) < 0) __PYX_ERR(0, 2188, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":2258
 * 
 * 
 * def array_split(ndarray ary, indices_or_sections, Py_ssize_t axis):             # <<<<<<<<<<<<<<
 * 
 *     cdef Py_ssize_t i, ndim, size, each_size, index, prev, offset, stride
 */
  __pyx_t_17 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_65array_split, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_array_split, __pyx_t_17) < 0) __PYX_ERR(0, 2258, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":2304
 * 
 * 
 * cdef Py_ssize_t PY_SSIZE_T_MAX = sys.maxsize             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_maxsize); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __pyx_t_20 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_20 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2304, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_4cupy_4core_4core_PY_SSIZE_T_MAX = __pyx_t_20;

  /* "cupy/core/core.pyx":2604
 *     return ret
 * 
 * cdef _concatenate_kernel_one = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw P x, int32 base',
 *     'T y',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__314, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2604, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__concatenate_kernel_one);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__concatenate_kernel_one, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2653
 *     ''',
 *     'cupy_concatenate',
 *     reduce_dims=False             # <<<<<<<<<<<<<<
 * )
 * 
 */
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2653, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_reduce_dims, Py_False) < 0) __PYX_ERR(0, 2653, __pyx_L1_error)

  /* "cupy/core/core.pyx":2618
 * 
 * 
 * cdef _concatenate_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     '''raw P x, int32 axis, raw int32 cum_sizes,
 *     raw int32 x_strides''',
 */
  __pyx_t_17 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__315, __pyx_t_8); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2618, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__concatenate_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__concatenate_kernel, __pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_17);
  __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":2695
 * 
 * 
 * bitwise_and = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'bitwise_and', '&', False,
 *     '''Computes the bitwise AND of two arrays elementwise.
 */
  __pyx_t_24.__pyx_n = 1;
  __pyx_t_24.doc = __pyx_kp_s_Computes_the_bitwise_AND_of_two;
  __pyx_t_17 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_bitwise_and, __pyx_kp_s__316, Py_False, 0, &__pyx_t_24); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2695, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bitwise_and, __pyx_t_17) < 0) __PYX_ERR(0, 2695, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":2706
 * 
 * 
 * bitwise_or = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'bitwise_or', '|', False,
 *     '''Computes the bitwise OR of two arrays elementwise.
 */
  __pyx_t_24.__pyx_n = 1;
  __pyx_t_24.doc = __pyx_kp_s_Computes_the_bitwise_OR_of_two_a;
  __pyx_t_17 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_bitwise_or, __pyx_kp_s__317, Py_False, 0, &__pyx_t_24); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2706, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bitwise_or, __pyx_t_17) < 0) __PYX_ERR(0, 2706, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":2717
 * 
 * 
 * bitwise_xor = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'bitwise_xor', '^', False,
 *     '''Computes the bitwise XOR of two arrays elementwise.
 */
  __pyx_t_24.__pyx_n = 1;
  __pyx_t_24.doc = __pyx_kp_s_Computes_the_bitwise_XOR_of_two;
  __pyx_t_17 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_bitwise_xor, __pyx_kp_s__318, Py_False, 0, &__pyx_t_24); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2717, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bitwise_xor, __pyx_t_17) < 0) __PYX_ERR(0, 2717, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":2728
 * 
 * 
 * invert = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_invert',
 *     (('?->?', 'out0 = !in0'), 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I',
 */
  __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);

  /* "cupy/core/core.pyx":2733
 *      '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_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2733, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Computes_the_bitwise_NOT_of_an_a) < 0) __PYX_ERR(0, 2733, __pyx_L1_error)

  /* "cupy/core/core.pyx":2728
 * 
 * 
 * invert = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_invert',
 *     (('?->?', 'out0 = !in0'), 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I',
 */
  __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_tuple__321, __pyx_t_8); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_invert, __pyx_t_15) < 0) __PYX_ERR(0, 2728, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":2742
 * 
 * 
 * left_shift = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'left_shift', '<<', True,
 *     '''Shifts the bits of each integer element to the left.
 */
  __pyx_t_24.__pyx_n = 1;
  __pyx_t_24.doc = __pyx_kp_s_Shifts_the_bits_of_each_integer;
  __pyx_t_15 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_left_shift, __pyx_kp_s__322, Py_True, 0, &__pyx_t_24); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_left_shift, __pyx_t_15) < 0) __PYX_ERR(0, 2742, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":2753
 * 
 * 
 * right_shift = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'right_shift', '>>', True,
 *     '''Shifts the bits of each integer element to the right.
 */
  __pyx_t_24.__pyx_n = 1;
  __pyx_t_24.doc = __pyx_kp_s_Shifts_the_bits_of_each_integer_2;
  __pyx_t_15 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_right_shift, __pyx_kp_s__323, Py_True, 0, &__pyx_t_24); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2753, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_right_shift, __pyx_t_15) < 0) __PYX_ERR(0, 2753, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":2767
 * # -----------------------------------------------------------------------------
 * 
 * cdef _take_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T a, S indices, int32 cdim, int32 rdim, int32 adim, S index_range',
 *     'T out',
 */
  __pyx_t_15 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__324, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__take_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__take_kernel, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_15);
  __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":2781
 * 
 * 
 * cdef _take_kernel_0axis = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T a, S indices, int32 rdim, S index_range',
 *     'T out',
 */
  __pyx_t_15 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__325, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2781, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__take_kernel_0axis);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__take_kernel_0axis, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_15);
  __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":2793
 * 
 * 
 * cdef _choose_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'S a, raw T choices, int32 n_channel',
 *     'T y',
 */
  __pyx_t_15 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__326, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2793, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__choose_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__choose_kernel, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_15);
  __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":2800
 * 
 * 
 * cdef _choose_clip_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'S a, raw T choices, int32 n_channel, int32 n',
 *     'T y',
 */
  __pyx_t_15 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__327, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2800, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__choose_clip_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__choose_clip_kernel, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_15);
  __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":2815
 * 
 * 
 * cdef _scatter_update_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'T v, S indices, int32 cdim, int32 rdim, int32 adim',
 *     'raw T a',
 */
  __pyx_t_15 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__328, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2815, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__scatter_update_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__scatter_update_kernel, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_15);
  __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":2828
 * 
 * 
 * cdef _scatter_add_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T v, S indices, int32 cdim, int32 rdim, int32 adim',
 *     'raw T a',
 */
  __pyx_t_15 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__329, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__scatter_add_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__scatter_add_kernel, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_15);
  __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":2841
 * 
 * 
 * cdef _scatter_update_mask_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T v, bool mask, S mask_scanned',
 *     'T a',
 */
  __pyx_t_15 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__330, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2841, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__scatter_update_mask_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__scatter_update_mask_kernel, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_15);
  __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":2848
 * 
 * 
 * cdef _scatter_add_mask_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T v, bool mask, S mask_scanned',
 *     'T a',
 */
  __pyx_t_15 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__331, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2848, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__scatter_add_mask_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__scatter_add_mask_kernel, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_15);
  __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":2855
 * 
 * 
 * cdef _getitem_mask_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'T a, bool mask, S mask_scanned',
 *     'raw T out',
 */
  __pyx_t_15 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__332, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__getitem_mask_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__getitem_mask_kernel, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_15);
  __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":3625
 * 
 * 
 * cdef _cuda_runtime_version = None             # <<<<<<<<<<<<<<
 * cdef _tensordot_core_mul_sum = ReductionKernel(
 *     'S x, T y', 'U out',
 */
  __Pyx_INCREF(Py_None);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cuda_runtime_version);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cuda_runtime_version, Py_None);
  __Pyx_GIVEREF(Py_None);

  /* "cupy/core/core.pyx":3626
 * 
 * cdef _cuda_runtime_version = None
 * cdef _tensordot_core_mul_sum = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T y', 'U out',
 *     'static_cast<U>(x) * static_cast<U>(y)',
 */
  __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_ReductionKernel); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__333, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 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_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3796
 * 
 * 
 * greater = create_comparison(             # <<<<<<<<<<<<<<
 *     'greater', '>',
 *     '''Tests elementwise if ``x1 > x2``.
 */
  __pyx_t_25.__pyx_n = 1;
  __pyx_t_25.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_greater, __pyx_kp_s__334, 0, &__pyx_t_25); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3796, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_greater, __pyx_t_8) < 0) __PYX_ERR(0, 3796, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3805
 * 
 * 
 * greater_equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'greater_equal', '>=',
 *     '''Tests elementwise if ``x1 >= x2``.
 */
  __pyx_t_25.__pyx_n = 1;
  __pyx_t_25.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_2;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_greater_equal, __pyx_kp_s__335, 0, &__pyx_t_25); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3805, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_greater_equal, __pyx_t_8) < 0) __PYX_ERR(0, 3805, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3814
 * 
 * 
 * less = create_comparison(             # <<<<<<<<<<<<<<
 *     'less', '<',
 *     '''Tests elementwise if ``x1 < x2``.
 */
  __pyx_t_25.__pyx_n = 1;
  __pyx_t_25.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_3;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_less, __pyx_kp_s__336, 0, &__pyx_t_25); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3814, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_less, __pyx_t_8) < 0) __PYX_ERR(0, 3814, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3823
 * 
 * 
 * less_equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'less_equal', '<=',
 *     '''Tests elementwise if ``x1 <= x2``.
 */
  __pyx_t_25.__pyx_n = 1;
  __pyx_t_25.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_4;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_less_equal, __pyx_kp_s__337, 0, &__pyx_t_25); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3823, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_less_equal, __pyx_t_8) < 0) __PYX_ERR(0, 3823, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3832
 * 
 * 
 * equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'equal', '==',
 *     '''Tests elementwise if ``x1 == x2``.
 */
  __pyx_t_25.__pyx_n = 2;
  __pyx_t_25.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_5;
  __pyx_t_25.require_sortable_dtype = Py_False;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_equal, __pyx_kp_s__338, 0, &__pyx_t_25); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3832, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_equal, __pyx_t_8) < 0) __PYX_ERR(0, 3832, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3841
 * 
 * 
 * not_equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'not_equal', '!=',
 *     '''Tests elementwise if ``x1 != x2``.
 */
  __pyx_t_25.__pyx_n = 2;
  __pyx_t_25.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_6;
  __pyx_t_25.require_sortable_dtype = Py_False;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_not_equal, __pyx_kp_s__339, 0, &__pyx_t_25); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3841, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_not_equal, __pyx_t_8) < 0) __PYX_ERR(0, 3841, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3850
 * 
 * 
 * _all = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_all',
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',
 */
  __pyx_t_23.__pyx_n = 3;
  __pyx_t_23.routine = __pyx_tuple__341;
  __pyx_t_23.identity = __pyx_n_s_true;
  __pyx_t_23.preamble = __pyx_kp_s__5;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_all, __pyx_tuple__340, 0, &__pyx_t_23); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_all_2, __pyx_t_8) < 0) __PYX_ERR(0, 3850, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3858
 * 
 * 
 * _any = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_any',
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',
 */
  __pyx_t_23.__pyx_n = 3;
  __pyx_t_23.routine = __pyx_tuple__343;
  __pyx_t_23.identity = __pyx_n_s_false;
  __pyx_t_23.preamble = __pyx_kp_s__5;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_any, __pyx_tuple__342, 0, &__pyx_t_23); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3858, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_any_2, __pyx_t_8) < 0) __PYX_ERR(0, 3858, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3870
 * # -----------------------------------------------------------------------------
 * 
 * _sum = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_sum',
 *     ('?->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L',
 */
  __pyx_t_23.__pyx_n = 2;
  __pyx_t_23.routine = __pyx_tuple__347;
  __pyx_t_23.identity = __pyx_int_0;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_sum, __pyx_tuple__346, 0, &__pyx_t_23); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3870, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sum_2, __pyx_t_8) < 0) __PYX_ERR(0, 3870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3881
 * _prod = create_reduction_func(
 *     'cupy_prod',
 *     ['?->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, None, None, 'float')),
 */
  __pyx_t_8 = PyList_New(15); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3881, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_kp_s_l_2);
  __Pyx_GIVEREF(__pyx_kp_s_l_2);
  PyList_SET_ITEM(__pyx_t_8, 0, __pyx_kp_s_l_2);
  __Pyx_INCREF(__pyx_kp_s_B_L);
  __Pyx_GIVEREF(__pyx_kp_s_B_L);
  PyList_SET_ITEM(__pyx_t_8, 1, __pyx_kp_s_B_L);
  __Pyx_INCREF(__pyx_kp_s_h_l);
  __Pyx_GIVEREF(__pyx_kp_s_h_l);
  PyList_SET_ITEM(__pyx_t_8, 2, __pyx_kp_s_h_l);
  __Pyx_INCREF(__pyx_kp_s_H_L);
  __Pyx_GIVEREF(__pyx_kp_s_H_L);
  PyList_SET_ITEM(__pyx_t_8, 3, __pyx_kp_s_H_L);
  __Pyx_INCREF(__pyx_kp_s_i_l);
  __Pyx_GIVEREF(__pyx_kp_s_i_l);
  PyList_SET_ITEM(__pyx_t_8, 4, __pyx_kp_s_i_l);
  __Pyx_INCREF(__pyx_kp_s_I_L);
  __Pyx_GIVEREF(__pyx_kp_s_I_L);
  PyList_SET_ITEM(__pyx_t_8, 5, __pyx_kp_s_I_L);
  __Pyx_INCREF(__pyx_kp_s_l_l);
  __Pyx_GIVEREF(__pyx_kp_s_l_l);
  PyList_SET_ITEM(__pyx_t_8, 6, __pyx_kp_s_l_l);
  __Pyx_INCREF(__pyx_kp_s_L_L);
  __Pyx_GIVEREF(__pyx_kp_s_L_L);
  PyList_SET_ITEM(__pyx_t_8, 7, __pyx_kp_s_L_L);
  __Pyx_INCREF(__pyx_kp_s_q_q);
  __Pyx_GIVEREF(__pyx_kp_s_q_q);
  PyList_SET_ITEM(__pyx_t_8, 8, __pyx_kp_s_q_q);
  __Pyx_INCREF(__pyx_kp_s_Q_Q);
  __Pyx_GIVEREF(__pyx_kp_s_Q_Q);
  PyList_SET_ITEM(__pyx_t_8, 9, __pyx_kp_s_Q_Q);
  __Pyx_INCREF(__pyx_tuple__349);
  __Pyx_GIVEREF(__pyx_tuple__349);
  PyList_SET_ITEM(__pyx_t_8, 10, __pyx_tuple__349);
  __Pyx_INCREF(__pyx_kp_s_f_f);
  __Pyx_GIVEREF(__pyx_kp_s_f_f);
  PyList_SET_ITEM(__pyx_t_8, 11, __pyx_kp_s_f_f);
  __Pyx_INCREF(__pyx_kp_s_d_d);
  __Pyx_GIVEREF(__pyx_kp_s_d_d);
  PyList_SET_ITEM(__pyx_t_8, 12, __pyx_kp_s_d_d);
  __Pyx_INCREF(__pyx_kp_s_F_F);
  __Pyx_GIVEREF(__pyx_kp_s_F_F);
  PyList_SET_ITEM(__pyx_t_8, 13, __pyx_kp_s_F_F);
  __Pyx_INCREF(__pyx_kp_s_D_D);
  __Pyx_GIVEREF(__pyx_kp_s_D_D);
  PyList_SET_ITEM(__pyx_t_8, 14, __pyx_kp_s_D_D);

  /* "cupy/core/core.pyx":3879
 * 
 * 
 * _prod = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_prod',
 *     ['?->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L',
 */
  __pyx_t_23.__pyx_n = 2;
  __pyx_t_23.routine = __pyx_tuple__350;
  __pyx_t_23.identity = __pyx_int_1;
  __pyx_t_15 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_prod, __pyx_t_8, 0, &__pyx_t_23); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3879, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_prod_2, __pyx_t_15) < 0) __PYX_ERR(0, 3879, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":3899
 * 
 * 
 * add = create_arithmetic(             # <<<<<<<<<<<<<<
 *     'add', '+', '|',
 *     '''Adds two arrays elementwise.
 */
  __pyx_t_15 = __pyx_f_4cupy_4core_4core_create_arithmetic(__pyx_n_s_add, __pyx_kp_s__351, __pyx_kp_s__317, __pyx_kp_s_Adds_two_arrays_elementwise_seea); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_add, __pyx_t_15) < 0) __PYX_ERR(0, 3899, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":3908
 * 
 * 
 * conj = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_conj',
 *     ('b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L', 'q->q',
 */
  __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3908, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);

  /* "cupy/core/core.pyx":3915
 *      ('D->D', 'out0 = conj(in0)')),
 *     'out0 = in0',
 *     doc='''Returns the complex conjugate, element-wise.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.conj`
 */
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3915, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Returns_the_complex_conjugate_el) < 0) __PYX_ERR(0, 3915, __pyx_L1_error)

  /* "cupy/core/core.pyx":3908
 * 
 * 
 * conj = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_conj',
 *     ('b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L', 'q->q',
 */
  __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__355, __pyx_t_8); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3908, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_conj, __pyx_t_17) < 0) __PYX_ERR(0, 3908, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":3922
 * 
 * 
 * angle = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_angle',
 *     ('?->d', 'e->e', 'f->f', 'd->d',
 */
  __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3922, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);

  /* "cupy/core/core.pyx":3928
 *      ('D->d', 'out0 = arg(in0)')),
 *     'out0 = in0 >= 0 ? 0 : M_PI',
 *     doc='''Returns the angle of the complex argument.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.angle`
 */
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3928, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Returns_the_angle_of_the_complex) < 0) __PYX_ERR(0, 3928, __pyx_L1_error)

  /* "cupy/core/core.pyx":3922
 * 
 * 
 * angle = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_angle',
 *     ('?->d', 'e->e', 'f->f', 'd->d',
 */
  __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_tuple__359, __pyx_t_8); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3922, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_angle, __pyx_t_15) < 0) __PYX_ERR(0, 3922, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":3935
 * 
 * 
 * real = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_real',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3935, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);

  /* "cupy/core/core.pyx":3942
 *      ('D->d', 'out0 = in0.real()')),
 *     'out0 = in0',
 *     doc='''Returns the real part of the elements of the array.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.real`
 */
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3942, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Returns_the_real_part_of_the_ele) < 0) __PYX_ERR(0, 3942, __pyx_L1_error)

  /* "cupy/core/core.pyx":3935
 * 
 * 
 * real = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_real',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__363, __pyx_t_8); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3935, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_real, __pyx_t_17) < 0) __PYX_ERR(0, 3935, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":3949
 * 
 * 
 * _real_setter = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_real_setter',
 *     ('f->F', 'd->D'),
 */
  __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3949, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);

  /* "cupy/core/core.pyx":3953
 *     ('f->F', 'd->D'),
 *     'out0.real(in0)',
 *     doc='''Sets the real part of the elements of the array.             # <<<<<<<<<<<<<<
 *     ''')
 * 
 */
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3953, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Sets_the_real_part_of_the_elemen) < 0) __PYX_ERR(0, 3953, __pyx_L1_error)

  /* "cupy/core/core.pyx":3949
 * 
 * 
 * _real_setter = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_real_setter',
 *     ('f->F', 'd->D'),
 */
  __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_tuple__365, __pyx_t_8); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3949, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_real_setter, __pyx_t_15) < 0) __PYX_ERR(0, 3949, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":3957
 * 
 * 
 * imag = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_imag',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3957, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);

  /* "cupy/core/core.pyx":3964
 *      ('D->d', 'out0 = in0.imag()')),
 *     'out0 = 0',
 *     doc='''Returns the imaginary part of the elements of the array.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.imag`
 */
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3964, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Returns_the_imaginary_part_of_th) < 0) __PYX_ERR(0, 3964, __pyx_L1_error)

  /* "cupy/core/core.pyx":3957
 * 
 * 
 * imag = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_imag',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__369, __pyx_t_8); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3957, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_imag, __pyx_t_17) < 0) __PYX_ERR(0, 3957, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":3971
 * 
 * 
 * _imag_setter = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_imag_setter',
 *     ('f->F', 'd->D'),
 */
  __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3971, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);

  /* "cupy/core/core.pyx":3975
 *     ('f->F', 'd->D'),
 *     'out0.imag(in0)',
 *     doc='''Sets the imaginary part of the elements of the array.             # <<<<<<<<<<<<<<
 *     ''')
 * 
 */
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3975, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Sets_the_imaginary_part_of_the_e) < 0) __PYX_ERR(0, 3975, __pyx_L1_error)

  /* "cupy/core/core.pyx":3971
 * 
 * 
 * _imag_setter = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_imag_setter',
 *     ('f->F', 'd->D'),
 */
  __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_tuple__371, __pyx_t_8); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3971, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_imag_setter, __pyx_t_15) < 0) __PYX_ERR(0, 3971, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":3979
 * 
 * 
 * negative = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_negative',
 *     (('?->?', 'out0 = !in0'),
 */
  __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3979, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);

  /* "cupy/core/core.pyx":3985
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d', 'F->F', 'D->D'),
 *     'out0 = -in0',
 *     doc='''Takes numerical negative elementwise.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.negative`
 */
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3985, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Takes_numerical_negative_element) < 0) __PYX_ERR(0, 3985, __pyx_L1_error)

  /* "cupy/core/core.pyx":3979
 * 
 * 
 * negative = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_negative',
 *     (('?->?', 'out0 = !in0'),
 */
  __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__374, __pyx_t_8); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3979, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_negative, __pyx_t_17) < 0) __PYX_ERR(0, 3979, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":3992
 * 
 * 
 * multiply = create_arithmetic(             # <<<<<<<<<<<<<<
 *     'multiply', '*', '&',
 *     '''Multiplies two arrays elementwise.
 */
  __pyx_t_17 = __pyx_f_4cupy_4core_4core_create_arithmetic(__pyx_n_s_multiply, __pyx_kp_s__375, __pyx_kp_s__316, __pyx_kp_s_Multiplies_two_arrays_elementwis); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_multiply, __pyx_t_17) < 0) __PYX_ERR(0, 3992, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":4001
 * 
 * 
 * divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);

  /* "cupy/core/core.pyx":4011
 *      ('DD->D', 'out0 = in0 / in1')),
 *     'out0 = in1 == 0 ? 0 : floor((double)in0 / (double)in1)',
 *     doc='''Divides arguments elementwise.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.divide`
 */
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4011, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Divides_arguments_elementwise_se) < 0) __PYX_ERR(0, 4011, __pyx_L1_error)

  /* "cupy/core/core.pyx":4001
 * 
 * 
 * divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_tuple__382, __pyx_t_8); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_divide, __pyx_t_15) < 0) __PYX_ERR(0, 4001, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":4018
 * 
 * 
 * power = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_power',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4018, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);

  /* "cupy/core/core.pyx":4028
 *      ('DD->D', 'out0 = pow(in0, in1)')),
 *     'out0 = rint(pow((double)in0, (double)in1))',
 *     doc='''Computes ``x1 ** x2`` elementwise.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.power`
 */
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4028, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Computes_x1_x2_elementwise_seeal) < 0) __PYX_ERR(0, 4028, __pyx_L1_error)

  /* "cupy/core/core.pyx":4018
 * 
 * 
 * power = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_power',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__389, __pyx_t_8); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4018, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_power, __pyx_t_17) < 0) __PYX_ERR(0, 4018, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":4035
 * 
 * 
 * subtract = create_arithmetic(             # <<<<<<<<<<<<<<
 *     'subtract', '-', '^',
 *     '''Subtracts arguments elementwise.
 */
  __pyx_t_17 = __pyx_f_4cupy_4core_4core_create_arithmetic(__pyx_n_s_subtract, __pyx_kp_s__390, __pyx_kp_s__318, __pyx_kp_s_Subtracts_arguments_elementwise); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4035, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_subtract, __pyx_t_17) < 0) __PYX_ERR(0, 4035, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":4044
 * 
 * 
 * true_divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_true_divide',
 *     ('bb->d', 'BB->d', 'hh->d', 'HH->d', 'ii->d', 'II->d', 'll->d', 'LL->d',
 */
  __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4044, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);

  /* "cupy/core/core.pyx":4049
 *      'qq->d', 'QQ->d', 'ee->e', 'ff->f', 'dd->d', 'FF->F', 'DD->D'),
 *     'out0 = (out0_type)in0 / (out0_type)in1',
 *     doc='''Elementwise true division (i.e. division as floating values).             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.true_divide`
 */
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4049, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Elementwise_true_division_i_e_di) < 0) __PYX_ERR(0, 4049, __pyx_L1_error)

  /* "cupy/core/core.pyx":4044
 * 
 * 
 * true_divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_true_divide',
 *     ('bb->d', 'BB->d', 'hh->d', 'HH->d', 'ii->d', 'II->d', 'll->d', 'LL->d',
 */
  __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_tuple__392, __pyx_t_8); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4044, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_true_divide, __pyx_t_15) < 0) __PYX_ERR(0, 4044, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":4056
 * 
 * 
 * if six.PY3:             # <<<<<<<<<<<<<<
 *     divide = true_divide
 * 
 */
  __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_PY3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 4056, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__pyx_t_19) {

    /* "cupy/core/core.pyx":4057
 * 
 * if six.PY3:
 *     divide = true_divide             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_true_divide); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4057, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_divide, __pyx_t_8) < 0) __PYX_ERR(0, 4057, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":4056
 * 
 * 
 * if six.PY3:             # <<<<<<<<<<<<<<
 *     divide = true_divide
 * 
 */
  }

  /* "cupy/core/core.pyx":4060
 * 
 * 
 * floor_divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_floor_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "cupy/core/core.pyx":4065
 *      'qq->q', 'QQ->Q', 'ee->e', 'ff->f', 'dd->d'),
 *     'out0 = _floor_divide(in0, in1)',
 *     doc='''Elementwise floor division (i.e. integer quotient).             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.floor_divide`
 */
  __pyx_t_15 = PyDict_New(); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4065, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_doc, __pyx_kp_s_Elementwise_floor_division_i_e_i) < 0) __PYX_ERR(0, 4065, __pyx_L1_error)

  /* "cupy/core/core.pyx":4060
 * 
 * 
 * floor_divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_floor_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__394, __pyx_t_15); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_floor_divide, __pyx_t_17) < 0) __PYX_ERR(0, 4060, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":4072
 * 
 * 
 * remainder = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_remainder',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4072, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);

  /* "cupy/core/core.pyx":4080
 *      ('dd->d', 'out0 = in0 - _floor_divide(in0, in1) * in1')),
 *     'out0 = (in0 - _floor_divide(in0, in1) * in1) * (in1 != 0)',
 *     doc='''Computes the remainder of Python division elementwise.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.remainder`
 */
  __pyx_t_15 = PyDict_New(); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4080, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_doc, __pyx_kp_s_Computes_the_remainder_of_Python) < 0) __PYX_ERR(0, 4080, __pyx_L1_error)

  /* "cupy/core/core.pyx":4072
 * 
 * 
 * remainder = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_remainder',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_tuple__399, __pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4072, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_remainder, __pyx_t_8) < 0) __PYX_ERR(0, 4072, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":4087
 * 
 * 
 * absolute = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4087, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "cupy/core/core.pyx":4099
 *      ('D->d', 'out0 = abs(in0)')),
 *     'out0 = in0 > 0 ? in0 : -in0',
 *     doc='''Elementwise absolute value function.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.absolute`
 */
  __pyx_t_15 = PyDict_New(); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4099, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_doc, __pyx_kp_s_Elementwise_absolute_value_funct) < 0) __PYX_ERR(0, 4099, __pyx_L1_error)

  /* "cupy/core/core.pyx":4087
 * 
 * 
 * absolute = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),
 */
  __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__412, __pyx_t_15); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4087, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_absolute, __pyx_t_17) < 0) __PYX_ERR(0, 4087, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":4106
 * 
 * 
 * sqrt = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_sqrt',
 *     ('e->e', 'f->f', 'd->d', 'F->F', 'D->D'),
 */
  __pyx_t_22.__pyx_n = 1;
  __pyx_t_22.routine = __pyx_kp_s_out0_sqrt_in0;
  __pyx_t_17 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_n_s_cupy_sqrt, __pyx_tuple__413, 0, &__pyx_t_22); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sqrt, __pyx_t_17) < 0) __PYX_ERR(0, 4106, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":4112
 * 
 * 
 * _clip = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_clip',
 *     ('???->?', 'bbb->b', 'BBB->B', 'hhh->h', 'HHH->H', 'iii->i', 'III->I',
 */
  __pyx_t_22.__pyx_n = 1;
  __pyx_t_22.routine = __pyx_kp_s_out0_in0_in1_in1_in0_in2_in2_in0;
  __pyx_t_17 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_n_s_cupy_clip, __pyx_tuple__415, 0, &__pyx_t_22); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_clip_2, __pyx_t_17) < 0) __PYX_ERR(0, 4112, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":4155
 * 
 * 
 * cdef _var_core = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T mean, T alpha', 'T out',
 *     '(x - mean) * (x - mean)',
 */
  __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_ReductionKernel); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_tuple__416, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__var_core);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__var_core, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_15);
  __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":4160
 *     'a + b', 'out = alpha * a', '0', '_var_core')
 * 
 * cdef _var_core_out = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T mean, T alpha', 'U out',
 *     '(x - mean) * (x - mean)',
 */
  __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_ReductionKernel); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__417, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__var_core_out);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__var_core_out, __pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_17);
  __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":4166
 * 
 * # TODO(okuta) needs cast
 * cdef _mean = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_mean',
 *     ('?->d', 'B->d', 'h->d', 'H->d', 'i->d', 'I->d', 'l->d', 'L->d',
 */
  __pyx_t_23.__pyx_n = 1;
  __pyx_t_23.routine = __pyx_tuple__421;
  __pyx_t_17 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_mean, __pyx_tuple__420, 0, &__pyx_t_23); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__mean);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__mean, __pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_17);
  __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":4180
 * # -----------------------------------------------------------------------------
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _inclusive_scan_kernel(dtype, block_size):
 *     """return Prefix Sum(Scan) cuda kernel
 */
  __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_memoize); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_15 = PyDict_New(); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(0, 4180, __pyx_L1_error)
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_empty_tuple, __pyx_t_15); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":4181
 * 
 * @util.memoize(for_each_device=True)
 * def _inclusive_scan_kernel(dtype, block_size):             # <<<<<<<<<<<<<<
 *     """return Prefix Sum(Scan) cuda kernel
 * 
 */
  __pyx_t_15 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_115_inclusive_scan_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_17 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_15); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4180, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_GOTREF(__pyx_t_17);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_15};
      __pyx_t_17 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4180, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_15};
      __pyx_t_17 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4180, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    } else
    #endif
    {
      __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4180, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_15);
      __pyx_t_15 = 0;
      __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_14, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4180, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_inclusive_scan_kernel_2, __pyx_t_17) < 0) __PYX_ERR(0, 4181, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":4247
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _add_scan_blocked_sum_kernel(dtype):
 *     name = "add_scan_blocked_sum_kernel"
 */
  __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_memoize); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(0, 4247, __pyx_L1_error)
  __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_empty_tuple, __pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":4248
 * 
 * @util.memoize(for_each_device=True)
 * def _add_scan_blocked_sum_kernel(dtype):             # <<<<<<<<<<<<<<
 *     name = "add_scan_blocked_sum_kernel"
 *     dtype = _get_typename(dtype)
 */
  __pyx_t_9 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_117_add_scan_blocked_sum_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_15);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_15, function);
    }
  }
  if (!__pyx_t_14) {
    __pyx_t_17 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4247, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_17);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_9};
      __pyx_t_17 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4247, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_9};
      __pyx_t_17 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4247, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4247, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_14); __pyx_t_14 = NULL;
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_8, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4247, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_add_scan_blocked_sum_kernel_2, __pyx_t_17) < 0) __PYX_ERR(0, 4248, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":4267
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _nonzero_1d_kernel(src_dtype, index_dtype):
 *     name = "nonzero_1d_kernel"
 */
  __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_memoize); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_15 = PyDict_New(); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(0, 4267, __pyx_L1_error)
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_empty_tuple, __pyx_t_15); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":4268
 * 
 * @util.memoize(for_each_device=True)
 * def _nonzero_1d_kernel(src_dtype, index_dtype):             # <<<<<<<<<<<<<<
 *     name = "nonzero_1d_kernel"
 *     src_dtype = _get_typename(src_dtype)
 */
  __pyx_t_15 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_119_nonzero_1d_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4268, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_17 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_15); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4267, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_GOTREF(__pyx_t_17);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_15};
      __pyx_t_17 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4267, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_15};
      __pyx_t_17 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4267, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    } else
    #endif
    {
      __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4267, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_15);
      __pyx_t_15 = 0;
      __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_14, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4267, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_nonzero_1d_kernel, __pyx_t_17) < 0) __PYX_ERR(0, 4268, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":4290
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype):
 *     name = "nonzero_kernel"
 */
  __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_memoize); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(0, 4290, __pyx_L1_error)
  __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_empty_tuple, __pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":4291
 * 
 * @util.memoize(for_each_device=True)
 * def _nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype):             # <<<<<<<<<<<<<<
 *     name = "nonzero_kernel"
 *     src_dtype = _get_typename(src_dtype)
 */
  __pyx_t_9 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_121_nonzero_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_15);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_15, function);
    }
  }
  if (!__pyx_t_14) {
    __pyx_t_17 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4290, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_17);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_9};
      __pyx_t_17 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4290, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_9};
      __pyx_t_17 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4290, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4290, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_14); __pyx_t_14 = NULL;
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_8, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4290, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_nonzero_kernel, __pyx_t_17) < 0) __PYX_ERR(0, 4291, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Indexer(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x6d47339:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_t_17 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_125__pyx_unpickle_Indexer, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_17)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Indexer, __pyx_t_17) < 0) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "(tree fragment)":9
 *         __pyx_unpickle_Indexer__set_state(<Indexer> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Indexer__set_state(Indexer __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.shape = __pyx_state[0]; __pyx_result.size = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_17 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_127__pyx_unpickle_ParameterInfo, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_17)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_ParameterInfo, __pyx_t_17) < 0) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ElementwiseKernel(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x7d8b293:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_t_17 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_129__pyx_unpickle_ElementwiseKernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_17)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_ElementwiseKernel, __pyx_t_17) < 0) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "(tree fragment)":9
 *         __pyx_unpickle_ElementwiseKernel__set_state(<ElementwiseKernel> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ElementwiseKernel__set_state(ElementwiseKernel __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.in_params = __pyx_state[0]; __pyx_result.kwargs = __pyx_state[1]; __pyx_result.name = __pyx_state[2]; __pyx_result.nargs = __pyx_state[3]; __pyx_result.nin = __pyx_state[4]; __pyx_result.nout = __pyx_state[5]; __pyx_result.operation = __pyx_state[6]; __pyx_result.out_params = __pyx_state[7]; __pyx_result.params = __pyx_state[8]; __pyx_result.preamble = __pyx_state[9]; __pyx_result.reduce_dims = __pyx_state[10]
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_17 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_131__pyx_unpickle_broadcast, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_17)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_broadcast, __pyx_t_17) < 0) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "cupy/core/core.pyx":1
 * # distutils: language = c++             # <<<<<<<<<<<<<<
 * 
 * from __future__ import division
 */
  __pyx_t_17 = PyDict_New(); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_t_17, __pyx_kp_u_ndarray___getitem___line_1394, __pyx_kp_u_x___getitem___y_x_y_Supports_bot) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_17, __pyx_kp_u_ndarray___setitem___line_1584, __pyx_kp_u_x___setitem___slices_y_x_slices) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_17) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "View.MemoryView":207
 *         info.obj = self
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(array self):
 */
  __pyx_t_17 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_17)) __PYX_ERR(4, 207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem((PyObject *)__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_17) < 0) __PYX_ERR(4, 207, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  PyType_Modified(__pyx_array_type);

  /* "View.MemoryView":284
 *         return self.name
 * 
 * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
 * cdef strided = Enum("<strided and direct>") # default
 * cdef indirect = Enum("<strided and indirect>")
 */
  __pyx_t_17 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__438, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(4, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_XGOTREF(generic);
  __Pyx_DECREF_SET(generic, __pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_17);
  __pyx_t_17 = 0;

  /* "View.MemoryView":285
 * 
 * cdef generic = Enum("<strided and direct or indirect>")
 * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
 * cdef indirect = Enum("<strided and indirect>")
 * 
 */
  __pyx_t_17 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__439, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(4, 285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_XGOTREF(strided);
  __Pyx_DECREF_SET(strided, __pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_17);
  __pyx_t_17 = 0;

  /* "View.MemoryView":286
 * cdef generic = Enum("<strided and direct or indirect>")
 * cdef strided = Enum("<strided and direct>") # default
 * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_17 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__440, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(4, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_XGOTREF(indirect);
  __Pyx_DECREF_SET(indirect, __pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_17);
  __pyx_t_17 = 0;

  /* "View.MemoryView":289
 * 
 * 
 * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
 * cdef indirect_contiguous = Enum("<contiguous and indirect>")
 * 
 */
  __pyx_t_17 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__441, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(4, 289, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_XGOTREF(contiguous);
  __Pyx_DECREF_SET(contiguous, __pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_17);
  __pyx_t_17 = 0;

  /* "View.MemoryView":290
 * 
 * cdef contiguous = Enum("<contiguous and direct>")
 * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_17 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__442, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(4, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_XGOTREF(indirect_contiguous);
  __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_17);
  __pyx_t_17 = 0;

  /* "View.MemoryView":314
 * 
 * DEF THREAD_LOCKS_PREALLOCATED = 8
 * cdef int __pyx_memoryview_thread_locks_used = 0             # <<<<<<<<<<<<<<
 * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [
 *     PyThread_allocate_lock(),
 */
  __pyx_memoryview_thread_locks_used = 0;

  /* "View.MemoryView":315
 * DEF THREAD_LOCKS_PREALLOCATED = 8
 * cdef int __pyx_memoryview_thread_locks_used = 0
 * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [             # <<<<<<<<<<<<<<
 *     PyThread_allocate_lock(),
 *     PyThread_allocate_lock(),
 */
  __pyx_t_26[0] = PyThread_allocate_lock();
  __pyx_t_26[1] = PyThread_allocate_lock();
  __pyx_t_26[2] = PyThread_allocate_lock();
  __pyx_t_26[3] = PyThread_allocate_lock();
  __pyx_t_26[4] = PyThread_allocate_lock();
  __pyx_t_26[5] = PyThread_allocate_lock();
  __pyx_t_26[6] = PyThread_allocate_lock();
  __pyx_t_26[7] = PyThread_allocate_lock();
  memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_26, sizeof(__pyx_memoryview_thread_locks[0]) * (8));

  /* "View.MemoryView":537
 *         info.obj = self
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_17 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_17)) __PYX_ERR(4, 537, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem((PyObject *)__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_17) < 0) __PYX_ERR(4, 537, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  PyType_Modified(__pyx_memoryview_type);

  /* "View.MemoryView":983
 *         return self.from_object
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_17 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_17)) __PYX_ERR(4, 983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem((PyObject *)__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_17) < 0) __PYX_ERR(4, 983, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  PyType_Modified(__pyx_memoryviewslice_type);

  /* "(tree fragment)":1
 * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xb068931:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_t_17 = PyCFunction_NewEx(&__pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum, NULL, __pyx_n_s_View_MemoryView); if (unlikely(!__pyx_t_17)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Enum, __pyx_t_17) < 0) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "(tree fragment)":9
 *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.name = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_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_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  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 PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #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

/* 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;
}

/* GetAttr */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_COMPILING_IN_CPYTHON
#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 CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = __Pyx_GetAttr(o, n);
    if (unlikely(!r)) {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError))
            goto bad;
        PyErr_Clear();
        r = d;
        Py_INCREF(d);
    }
    return r;
bad:
    return NULL;
}

/* RaiseDoubleKeywords */
static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

/* ParseKeywords */
static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

/* RaiseArgTupleInvalid */
static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

/* GetModuleGlobalName */
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
    result = PyDict_GetItem(__pyx_d, name);
    if (likely(result)) {
        Py_INCREF(result);
    } else {
#else
    result = PyObject_GetItem(__pyx_d, name);
    if (!result) {
        PyErr_Clear();
#endif
        result = __Pyx_GetBuiltinName(name);
    }
    return result;
}

/* PyObjectCall */
  #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = func->ob_type->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyErrFetchRestore */
  #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* RaiseException */
  #if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_PyThreadState_assign
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
#if PY_VERSION_HEX >= 0x03030000
    if (cause) {
#else
    if (cause && cause != Py_None) {
#endif
        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 = PyThreadState_GET();
        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

/* 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 = PyThreadState_GET();
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = f->f_localsplus;
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#endif

/* PyObjectCallMethO */
    #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallOneArg */
    #if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
    if (likely(PyCFunction_Check(func))) {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
        } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* 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(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* BytesEquals */
    static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result;
#if CYTHON_USE_UNICODE_INTERNALS
            Py_hash_t hash1, hash2;
            hash1 = ((PyBytesObject*)s1)->ob_shash;
            hash2 = ((PyBytesObject*)s2)->ob_shash;
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                return (equals == Py_NE);
            }
#endif
            result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

/* UnicodeEquals */
    static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
#if CYTHON_USE_UNICODE_INTERNALS
        {
            Py_hash_t hash1, hash2;
        #if CYTHON_PEP393_ENABLED
            hash1 = ((PyASCIIObject*)s1)->hash;
            hash2 = ((PyASCIIObject*)s2)->hash;
        #else
            hash1 = ((PyUnicodeObject*)s1)->hash;
            hash2 = ((PyUnicodeObject*)s2)->hash;
        #endif
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                goto return_ne;
            }
        }
#endif
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

/* 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) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* PyIntBinop */
      #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                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
                    }
                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
                    }
                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
                    }
                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
                    }
                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
                    }
                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

/* RaiseTooManyValuesToUnpack */
      static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

/* RaiseNeedMoreValuesToUnpack */
      static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

/* IterFinish */
      static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_FAST_THREAD_STATE
    PyThreadState *tstate = PyThreadState_GET();
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(exc_type == PyExc_StopIteration) || 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;
}

/* SaveResetException */
      #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    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;
    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;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* GetException */
      #if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
#endif
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_FAST_THREAD_STATE
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_FAST_THREAD_STATE
    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;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

/* None */
        static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

/* GetItemInt */
        static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return NULL;
                    PyErr_Clear();
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

/* SetItemInt */
        static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
                                               CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
        if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return -1;
                    PyErr_Clear();
                }
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) {
#else
    if (is_list || PySequence_Check(o)) {
#endif
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

/* 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;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                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;
                    }
                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;
                    }
                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;
                    }
                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;
                    }
                #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 CYTHON_INLINE 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_CheckExact(key)) && unlikely(!PyString_Check(key)))
        #endif
            if (unlikely(!PyUnicode_Check(key)))
                goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    return 0;
#endif
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}

/* None */
          static CYTHON_INLINE Py_ssize_t __Pyx_mod_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
    Py_ssize_t r = a % b;
    r += ((r != 0) & ((r ^ b) < 0)) * b;
    return r;
}

/* PyIntBinop */
          #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a - b);
            if (likely((x^a) >= 0 || (x^~b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                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
                    }
                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
                    }
                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
                    }
                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
                    }
                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
                    }
                default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
            }
        }
                x = a - b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla - llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("subtract", return NULL)
            result = ((double)a) - (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
}
#endif

/* RaiseNoneIterError */
          static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

/* SliceObject */
          static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_USE_TYPE_SLOTS
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                    goto bad;
                PyErr_Clear();
            }
        }
        return ms->sq_slice(obj, cstart, cstop);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_subscript))
#endif
    {
        PyObject* result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_USE_TYPE_SLOTS
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

/* 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;
}

/* 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;
}

/* ArgTypeTest */
          static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
}
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (likely(Py_TYPE(obj) == type)) return 1;
        #if PY_MAJOR_VERSION == 2
        else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(PyObject_TypeCheck(obj, type))) return 1;
    }
    __Pyx_RaiseArgumentTypeInvalid(name, obj, type);
    return 0;
}

/* StringJoin */
          #if !CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
    return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
}
#endif

/* SliceTupleAndList */
          #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE void __Pyx_crop_slice(Py_ssize_t* _start, Py_ssize_t* _stop, Py_ssize_t* _length) {
    Py_ssize_t start = *_start, stop = *_stop, length = *_length;
    if (start < 0) {
        start += length;
        if (start < 0)
            start = 0;
    }
    if (stop < 0)
        stop += length;
    else if (stop > length)
        stop = length;
    *_length = stop - start;
    *_start = start;
    *_stop = stop;
}
static CYTHON_INLINE void __Pyx_copy_object_array(PyObject** CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
    PyObject *v;
    Py_ssize_t i;
    for (i = 0; i < length; i++) {
        v = dest[i] = src[i];
        Py_INCREF(v);
    }
}
static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(
            PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
    PyObject* dest;
    Py_ssize_t length = PyList_GET_SIZE(src);
    __Pyx_crop_slice(&start, &stop, &length);
    if (unlikely(length <= 0))
        return PyList_New(0);
    dest = PyList_New(length);
    if (unlikely(!dest))
        return NULL;
    __Pyx_copy_object_array(
        ((PyListObject*)src)->ob_item + start,
        ((PyListObject*)dest)->ob_item,
        length);
    return dest;
}
static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(
            PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
    PyObject* dest;
    Py_ssize_t length = PyTuple_GET_SIZE(src);
    __Pyx_crop_slice(&start, &stop, &length);
    if (unlikely(length <= 0))
        return PyTuple_New(0);
    dest = PyTuple_New(length);
    if (unlikely(!dest))
        return NULL;
    __Pyx_copy_object_array(
        ((PyTupleObject*)src)->ob_item + start,
        ((PyTupleObject*)dest)->ob_item,
        length);
    return dest;
}
#endif

/* UnpackUnboundCMethod */
          static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    target->method = method;
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION >= 3
    if (likely(PyObject_TypeCheck(method, &PyMethodDescr_Type)))
    #endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
    }
#endif
    return 0;
}

/* CallUnboundCMethod0 */
          static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_ASSUME_SAFE_MACROS
    args = PyTuple_New(1);
    if (unlikely(!args)) goto bad;
    Py_INCREF(self);
    PyTuple_SET_ITEM(args, 0, self);
#else
    args = PyTuple_Pack(1, self);
    if (unlikely(!args)) goto bad;
#endif
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    Py_DECREF(args);
bad:
    return result;
}

/* py_dict_items */
          static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) {
    if (PY_MAJOR_VERSION >= 3)
        return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_items, d);
    else
        return PyDict_Items(d);
}

/* None */
          static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

/* PyObjectCallMethod1 */
          static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method, *result = NULL;
    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
    if (unlikely(!method)) goto done;
#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);
            Py_DECREF(method); method = NULL;
            result = __Pyx_PyObject_Call(function, args, NULL);
            Py_DECREF(args);
            Py_DECREF(function);
            return result;
        }
    }
#endif
    result = __Pyx_PyObject_CallOneArg(method, arg);
done:
    Py_XDECREF(method);
    return result;
}

/* append */
          static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
    } else {
        PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
        if (unlikely(!retval))
            return -1;
        Py_DECREF(retval);
    }
    return 0;
}

/* dict_getitem_default */
          static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
    PyObject* value;
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (unlikely(PyErr_Occurred()))
            return NULL;
        value = default_value;
    }
    Py_INCREF(value);
#else
    if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
        value = PyDict_GetItem(d, key);
        if (unlikely(!value)) {
            value = default_value;
        }
        Py_INCREF(value);
    } else {
        if (default_value == Py_None)
            default_value = NULL;
        value = PyObject_CallMethodObjArgs(
            d, __pyx_n_s_get, key, default_value, NULL);
    }
#endif
    return value;
}

/* BufferIndexError */
          static void __Pyx_RaiseBufferIndexError(int axis) {
  PyErr_Format(PyExc_IndexError,
     "Out of bounds on buffer access (axis %d)", axis);
}

/* IsLittleEndian */
          static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
{
  union {
    uint32_t u32;
    uint8_t u8[4];
  } S;
  S.u32 = 0x01020304;
  return S.u8[0] == 4;
}

/* BufferFormatCheck */
          static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
                              __Pyx_BufFmt_StackElem* stack,
                              __Pyx_TypeInfo* type) {
  stack[0].field = &ctx->root;
  stack[0].parent_offset = 0;
  ctx->root.type = type;
  ctx->root.name = "buffer dtype";
  ctx->root.offset = 0;
  ctx->head = stack;
  ctx->head->field = &ctx->root;
  ctx->fmt_offset = 0;
  ctx->head->parent_offset = 0;
  ctx->new_packmode = '@';
  ctx->enc_packmode = '@';
  ctx->new_count = 1;
  ctx->enc_count = 0;
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  ctx->is_valid_array = 0;
  ctx->struct_alignment = 0;
  while (type->typegroup == 'S') {
    ++ctx->head;
    ctx->head->field = type->fields;
    ctx->head->parent_offset = 0;
    type = type->fields->type;
  }
}
static int __Pyx_BufFmt_ParseNumber(const char** ts) {
    int count;
    const char* t = *ts;
    if (*t < '0' || *t > '9') {
      return -1;
    } else {
        count = *t++ - '0';
        while (*t >= '0' && *t < '9') {
            count *= 10;
            count += *t++ - '0';
        }
    }
    *ts = t;
    return count;
}
static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
    int number = __Pyx_BufFmt_ParseNumber(ts);
    if (number == -1)
        PyErr_Format(PyExc_ValueError,\
                     "Does not understand character buffer dtype format string ('%c')", **ts);
    return number;
}
static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
  PyErr_Format(PyExc_ValueError,
               "Unexpected format string character: '%c'", ch);
}
static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
  switch (ch) {
    case 'c': return "'char'";
    case 'b': return "'signed char'";
    case 'B': return "'unsigned char'";
    case 'h': return "'short'";
    case 'H': return "'unsigned short'";
    case 'i': return "'int'";
    case 'I': return "'unsigned int'";
    case 'l': return "'long'";
    case 'L': return "'unsigned long'";
    case 'q': return "'long long'";
    case 'Q': return "'unsigned long long'";
    case 'f': return (is_complex ? "'complex float'" : "'float'");
    case 'd': return (is_complex ? "'complex double'" : "'double'");
    case 'g': return (is_complex ? "'complex long double'" : "'long double'");
    case 'T': return "a struct";
    case 'O': return "Python object";
    case 'P': return "a pointer";
    case 's': case 'p': return "a string";
    case 0: return "end";
    default: return "unparseable format string";
  }
}
static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return 2;
    case 'i': case 'I': case 'l': case 'L': return 4;
    case 'q': case 'Q': return 8;
    case 'f': return (is_complex ? 8 : 4);
    case 'd': return (is_complex ? 16 : 8);
    case 'g': {
      PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
      return 0;
    }
    case 'O': case 'P': return sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
  switch (ch) {
    case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(short);
    case 'i': case 'I': return sizeof(int);
    case 'l': case 'L': return sizeof(long);
    #ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(PY_LONG_LONG);
    #endif
    case 'f': return sizeof(float) * (is_complex ? 2 : 1);
    case 'd': return sizeof(double) * (is_complex ? 2 : 1);
    case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
    case 'O': case 'P': return sizeof(void*);
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
  }
}
typedef struct { char c; short x; } __Pyx_st_short;
typedef struct { char c; int x; } __Pyx_st_int;
typedef struct { char c; long x; } __Pyx_st_long;
typedef struct { char c; float x; } __Pyx_st_float;
typedef struct { char c; double x; } __Pyx_st_double;
typedef struct { char c; long double x; } __Pyx_st_longdouble;
typedef struct { char c; void *x; } __Pyx_st_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
/* These are for computing the padding at the end of the struct to align
   on the first member of the struct. This will probably the same as above,
   but we don't have any guarantees.
 */
typedef struct { short x; char c; } __Pyx_pad_short;
typedef struct { int x; char c; } __Pyx_pad_int;
typedef struct { long x; char c; } __Pyx_pad_long;
typedef struct { float x; char c; } __Pyx_pad_float;
typedef struct { double x; char c; } __Pyx_pad_double;
typedef struct { long double x; char c; } __Pyx_pad_longdouble;
typedef struct { void *x; char c; } __Pyx_pad_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
  switch (ch) {
    case 'c':
        return 'H';
    case 'b': case 'h': case 'i':
    case 'l': case 'q': case 's': case 'p':
        return 'I';
    case 'B': case 'H': case 'I': case 'L': case 'Q':
        return 'U';
    case 'f': case 'd': case 'g':
        return (is_complex ? 'C' : 'R');
    case 'O':
        return 'O';
    case 'P':
        return 'P';
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
  }
}
static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
  if (ctx->head == NULL || ctx->head->field == &ctx->root) {
    const char* expected;
    const char* quote;
    if (ctx->head == NULL) {
      expected = "end";
      quote = "";
    } else {
      expected = ctx->head->field->type->name;
      quote = "'";
    }
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected %s%s%s but got %s",
                 quote, expected, quote,
                 __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
  } else {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_StructField* parent = (ctx->head - 1)->field;
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
                 field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
                 parent->type->name, field->name);
  }
}
static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
  char group;
  size_t size, offset, arraysize = 1;
  if (ctx->enc_type == 0) return 0;
  if (ctx->head->field->type->arraysize[0]) {
    int i, ndim = 0;
    if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
        ctx->is_valid_array = ctx->head->field->type->ndim == 1;
        ndim = 1;
        if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
            PyErr_Format(PyExc_ValueError,
                         "Expected a dimension of size %zu, got %zu",
                         ctx->head->field->type->arraysize[0], ctx->enc_count);
            return -1;
        }
    }
    if (!ctx->is_valid_array) {
      PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
                   ctx->head->field->type->ndim, ndim);
      return -1;
    }
    for (i = 0; i < ctx->head->field->type->ndim; i++) {
      arraysize *= ctx->head->field->type->arraysize[i];
    }
    ctx->is_valid_array = 0;
    ctx->enc_count = 1;
  }
  group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
  do {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_TypeInfo* type = field->type;
    if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
      size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
    } else {
      size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
    }
    if (ctx->enc_packmode == '@') {
      size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
      size_t align_mod_offset;
      if (align_at == 0) return -1;
      align_mod_offset = ctx->fmt_offset % align_at;
      if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
      if (ctx->struct_alignment == 0)
          ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
                                                                 ctx->is_complex);
    }
    if (type->size != size || type->typegroup != group) {
      if (type->typegroup == 'C' && type->fields != NULL) {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        ++ctx->head;
        ctx->head->field = type->fields;
        ctx->head->parent_offset = parent_offset;
        continue;
      }
      if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
      } else {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
      }
    }
    offset = ctx->head->parent_offset + field->offset;
    if (ctx->fmt_offset != offset) {
      PyErr_Format(PyExc_ValueError,
                   "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
                   (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
      return -1;
    }
    ctx->fmt_offset += size;
    if (arraysize)
      ctx->fmt_offset += (arraysize - 1) * size;
    --ctx->enc_count;
    while (1) {
      if (field == &ctx->root) {
        ctx->head = NULL;
        if (ctx->enc_count != 0) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
        }
        break;
      }
      ctx->head->field = ++field;
      if (field->type == NULL) {
        --ctx->head;
        field = ctx->head->field;
        continue;
      } else if (field->type->typegroup == 'S') {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        if (field->type->fields->type == NULL) continue;
        field = field->type->fields;
        ++ctx->head;
        ctx->head->field = field;
        ctx->head->parent_offset = parent_offset;
        break;
      } else {
        break;
      }
    }
  } while (ctx->enc_count);
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  return 0;
}
static CYTHON_INLINE PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
{
    const char *ts = *tsp;
    int i = 0, number;
    int ndim = ctx->head->field->type->ndim;
;
    ++ts;
    if (ctx->new_count != 1) {
        PyErr_SetString(PyExc_ValueError,
                        "Cannot handle repeated arrays in format string");
        return NULL;
    }
    if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
    while (*ts && *ts != ')') {
        switch (*ts) {
            case ' ': case '\f': case '\r': case '\n': case '\t': case '\v':  continue;
            default:  break;
        }
        number = __Pyx_BufFmt_ExpectNumber(&ts);
        if (number == -1) return NULL;
        if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
            return PyErr_Format(PyExc_ValueError,
                        "Expected a dimension of size %zu, got %d",
                        ctx->head->field->type->arraysize[i], number);
        if (*ts != ',' && *ts != ')')
            return PyErr_Format(PyExc_ValueError,
                                "Expected a comma in format string, got '%c'", *ts);
        if (*ts == ',') ts++;
        i++;
    }
    if (i != ndim)
        return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
                            ctx->head->field->type->ndim, i);
    if (!*ts) {
        PyErr_SetString(PyExc_ValueError,
                        "Unexpected end of format string, expected ')'");
        return NULL;
    }
    ctx->is_valid_array = 1;
    ctx->new_count = 1;
    *tsp = ++ts;
    return Py_None;
}
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
  int got_Z = 0;
  while (1) {
    switch(*ts) {
      case 0:
        if (ctx->enc_type != 0 && ctx->head == NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        if (ctx->head != NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
        return ts;
      case ' ':
      case '\r':
      case '\n':
        ++ts;
        break;
      case '<':
        if (!__Pyx_Is_Little_Endian()) {
          PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '>':
      case '!':
        if (__Pyx_Is_Little_Endian()) {
          PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '=':
      case '@':
      case '^':
        ctx->new_packmode = *ts++;
        break;
      case 'T':
        {
          const char* ts_after_sub;
          size_t i, struct_count = ctx->new_count;
          size_t struct_alignment = ctx->struct_alignment;
          ctx->new_count = 1;
          ++ts;
          if (*ts != '{') {
            PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
            return NULL;
          }
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0;
          ctx->enc_count = 0;
          ctx->struct_alignment = 0;
          ++ts;
          ts_after_sub = ts;
          for (i = 0; i != struct_count; ++i) {
            ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
            if (!ts_after_sub) return NULL;
          }
          ts = ts_after_sub;
          if (struct_alignment) ctx->struct_alignment = struct_alignment;
        }
        break;
      case '}':
        {
          size_t alignment = ctx->struct_alignment;
          ++ts;
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0;
          if (alignment && ctx->fmt_offset % alignment) {
            ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
          }
        }
        return ts;
      case 'x':
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        ctx->fmt_offset += ctx->new_count;
        ctx->new_count = 1;
        ctx->enc_count = 0;
        ctx->enc_type = 0;
        ctx->enc_packmode = ctx->new_packmode;
        ++ts;
        break;
      case 'Z':
        got_Z = 1;
        ++ts;
        if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
          __Pyx_BufFmt_RaiseUnexpectedChar('Z');
          return NULL;
        }
      case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
      case 'l': case 'L': case 'q': case 'Q':
      case 'f': case 'd': case 'g':
      case 'O': case 'p':
        if (ctx->enc_type == *ts && got_Z == ctx->is_complex &&
            ctx->enc_packmode == ctx->new_packmode) {
          ctx->enc_count += ctx->new_count;
          ctx->new_count = 1;
          got_Z = 0;
          ++ts;
          break;
        }
      case 's':
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        ctx->enc_count = ctx->new_count;
        ctx->enc_packmode = ctx->new_packmode;
        ctx->enc_type = *ts;
        ctx->is_complex = got_Z;
        ++ts;
        ctx->new_count = 1;
        got_Z = 0;
        break;
      case ':':
        ++ts;
        while(*ts != ':') ++ts;
        ++ts;
        break;
      case '(':
        if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
        break;
      default:
        {
          int number = __Pyx_BufFmt_ExpectNumber(&ts);
          if (number == -1) return NULL;
          ctx->new_count = (size_t)number;
        }
    }
  }
}
static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) {
  buf->buf = NULL;
  buf->obj = NULL;
  buf->strides = __Pyx_zeros;
  buf->shape = __Pyx_zeros;
  buf->suboffsets = __Pyx_minusones;
}
static CYTHON_INLINE int __Pyx_GetBufferAndValidate(
        Py_buffer* buf, PyObject* obj,  __Pyx_TypeInfo* dtype, int flags,
        int nd, int cast, __Pyx_BufFmt_StackElem* stack)
{
  if (obj == Py_None || obj == NULL) {
    __Pyx_ZeroBuffer(buf);
    return 0;
  }
  buf->buf = NULL;
  if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail;
  if (buf->ndim != nd) {
    PyErr_Format(PyExc_ValueError,
                 "Buffer has wrong number of dimensions (expected %d, got %d)",
                 nd, buf->ndim);
    goto fail;
  }
  if (!cast) {
    __Pyx_BufFmt_Context ctx;
    __Pyx_BufFmt_Init(&ctx, stack, dtype);
    if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
  }
  if ((unsigned)buf->itemsize != dtype->size) {
    PyErr_Format(PyExc_ValueError,
      "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)",
      buf->itemsize, (buf->itemsize > 1) ? "s" : "",
      dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
    goto fail;
  }
  if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
  return 0;
fail:;
  __Pyx_ZeroBuffer(buf);
  return -1;
}
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
  if (info->buf == NULL) return;
  if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
  __Pyx_ReleaseBuffer(info);
}

/* MemviewSliceInit */
            static int
__Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview,
                        int ndim,
                        __Pyx_memviewslice *memviewslice,
                        int memview_is_new_reference)
{
    __Pyx_RefNannyDeclarations
    int i, retval=-1;
    Py_buffer *buf = &memview->view;
    __Pyx_RefNannySetupContext("init_memviewslice", 0);
    if (!buf) {
        PyErr_SetString(PyExc_ValueError,
            "buf is NULL.");
        goto fail;
    } else if (memviewslice->memview || memviewslice->data) {
        PyErr_SetString(PyExc_ValueError,
            "memviewslice is already initialized!");
        goto fail;
    }
    if (buf->strides) {
        for (i = 0; i < ndim; i++) {
            memviewslice->strides[i] = buf->strides[i];
        }
    } else {
        Py_ssize_t stride = buf->itemsize;
        for (i = ndim - 1; i >= 0; i--) {
            memviewslice->strides[i] = stride;
            stride *= buf->shape[i];
        }
    }
    for (i = 0; i < ndim; i++) {
        memviewslice->shape[i]   = buf->shape[i];
        if (buf->suboffsets) {
            memviewslice->suboffsets[i] = buf->suboffsets[i];
        } else {
            memviewslice->suboffsets[i] = -1;
        }
    }
    memviewslice->memview = memview;
    memviewslice->data = (char *)buf->buf;
    if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) {
        Py_INCREF(memview);
    }
    retval = 0;
    goto no_fail;
fail:
    memviewslice->memview = 0;
    memviewslice->data = 0;
    retval = -1;
no_fail:
    __Pyx_RefNannyFinishContext();
    return retval;
}
static CYTHON_INLINE void __pyx_fatalerror(const char *fmt, ...) {
    va_list vargs;
    char msg[200];
#ifdef HAVE_STDARG_PROTOTYPES
    va_start(vargs, fmt);
#else
    va_start(vargs);
#endif
    vsnprintf(msg, 200, fmt, vargs);
    Py_FatalError(msg);
    va_end(vargs);
}
static CYTHON_INLINE int
__pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
                                   PyThread_type_lock lock)
{
    int result;
    PyThread_acquire_lock(lock, 1);
    result = (*acquisition_count)++;
    PyThread_release_lock(lock);
    return result;
}
static CYTHON_INLINE int
__pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
                                   PyThread_type_lock lock)
{
    int result;
    PyThread_acquire_lock(lock, 1);
    result = (*acquisition_count)--;
    PyThread_release_lock(lock);
    return result;
}
static CYTHON_INLINE void
__Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno)
{
    int first_time;
    struct __pyx_memoryview_obj *memview = memslice->memview;
    if (!memview || (PyObject *) memview == Py_None)
        return;
    if (__pyx_get_slice_count(memview) < 0)
        __pyx_fatalerror("Acquisition count is %d (line %d)",
                         __pyx_get_slice_count(memview), lineno);
    first_time = __pyx_add_acquisition_count(memview) == 0;
    if (first_time) {
        if (have_gil) {
            Py_INCREF((PyObject *) memview);
        } else {
            PyGILState_STATE _gilstate = PyGILState_Ensure();
            Py_INCREF((PyObject *) memview);
            PyGILState_Release(_gilstate);
        }
    }
}
static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice,
                                             int have_gil, int lineno) {
    int last_time;
    struct __pyx_memoryview_obj *memview = memslice->memview;
    if (!memview ) {
        return;
    } else if ((PyObject *) memview == Py_None) {
        memslice->memview = NULL;
        return;
    }
    if (__pyx_get_slice_count(memview) <= 0)
        __pyx_fatalerror("Acquisition count is %d (line %d)",
                         __pyx_get_slice_count(memview), lineno);
    last_time = __pyx_sub_acquisition_count(memview) == 1;
    memslice->data = NULL;
    if (last_time) {
        if (have_gil) {
            Py_CLEAR(memslice->memview);
        } else {
            PyGILState_STATE _gilstate = PyGILState_Ensure();
            Py_CLEAR(memslice->memview);
            PyGILState_Release(_gilstate);
        }
    } else {
        memslice->memview = NULL;
    }
}

/* DelItemInt */
            static CYTHON_INLINE int __Pyx_DelItem_Generic(PyObject *o, PyObject *j) {
    int r;
    if (!j) return -1;
    r = PyObject_DelItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i,
                                               CYTHON_UNUSED int is_list, CYTHON_NCP_UNUSED int wraparound) {
#if !CYTHON_USE_TYPE_SLOTS
    if (is_list || PySequence_Check(o)) {
        return PySequence_DelItem(o, i);
    }
#else
    PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
    if (likely(m && m->sq_ass_item)) {
        if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
            Py_ssize_t l = m->sq_length(o);
            if (likely(l >= 0)) {
                i += l;
            } else {
                if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                    return -1;
                PyErr_Clear();
            }
        }
        return m->sq_ass_item(o, i, (PyObject *)NULL);
    }
#endif
    return __Pyx_DelItem_Generic(o, PyInt_FromSsize_t(i));
}

/* PyFloatBinop */
            #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyFloat_TrueDivideCObj(PyObject *op1, PyObject *op2, double floatval, CYTHON_UNUSED int inplace) {
    const double a = floatval;
    double b, result;
    if (likely(PyFloat_CheckExact(op2))) {
        b = PyFloat_AS_DOUBLE(op2);
    } else
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op2))) {
        b = (double) PyInt_AS_LONG(op2);
    } else
    #endif
    if (likely(PyLong_CheckExact(op2))) {
        #if CYTHON_USE_PYLONG_INTERNALS
        const digit* digits = ((PyLongObject*)op2)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op2);
        switch (size) {
            case  0: b = 0.0; break;
            case -1: b = -(double) digits[0]; break;
            case  1: b = (double) digits[0]; break;
            case -2:
            case 2:
                if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) {
                    b = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -2)
                            b = -b;
                        break;
                    }
                }
            case -3:
            case 3:
                if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) {
                    b = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -3)
                            b = -b;
                        break;
                    }
                }
            case -4:
            case 4:
                if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) {
                    b = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -4)
                            b = -b;
                        break;
                    }
                }
            default:
        #else
        {
        #endif
            b = PyLong_AsDouble(op2);
            if (unlikely(b == -1.0 && PyErr_Occurred())) return NULL;
        }
    } else {
        return (inplace ? PyNumber_InPlaceTrueDivide : PyNumber_TrueDivide)(op1, op2);
    }
        PyFPE_START_PROTECT("divide", return NULL)
        result = a / b;
        PyFPE_END_PROTECT(result)
        return PyFloat_FromDouble(result);
}
#endif

/* Import */
              static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_VERSION_HEX < 0x03030000
    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, '.')) {
                #if PY_VERSION_HEX < 0x03030000
                PyObject *py_level = PyInt_FromLong(1);
                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, 1);
                #endif
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_VERSION_HEX < 0x03030000
            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_VERSION_HEX < 0x03030000
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* ImportFrom */
              static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* HasAttr */
              static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
    PyObject *r;
    if (unlikely(!__Pyx_PyBaseString_Check(n))) {
        PyErr_SetString(PyExc_TypeError,
                        "hasattr(): attribute name must be string");
        return -1;
    }
    r = __Pyx_GetAttr(o, n);
    if (unlikely(!r)) {
        PyErr_Clear();
        return 0;
    } else {
        Py_DECREF(r);
        return 1;
    }
}

/* decode_c_string */
              static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
         const char* cstring, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
    Py_ssize_t length;
    if (unlikely((start < 0) | (stop < 0))) {
        size_t slen = strlen(cstring);
        if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
            PyErr_SetString(PyExc_OverflowError,
                            "c-string too long to convert to Python");
            return NULL;
        }
        length = (Py_ssize_t) slen;
        if (start < 0) {
            start += length;
            if (start < 0)
                start = 0;
        }
        if (stop < 0)
            stop += length;
    }
    length = stop - start;
    if (unlikely(length <= 0))
        return PyUnicode_FromUnicode(NULL, 0);
    cstring += start;
    if (decode_func) {
        return decode_func(cstring, length, errors);
    } else {
        return PyUnicode_Decode(cstring, length, encoding, errors);
    }
}

/* PyErrExceptionMatches */
              #if CYTHON_FAST_THREAD_STATE
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;
    return PyErr_GivenExceptionMatches(exc_type, err);
}
#endif

/* 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;
    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;
    *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

/* None */
              static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
    long q = a / b;
    long r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

/* 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
}

/* CallNextTpDealloc */
              static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc) {
    PyTypeObject* type = Py_TYPE(obj);
    while (type && type->tp_dealloc != current_tp_dealloc)
        type = type->tp_base;
    while (type && type->tp_dealloc == current_tp_dealloc)
        type = type->tp_base;
    if (type)
        type->tp_dealloc(obj);
}

/* SetVTable */
              static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

/* SetupReduce */
              static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  int ret;
  PyObject *name_attr;
  name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2);
  if (likely(name_attr)) {
      ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  } else {
      ret = -1;
  }
  if (unlikely(ret < 0)) {
      PyErr_Clear();
      ret = 0;
  }
  Py_XDECREF(name_attr);
  return ret;
}
static int __Pyx_setup_reduce(PyObject* type_obj) {
    int ret = 0;
    PyObject *object_reduce = NULL;
    PyObject *object_reduce_ex = NULL;
    PyObject *reduce = NULL;
    PyObject *reduce_ex = NULL;
    PyObject *reduce_cython = NULL;
    PyObject *setstate = NULL;
    PyObject *setstate_cython = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
    if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD;
#else
    if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD;
#endif
#if CYTHON_USE_PYTYPE_LOOKUP
    object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
#else
    object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
#endif
    reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD;
    if (reduce_ex == object_reduce_ex) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
#else
        object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
#endif
        reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD;
        if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
            reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD;
            ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD;
            ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD;
            setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
            if (!setstate) PyErr_Clear();
            if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
                setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD;
                ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD;
                ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD;
            }
            PyType_Modified((PyTypeObject*)type_obj);
        }
    }
    goto GOOD;
BAD:
    if (!PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
    ret = -1;
GOOD:
#if !CYTHON_COMPILING_IN_CPYTHON
    Py_XDECREF(object_reduce);
    Py_XDECREF(object_reduce_ex);
#endif
    Py_XDECREF(reduce);
    Py_XDECREF(reduce_ex);
    Py_XDECREF(reduce_cython);
    Py_XDECREF(setstate);
    Py_XDECREF(setstate_cython);
    return ret;
}

/* GetVTable */
              static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

/* CalculateMetaclass */
              static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
    Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
    for (i=0; i < nbases; i++) {
        PyTypeObject *tmptype;
        PyObject *tmp = PyTuple_GET_ITEM(bases, i);
        tmptype = Py_TYPE(tmp);
#if PY_MAJOR_VERSION < 3
        if (tmptype == &PyClass_Type)
            continue;
#endif
        if (!metaclass) {
            metaclass = tmptype;
            continue;
        }
        if (PyType_IsSubtype(metaclass, tmptype))
            continue;
        if (PyType_IsSubtype(tmptype, metaclass)) {
            metaclass = tmptype;
            continue;
        }
        PyErr_SetString(PyExc_TypeError,
                        "metaclass conflict: "
                        "the metaclass of a derived class "
                        "must be a (non-strict) subclass "
                        "of the metaclasses of all its bases");
        return NULL;
    }
    if (!metaclass) {
#if PY_MAJOR_VERSION < 3
        metaclass = &PyClass_Type;
#else
        metaclass = &PyType_Type;
#endif
    }
    Py_INCREF((PyObject*) metaclass);
    return (PyObject*) metaclass;
}

/* FetchCommonType */
              static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
    PyObject* fake_module;
    PyTypeObject* cached_type = NULL;
    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
    if (!fake_module) return NULL;
    Py_INCREF(fake_module);
    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
    if (cached_type) {
        if (!PyType_Check((PyObject*)cached_type)) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s is not a type object",
                type->tp_name);
            goto bad;
        }
        if (cached_type->tp_basicsize != type->tp_basicsize) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s has the wrong size, try recompiling",
                type->tp_name);
            goto bad;
        }
    } else {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        if (PyType_Ready(type) < 0) goto bad;
        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
            goto bad;
        Py_INCREF(type);
        cached_type = type;
    }
done:
    Py_DECREF(fake_module);
    return cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

/* CythonFunction */
              static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (unlikely(op->func_doc == NULL)) {
        if (op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
            op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
            op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
            if (unlikely(op->func_doc == NULL))
                return NULL;
        } else {
            Py_INCREF(Py_None);
            return Py_None;
        }
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL) {
        value = Py_None;
    }
    Py_INCREF(value);
    op->func_doc = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
{
    if (unlikely(op->func_name == NULL)) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
        if (unlikely(op->func_name == NULL))
            return NULL;
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
{
    Py_INCREF(op->func_qualname);
    return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = op->func_qualname;
    Py_INCREF(value);
    op->func_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
{
    if (unlikely(op->func_dict == NULL)) {
        op->func_dict = PyDict_New();
        if (unlikely(op->func_dict == NULL))
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
    if (unlikely(value == NULL)) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (unlikely(!PyDict_Check(value))) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
{
    Py_INCREF(op->func_globals);
    return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
    int result = 0;
    PyObject *res = op->defaults_getter((PyObject *) op);
    if (unlikely(!res))
        return -1;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
    Py_INCREF(op->defaults_tuple);
    op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
    Py_INCREF(op->defaults_kwdict);
    #else
    op->defaults_tuple = PySequence_ITEM(res, 0);
    if (unlikely(!op->defaults_tuple)) result = -1;
    else {
        op->defaults_kwdict = PySequence_ITEM(res, 1);
        if (unlikely(!op->defaults_kwdict)) result = -1;
    }
    #endif
    Py_DECREF(res);
    return result;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyTuple_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__defaults__ must be set to a tuple object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_tuple;
    op->defaults_tuple = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
    PyObject* result = op->defaults_tuple;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_tuple;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__kwdefaults__ must be set to a dict object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_kwdict;
    op->defaults_kwdict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
    PyObject* result = op->defaults_kwdict;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_kwdict;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value || value == Py_None) {
        value = NULL;
    } else if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__annotations__ must be set to a dict object");
        return -1;
    }
    Py_XINCREF(value);
    tmp = op->func_annotations;
    op->func_annotations = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
    PyObject* result = op->func_annotations;
    if (unlikely(!result)) {
        result = PyDict_New();
        if (unlikely(!result)) return NULL;
        op->func_annotations = result;
    }
    Py_INCREF(result);
    return result;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
    {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
    {0, 0, 0, 0, 0}
};
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromString(m->func.m_ml->ml_name);
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
#if PY_VERSION_HEX < 0x030500A0
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
#else
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
#endif
static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
                                      PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
    if (op == NULL)
        return NULL;
    op->flags = flags;
    __Pyx_CyFunction_weakreflist(op) = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    Py_INCREF(qualname);
    op->func_qualname = qualname;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    op->func_globals = globals;
    Py_INCREF(op->func_globals);
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_kwdict = NULL;
    op->defaults_getter = NULL;
    op->func_annotations = NULL;
    PyObject_GC_Track(op);
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_qualname);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_globals);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    Py_CLEAR(m->defaults_kwdict);
    Py_CLEAR(m->func_annotations);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyObject_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    if (__Pyx_CyFunction_weakreflist(m) != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_qualname);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_globals);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    Py_VISIT(m->defaults_kwdict);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
    return __Pyx_PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                op->func_qualname, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(op->func_qualname), (void *)op);
#endif
}
static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = f->m_ml->ml_meth;
    Py_ssize_t size;
    switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
    case METH_VARARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0))
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 0))
                return (*meth)(self, NULL);
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    case METH_O:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 1)) {
                PyObject *result, *arg0 = PySequence_ITEM(arg, 0);
                if (unlikely(!arg0)) return NULL;
                result = (*meth)(self, arg0);
                Py_DECREF(arg0);
                return result;
            }
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    default:
        PyErr_SetString(PyExc_SystemError, "Bad call flags in "
                        "__Pyx_CyFunction_Call. METH_OLDARGS is no "
                        "longer supported!");
        return NULL;
    }
    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
                 f->m_ml->ml_name);
    return NULL;
}
static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
}
static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
    PyObject *result;
    __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
    if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
        Py_ssize_t argc;
        PyObject *new_args;
        PyObject *self;
        argc = PyTuple_GET_SIZE(args);
        new_args = PyTuple_GetSlice(args, 1, argc);
        if (unlikely(!new_args))
            return NULL;
        self = PyTuple_GetItem(args, 0);
        if (unlikely(!self)) {
            Py_DECREF(new_args);
            return NULL;
        }
        result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
        Py_DECREF(new_args);
    } else {
        result = __Pyx_CyFunction_Call(func, args, kw);
    }
    return result;
}
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "cython_function_or_method",
    sizeof(__pyx_CyFunctionObject),
    0,
    (destructor) __Pyx_CyFunction_dealloc,
    0,
    0,
    0,
#if PY_MAJOR_VERSION < 3
    0,
#else
    0,
#endif
    (reprfunc) __Pyx_CyFunction_repr,
    0,
    0,
    0,
    0,
    __Pyx_CyFunction_CallAsMethod,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
    0,
    (traverseproc) __Pyx_CyFunction_traverse,
    (inquiry) __Pyx_CyFunction_clear,
    0,
#if PY_VERSION_HEX < 0x030500A0
    offsetof(__pyx_CyFunctionObject, func_weakreflist),
#else
    offsetof(PyCFunctionObject, m_weakreflist),
#endif
    0,
    0,
    __pyx_CyFunction_methods,
    __pyx_CyFunction_members,
    __pyx_CyFunction_getsets,
    0,
    0,
    __Pyx_CyFunction_descr_get,
    0,
    offsetof(__pyx_CyFunctionObject, func_dict),
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#endif
};
static int __pyx_CyFunction_init(void) {
    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
    if (__pyx_CyFunctionType == NULL) {
        return -1;
    }
    return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyObject_Malloc(size);
    if (!m->defaults)
        return PyErr_NoMemory();
    memset(m->defaults, 0, size);
    m->defaults_pyobjects = pyobjects;
    return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_kwdict = dict;
    Py_INCREF(dict);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->func_annotations = dict;
    Py_INCREF(dict);
}

/* Py3ClassCreate */
                  static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
                                           PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
    PyObject *ns;
    if (metaclass) {
        PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
        if (prep) {
            PyObject *pargs = PyTuple_Pack(2, name, bases);
            if (unlikely(!pargs)) {
                Py_DECREF(prep);
                return NULL;
            }
            ns = PyObject_Call(prep, pargs, mkw);
            Py_DECREF(prep);
            Py_DECREF(pargs);
        } else {
            if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
                return NULL;
            PyErr_Clear();
            ns = PyDict_New();
        }
    } else {
        ns = PyDict_New();
    }
    if (unlikely(!ns))
        return NULL;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
    if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc_2, doc) < 0)) goto bad;
    return ns;
bad:
    Py_DECREF(ns);
    return NULL;
}
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
                                      PyObject *dict, PyObject *mkw,
                                      int calculate_metaclass, int allow_py2_metaclass) {
    PyObject *result, *margs;
    PyObject *owned_metaclass = NULL;
    if (allow_py2_metaclass) {
        owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
        if (owned_metaclass) {
            metaclass = owned_metaclass;
        } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
            PyErr_Clear();
        } else {
            return NULL;
        }
    }
    if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
        metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
        Py_XDECREF(owned_metaclass);
        if (unlikely(!metaclass))
            return NULL;
        owned_metaclass = metaclass;
    }
    margs = PyTuple_Pack(3, name, bases, dict);
    if (unlikely(!margs)) {
        result = NULL;
    } else {
        result = PyObject_Call(metaclass, margs, mkw);
        Py_DECREF(margs);
    }
    Py_XDECREF(owned_metaclass);
    return result;
}

/* CLineInTraceback */
                  static int __Pyx_CLineForTraceback(int c_line) {
#ifdef CYTHON_CLINE_IN_TRACEBACK
    return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0;
#else
    PyObject *use_cline;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
      use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
    } else
#endif
    {
      PyObject *ptype, *pvalue, *ptraceback;
      PyObject *use_cline_obj;
      PyErr_Fetch(&ptype, &pvalue, &ptraceback);
      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 {
        use_cline = NULL;
      }
      PyErr_Restore(ptype, pvalue, ptraceback);
    }
    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;
    }
    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;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(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(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        __pyx_d,      /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
    if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
        if (PyObject_TypeCheck(obj, __pyx_array_type)) return __pyx_array_getbuffer(obj, view, flags);
        if (PyObject_TypeCheck(obj, __pyx_memoryview_type)) return __pyx_memoryview_getbuffer(obj, view, flags);
    PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
    return -1;
}
static void __Pyx_ReleaseBuffer(Py_buffer *view) {
    PyObject *obj = view->obj;
    if (!obj) return;
    if (PyObject_CheckBuffer(obj)) {
        PyBuffer_Release(view);
        return;
    }
    if ((0)) {}
    view->obj = NULL;
    Py_DECREF(obj);
}
#endif


                  /* MemviewSliceIsContig */
                  static int
__pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs,
                             char order, int ndim)
{
    int i, index, step, start;
    Py_ssize_t itemsize = mvs.memview->view.itemsize;
    if (order == 'F') {
        step = 1;
        start = 0;
    } else {
        step = -1;
        start = ndim - 1;
    }
    for (i = 0; i < ndim; i++) {
        index = start + step * i;
        if (mvs.suboffsets[index] >= 0 || mvs.strides[index] != itemsize)
            return 0;
        itemsize *= mvs.shape[index];
    }
    return 1;
}

/* OverlappingSlices */
                  static void
__pyx_get_array_memory_extents(__Pyx_memviewslice *slice,
                               void **out_start, void **out_end,
                               int ndim, size_t itemsize)
{
    char *start, *end;
    int i;
    start = end = slice->data;
    for (i = 0; i < ndim; i++) {
        Py_ssize_t stride = slice->strides[i];
        Py_ssize_t extent = slice->shape[i];
        if (extent == 0) {
            *out_start = *out_end = start;
            return;
        } else {
            if (stride > 0)
                end += stride * (extent - 1);
            else
                start += stride * (extent - 1);
        }
    }
    *out_start = start;
    *out_end = end + itemsize;
}
static int
__pyx_slices_overlap(__Pyx_memviewslice *slice1,
                     __Pyx_memviewslice *slice2,
                     int ndim, size_t itemsize)
{
    void *start1, *end1, *start2, *end2;
    __pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize);
    __pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize);
    return (start1 < end2) && (start2 < end1);
}

/* Capsule */
                  static CYTHON_INLINE PyObject *
__pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig)
{
    PyObject *cobj;
#if PY_VERSION_HEX >= 0x02070000
    cobj = PyCapsule_New(p, sig, NULL);
#else
    cobj = PyCObject_FromVoidPtr(p, NULL);
#endif
    return cobj;
}

/* CIntFromPyVerify */
                  #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

/* CIntToPy */
                  static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
                  static CYTHON_INLINE PyObject* __Pyx_PyInt_From_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);
    }
}

/* MemviewDtypeToObject */
                  static CYTHON_INLINE PyObject *__pyx_memview_get_Py_ssize_t(const char *itemp) {
    return (PyObject *) PyInt_FromSsize_t(*(Py_ssize_t *) itemp);
}
static CYTHON_INLINE int __pyx_memview_set_Py_ssize_t(const char *itemp, PyObject *obj) {
    Py_ssize_t value = __Pyx_PyIndex_AsSsize_t(obj);
    if ((value == (Py_ssize_t)-1) && PyErr_Occurred())
        return 0;
    *(Py_ssize_t *) itemp = value;
    return 1;
}

/* MemviewDtypeToObject */
                  static CYTHON_INLINE PyObject *__pyx_memview_get_int(const char *itemp) {
    return (PyObject *) __Pyx_PyInt_From_int(*(int *) itemp);
}
static CYTHON_INLINE int __pyx_memview_set_int(const char *itemp, PyObject *obj) {
    int value = __Pyx_PyInt_As_int(obj);
    if ((value == (int)-1) && PyErr_Occurred())
        return 0;
    *(int *) itemp = value;
    return 1;
}

/* Declarations */
                  #if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return ::std::complex< float >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return x + y*(__pyx_t_float_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      __pyx_t_float_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

/* Arithmetic */
                  #if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    #if 1
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        if (b.imag == 0) {
            return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else if (fabsf(b.real) >= fabsf(b.imag)) {
            if (b.real == 0 && b.imag == 0) {
                return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag);
            } else {
                float r = b.imag / b.real;
                float s = 1.0 / (b.real + b.imag * r);
                return __pyx_t_float_complex_from_parts(
                    (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
            }
        } else {
            float r = b.real / b.imag;
            float s = 1.0 / (b.imag + b.real * r);
            return __pyx_t_float_complex_from_parts(
                (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
        }
    }
    #else
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        if (b.imag == 0) {
            return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else {
            float denom = b.real * b.real + b.imag * b.imag;
            return __pyx_t_float_complex_from_parts(
                (a.real * b.real + a.imag * b.imag) / denom,
                (a.imag * b.real - a.real * b.imag) / denom);
        }
    }
    #endif
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrtf(z.real*z.real + z.imag*z.imag);
          #else
            return hypotf(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
            __pyx_t_float_complex z;
            float r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    float denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        z = __Pyx_c_prod_float(a, a);
                        return __Pyx_c_prod_float(a, a);
                    case 3:
                        z = __Pyx_c_prod_float(a, a);
                        return __Pyx_c_prod_float(z, a);
                    case 4:
                        z = __Pyx_c_prod_float(a, a);
                        return __Pyx_c_prod_float(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                } else if (b.imag == 0) {
                    z.real = powf(a.real, b.real);
                    z.imag = 0;
                    return z;
                } else if (a.real > 0) {
                    r = a.real;
                    theta = 0;
                } else {
                    r = -a.real;
                    theta = atan2f(0, -1);
                }
            } else {
                r = __Pyx_c_abs_float(a);
                theta = atan2f(a.imag, a.real);
            }
            lnr = logf(r);
            z_r = expf(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cosf(z_theta);
            z.imag = z_r * sinf(z_theta);
            return z;
        }
    #endif
#endif

/* 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

/* MemviewSliceCopyTemplate */
                  static __Pyx_memviewslice
__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
                                 const char *mode, int ndim,
                                 size_t sizeof_dtype, int contig_flag,
                                 int dtype_is_object)
{
    __Pyx_RefNannyDeclarations
    int i;
    __Pyx_memviewslice new_mvs = { 0, 0, { 0 }, { 0 }, { 0 } };
    struct __pyx_memoryview_obj *from_memview = from_mvs->memview;
    Py_buffer *buf = &from_memview->view;
    PyObject *shape_tuple = NULL;
    PyObject *temp_int = NULL;
    struct __pyx_array_obj *array_obj = NULL;
    struct __pyx_memoryview_obj *memview_obj = NULL;
    __Pyx_RefNannySetupContext("__pyx_memoryview_copy_new_contig", 0);
    for (i = 0; i < ndim; i++) {
        if (from_mvs->suboffsets[i] >= 0) {
            PyErr_Format(PyExc_ValueError, "Cannot copy memoryview slice with "
                                           "indirect dimensions (axis %d)", i);
            goto fail;
        }
    }
    shape_tuple = PyTuple_New(ndim);
    if (unlikely(!shape_tuple)) {
        goto fail;
    }
    __Pyx_GOTREF(shape_tuple);
    for(i = 0; i < ndim; i++) {
        temp_int = PyInt_FromSsize_t(from_mvs->shape[i]);
        if(unlikely(!temp_int)) {
            goto fail;
        } else {
            PyTuple_SET_ITEM(shape_tuple, i, temp_int);
            temp_int = NULL;
        }
    }
    array_obj = __pyx_array_new(shape_tuple, sizeof_dtype, buf->format, (char *) mode, NULL);
    if (unlikely(!array_obj)) {
        goto fail;
    }
    __Pyx_GOTREF(array_obj);
    memview_obj = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
                                    (PyObject *) array_obj, contig_flag,
                                    dtype_is_object,
                                    from_mvs->memview->typeinfo);
    if (unlikely(!memview_obj))
        goto fail;
    if (unlikely(__Pyx_init_memviewslice(memview_obj, ndim, &new_mvs, 1) < 0))
        goto fail;
    if (unlikely(__pyx_memoryview_copy_contents(*from_mvs, new_mvs, ndim, ndim,
                                                dtype_is_object) < 0))
        goto fail;
    goto no_fail;
fail:
    __Pyx_XDECREF(new_mvs.memview);
    new_mvs.memview = NULL;
    new_mvs.data = NULL;
no_fail:
    __Pyx_XDECREF(shape_tuple);
    __Pyx_XDECREF(temp_int);
    __Pyx_XDECREF(array_obj);
    __Pyx_RefNannyFinishContext();
    return new_mvs;
}

/* CIntFromPy */
                  static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) -1, const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

/* CIntFromPy */
                  static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
    const size_t neg_one = (size_t) -1, const_zero = (size_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(size_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (size_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (size_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
                            return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
                            return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
                            return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (size_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(size_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (size_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(size_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                            return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                            return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
                            return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(size_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            size_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (size_t) -1;
        }
    } else {
        size_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (size_t) -1;
        val = __Pyx_PyInt_As_size_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to size_t");
    return (size_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to size_t");
    return (size_t) -1;
}

/* CIntFromPy */
                  static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

/* CIntFromPy */
                  static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
    const char neg_one = (char) -1, const_zero = (char) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(char) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (char) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (char) 0;
                case  1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0])
                case 2:
                    if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) {
                            return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) {
                            return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) {
                            return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (char) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(char) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (char) 0;
                case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(char,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
                            return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
                            return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
                            return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
                            return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
                            return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
                            return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(char) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            char val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (char) -1;
        }
    } else {
        char val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (char) -1;
        val = __Pyx_PyInt_As_char(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to char");
    return (char) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to char");
    return (char) -1;
}

/* CoroutineBase */
                  #include <structmember.h>
#include <frameobject.h>
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_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
#if 1 || PY_VERSION_HEX < 0x030300B0
static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) {
    PyObject *et, *ev, *tb;
    PyObject *value = NULL;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __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 (!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
            value = ev;
        }
        if (likely(value)) {
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = value;
            return 0;
        }
    } else if (!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;
}
#endif
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);
}
static CYTHON_INLINE
int __Pyx_Coroutine_CheckRunning(__pyx_CoroutineObject *gen) {
    if (unlikely(gen->is_running)) {
        PyErr_SetString(PyExc_ValueError,
                        "generator already executing");
        return 1;
    }
    return 0;
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value) {
    PyObject *retval;
    __Pyx_PyThreadState_declare
    assert(!self->is_running);
    if (unlikely(self->resume_label == 0)) {
        if (unlikely(value && value != Py_None)) {
            PyErr_SetString(PyExc_TypeError,
                            "can't send non-None value to a "
                            "just-started generator");
            return NULL;
        }
    }
    if (unlikely(self->resume_label == -1)) {
        PyErr_SetNone(PyExc_StopIteration);
        return NULL;
    }
    __Pyx_PyThreadState_assign
    if (value) {
#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(__pyx_tstate->frame);
            assert(f->f_back == NULL);
            f->f_back = __pyx_tstate->frame;
        }
#endif
        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
                            &self->exc_traceback);
    } else {
        __Pyx_Coroutine_ExceptionClear(self);
    }
    self->is_running = 1;
    retval = self->body((PyObject *) self, value);
    self->is_running = 0;
    if (retval) {
        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
                            &self->exc_traceback);
#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_CLEAR(f->f_back);
        }
#endif
    } else {
        __Pyx_Coroutine_ExceptionClear(self);
    }
    return retval;
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_MethodReturn(PyObject *retval) {
    if (unlikely(!retval && !PyErr_Occurred())) {
        PyErr_SetNone(PyExc_StopIteration);
    }
    return retval;
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
    PyObject *ret;
    PyObject *val = NULL;
    __Pyx_Coroutine_Undelegate(gen);
    __Pyx_PyGen_FetchStopIterationValue(&val);
    ret = __Pyx_Coroutine_SendEx(gen, val);
    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(__Pyx_Coroutine_CheckRunning(gen)))
        return NULL;
    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_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Send(yf, 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);
    }
    return __Pyx_Coroutine_MethodReturn(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_CheckExact(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } 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(__Pyx_Coroutine_CheckRunning(gen)))
        return NULL;
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Generator_Next(yf);
        } 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);
}
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(__Pyx_Coroutine_CheckRunning(gen)))
        return NULL;
    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);
    if (retval) {
        Py_DECREF(retval);
        PyErr_SetString(PyExc_RuntimeError,
                        "generator ignored GeneratorExit");
        return NULL;
    }
    raised_exception = PyErr_Occurred();
    if (!raised_exception
        || raised_exception == PyExc_StopIteration
        || raised_exception == PyExc_GeneratorExit
        || PyErr_GivenExceptionMatches(raised_exception, PyExc_GeneratorExit)
        || PyErr_GivenExceptionMatches(raised_exception, PyExc_StopIteration))
    {
        if (raised_exception) PyErr_Clear();
        Py_INCREF(Py_None);
        return Py_None;
    }
    return NULL;
}
static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *typ;
    PyObject *tb = NULL;
    PyObject *val = NULL;
    PyObject *yf = gen->yieldfrom;
    if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
        return NULL;
    if (unlikely(__Pyx_Coroutine_CheckRunning(gen)))
        return NULL;
    if (yf) {
        PyObject *ret;
        Py_INCREF(yf);
        if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit)) {
            int err = __Pyx_Coroutine_CloseIter(gen, yf);
            Py_DECREF(yf);
            __Pyx_Coroutine_Undelegate(gen);
            if (err < 0)
                return __Pyx_Coroutine_MethodReturn(__Pyx_Coroutine_SendEx(gen, NULL));
            goto throw_here;
        }
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Throw(yf, args);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Throw(yf, args);
        } else
        #endif
        {
            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;
            }
            ret = PyObject_CallObject(meth, args);
            Py_DECREF(meth);
        }
        gen->is_running = 0;
        Py_DECREF(yf);
        if (!ret) {
            ret = __Pyx_Coroutine_FinishDelegation(gen);
        }
        return __Pyx_Coroutine_MethodReturn(ret);
    }
throw_here:
    __Pyx_Raise(typ, val, tb, NULL);
    return __Pyx_Coroutine_MethodReturn(__Pyx_Coroutine_SendEx(gen, NULL));
}
static int __Pyx_Coroutine_traverse(PyObject *self, visitproc visit, void *arg) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    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);
    Py_CLEAR(gen->gi_name);
    Py_CLEAR(gen->gi_qualname);
    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
        if (PyObject_CallFinalizerFromDealloc(self))
#else
        Py_TYPE(gen)->tp_del(self);
        if (self->ob_refcnt > 0)
#endif
        {
            return;
        }
        PyObject_GC_UnTrack(self);
    }
    __Pyx_Coroutine_clear(self);
    PyObject_GC_Del(gen);
}
static void __Pyx_Coroutine_del(PyObject *self) {
    PyObject *res;
    PyObject *error_type, *error_value, *error_traceback;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    __Pyx_PyThreadState_declare
    if (gen->resume_label <= 0)
        return ;
#if PY_VERSION_HEX < 0x030400a1
    assert(self->ob_refcnt == 0);
    self->ob_refcnt = 1;
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
    res = __Pyx_Coroutine_Close(self);
    if (res == NULL)
        PyErr_WriteUnraisable(self);
    else
        Py_DECREF(res);
    __Pyx_ErrRestore(error_type, error_value, error_traceback);
#if PY_VERSION_HEX < 0x030400a1
    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 *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
    if (gen == NULL)
        return NULL;
    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;
    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_VERSION_HEX >= 0x03030000) ? "collections.abc" : "collections");
        if (!module) {
            PyErr_WriteUnraisable(NULL);
            if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
                    ((PY_VERSION_HEX >= 0x03030000) ?
                        "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")},
    {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 PY_VERSION_HEX >= 0x030400a1
    0,
#else
    __Pyx_Coroutine_del,
#endif
    0,
#if PY_VERSION_HEX >= 0x030400a1
    __Pyx_Coroutine_del,
#endif
};
static int __pyx_Generator_init(void) {
    __pyx_GeneratorType_type.tp_getattro = PyObject_GenericGetAttr;
    __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
    __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
    if (unlikely(!__pyx_GeneratorType)) {
        return -1;
    }
    return 0;
}

/* TypeInfoCompare */
                      static int
__pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b)
{
    int i;
    if (!a || !b)
        return 0;
    if (a == b)
        return 1;
    if (a->size != b->size || a->typegroup != b->typegroup ||
            a->is_unsigned != b->is_unsigned || a->ndim != b->ndim) {
        if (a->typegroup == 'H' || b->typegroup == 'H') {
            return a->size == b->size;
        } else {
            return 0;
        }
    }
    if (a->ndim) {
        for (i = 0; i < a->ndim; i++)
            if (a->arraysize[i] != b->arraysize[i])
                return 0;
    }
    if (a->typegroup == 'S') {
        if (a->flags != b->flags)
            return 0;
        if (a->fields || b->fields) {
            if (!(a->fields && b->fields))
                return 0;
            for (i = 0; a->fields[i].type && b->fields[i].type; i++) {
                __Pyx_StructField *field_a = a->fields + i;
                __Pyx_StructField *field_b = b->fields + i;
                if (field_a->offset != field_b->offset ||
                    !__pyx_typeinfo_cmp(field_a->type, field_b->type))
                    return 0;
            }
            return !a->fields[i].type && !b->fields[i].type;
        }
    }
    return 1;
}

/* MemviewSliceValidateAndInit */
                      static int
__pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec)
{
    if (buf->shape[dim] <= 1)
        return 1;
    if (buf->strides) {
        if (spec & __Pyx_MEMVIEW_CONTIG) {
            if (spec & (__Pyx_MEMVIEW_PTR|__Pyx_MEMVIEW_FULL)) {
                if (buf->strides[dim] != sizeof(void *)) {
                    PyErr_Format(PyExc_ValueError,
                                 "Buffer is not indirectly contiguous "
                                 "in dimension %d.", dim);
                    goto fail;
                }
            } else if (buf->strides[dim] != buf->itemsize) {
                PyErr_SetString(PyExc_ValueError,
                                "Buffer and memoryview are not contiguous "
                                "in the same dimension.");
                goto fail;
            }
        }
        if (spec & __Pyx_MEMVIEW_FOLLOW) {
            Py_ssize_t stride = buf->strides[dim];
            if (stride < 0)
                stride = -stride;
            if (stride < buf->itemsize) {
                PyErr_SetString(PyExc_ValueError,
                                "Buffer and memoryview are not contiguous "
                                "in the same dimension.");
                goto fail;
            }
        }
    } else {
        if (spec & __Pyx_MEMVIEW_CONTIG && dim != ndim - 1) {
            PyErr_Format(PyExc_ValueError,
                         "C-contiguous buffer is not contiguous in "
                         "dimension %d", dim);
            goto fail;
        } else if (spec & (__Pyx_MEMVIEW_PTR)) {
            PyErr_Format(PyExc_ValueError,
                         "C-contiguous buffer is not indirect in "
                         "dimension %d", dim);
            goto fail;
        } else if (buf->suboffsets) {
            PyErr_SetString(PyExc_ValueError,
                            "Buffer exposes suboffsets but no strides");
            goto fail;
        }
    }
    return 1;
fail:
    return 0;
}
static int
__pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec)
{
    if (spec & __Pyx_MEMVIEW_DIRECT) {
        if (buf->suboffsets && buf->suboffsets[dim] >= 0) {
            PyErr_Format(PyExc_ValueError,
                         "Buffer not compatible with direct access "
                         "in dimension %d.", dim);
            goto fail;
        }
    }
    if (spec & __Pyx_MEMVIEW_PTR) {
        if (!buf->suboffsets || (buf->suboffsets && buf->suboffsets[dim] < 0)) {
            PyErr_Format(PyExc_ValueError,
                         "Buffer is not indirectly accessible "
                         "in dimension %d.", dim);
            goto fail;
        }
    }
    return 1;
fail:
    return 0;
}
static int
__pyx_verify_contig(Py_buffer *buf, int ndim, int c_or_f_flag)
{
    int i;
    if (c_or_f_flag & __Pyx_IS_F_CONTIG) {
        Py_ssize_t stride = 1;
        for (i = 0; i < ndim; i++) {
            if (stride * buf->itemsize != buf->strides[i] &&
                    buf->shape[i] > 1)
            {
                PyErr_SetString(PyExc_ValueError,
                    "Buffer not fortran contiguous.");
                goto fail;
            }
            stride = stride * buf->shape[i];
        }
    } else if (c_or_f_flag & __Pyx_IS_C_CONTIG) {
        Py_ssize_t stride = 1;
        for (i = ndim - 1; i >- 1; i--) {
            if (stride * buf->itemsize != buf->strides[i] &&
                    buf->shape[i] > 1) {
                PyErr_SetString(PyExc_ValueError,
                    "Buffer not C contiguous.");
                goto fail;
            }
            stride = stride * buf->shape[i];
        }
    }
    return 1;
fail:
    return 0;
}
static int __Pyx_ValidateAndInit_memviewslice(
                int *axes_specs,
                int c_or_f_flag,
                int buf_flags,
                int ndim,
                __Pyx_TypeInfo *dtype,
                __Pyx_BufFmt_StackElem stack[],
                __Pyx_memviewslice *memviewslice,
                PyObject *original_obj)
{
    struct __pyx_memoryview_obj *memview, *new_memview;
    __Pyx_RefNannyDeclarations
    Py_buffer *buf;
    int i, spec = 0, retval = -1;
    __Pyx_BufFmt_Context ctx;
    int from_memoryview = __pyx_memoryview_check(original_obj);
    __Pyx_RefNannySetupContext("ValidateAndInit_memviewslice", 0);
    if (from_memoryview && __pyx_typeinfo_cmp(dtype, ((struct __pyx_memoryview_obj *)
                                                            original_obj)->typeinfo)) {
        memview = (struct __pyx_memoryview_obj *) original_obj;
        new_memview = NULL;
    } else {
        memview = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
                                            original_obj, buf_flags, 0, dtype);
        new_memview = memview;
        if (unlikely(!memview))
            goto fail;
    }
    buf = &memview->view;
    if (buf->ndim != ndim) {
        PyErr_Format(PyExc_ValueError,
                "Buffer has wrong number of dimensions (expected %d, got %d)",
                ndim, buf->ndim);
        goto fail;
    }
    if (new_memview) {
        __Pyx_BufFmt_Init(&ctx, stack, dtype);
        if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
    }
    if ((unsigned) buf->itemsize != dtype->size) {
        PyErr_Format(PyExc_ValueError,
                     "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "u byte%s) "
                     "does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "u byte%s)",
                     buf->itemsize,
                     (buf->itemsize > 1) ? "s" : "",
                     dtype->name,
                     dtype->size,
                     (dtype->size > 1) ? "s" : "");
        goto fail;
    }
    for (i = 0; i < ndim; i++) {
        spec = axes_specs[i];
        if (!__pyx_check_strides(buf, i, ndim, spec))
            goto fail;
        if (!__pyx_check_suboffsets(buf, i, ndim, spec))
            goto fail;
    }
    if (buf->strides && !__pyx_verify_contig(buf, ndim, c_or_f_flag))
        goto fail;
    if (unlikely(__Pyx_init_memviewslice(memview, ndim, memviewslice,
                                         new_memview != NULL) == -1)) {
        goto fail;
    }
    retval = 0;
    goto no_fail;
fail:
    Py_XDECREF(new_memview);
    retval = -1;
no_fail:
    __Pyx_RefNannyFinishContext();
    return retval;
}

/* ObjectToMemviewSlice */
                      static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_Py_ssize_t(PyObject *obj) {
    __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
    __Pyx_BufFmt_StackElem stack[1];
    int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
    int retcode;
    if (obj == Py_None) {
        result.memview = (struct __pyx_memoryview_obj *) Py_None;
        return result;
    }
    retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
                                                 PyBUF_RECORDS, 1,
                                                 &__Pyx_TypeInfo_Py_ssize_t, stack,
                                                 &result, obj);
    if (unlikely(retcode == -1))
        goto __pyx_fail;
    return result;
__pyx_fail:
    result.memview = NULL;
    result.data = NULL;
    return result;
}

/* ObjectToMemviewSlice */
                      static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_int(PyObject *obj) {
    __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
    __Pyx_BufFmt_StackElem stack[1];
    int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
    int retcode;
    if (obj == Py_None) {
        result.memview = (struct __pyx_memoryview_obj *) Py_None;
        return result;
    }
    retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
                                                 PyBUF_RECORDS, 2,
                                                 &__Pyx_TypeInfo_int, stack,
                                                 &result, obj);
    if (unlikely(retcode == -1))
        goto __pyx_fail;
    return result;
__pyx_fail:
    result.memview = NULL;
    result.data = NULL;
    return result;
}

/* ObjectToMemviewSlice */
                      static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_int(PyObject *obj) {
    __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
    __Pyx_BufFmt_StackElem stack[1];
    int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
    int retcode;
    if (obj == Py_None) {
        result.memview = (struct __pyx_memoryview_obj *) Py_None;
        return result;
    }
    retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
                                                 PyBUF_RECORDS, 1,
                                                 &__Pyx_TypeInfo_int, stack,
                                                 &result, obj);
    if (unlikely(retcode == -1))
        goto __pyx_fail;
    return result;
__pyx_fail:
    result.memview = NULL;
    result.data = NULL;
    return result;
}

/* CheckBinaryVersion */
                      static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

/* FunctionExport */
                      static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
    if (!d) {
        PyErr_Clear();
        d = PyDict_New();
        if (!d)
            goto bad;
        Py_INCREF(d);
        if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
            goto bad;
    }
    tmp.fp = f;
#if PY_VERSION_HEX >= 0x02070000
    cobj = PyCapsule_New(tmp.p, sig, 0);
#else
    cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
#endif
    if (!cobj)
        goto bad;
    if (PyDict_SetItemString(d, name, cobj) < 0)
        goto bad;
    Py_DECREF(cobj);
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(cobj);
    Py_XDECREF(d);
    return -1;
}

/* ModuleImport */
                      #ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;
    py_name = __Pyx_PyIdentifier_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

/* TypeImport */
                      #ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    py_name = __Pyx_PyIdentifier_FromString(class_name);
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if (!strict && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
            module_name, class_name, basicsize, size);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    else if ((size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
            module_name, class_name, basicsize, size);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

/* FunctionImport */
                      #ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C function %.200s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

/* InitStrings */
                      static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        if (PyObject_Hash(*t->p) == -1)
            PyErr_Clear();
        ++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);
}
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if CYTHON_COMPILING_IN_CPYTHON && (__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)) {
#if PY_VERSION_HEX < 0x03030000
        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
        if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        if (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
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE 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 (PyInt_Check(x) || PyLong_Check(x))
#else
  if (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 = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
  #else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
  #endif
#else
  res = PyNumber_Int(x);
#endif
  if (res) {
#if PY_MAJOR_VERSION < 3
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%.4s__ returned non-%.4s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(x);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
