/* Generated by Cython 0.24 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "define_macros": [
            [
                "_GLIBCXX_USE_CXX11_ABI",
                "0"
            ]
        ],
        "depends": [],
        "include_dirs": [
            "/usr/local/cuda/include"
        ],
        "language": "c++",
        "libraries": [
            "cublas",
            "cuda",
            "cudart",
            "curand",
            "nvToolsExt"
        ],
        "library_dirs": [
            "/usr/local/cuda/lib64"
        ],
        "runtime_library_dirs": [
            "/usr/local/cuda/lib64"
        ]
    }
}
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_24"
#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
#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_CPYTHON 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
#endif
#if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000
  #define CYTHON_USE_PYLONG_INTERNALS 1
#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 > 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_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_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
#else
  #define CYTHON_PEP393_ENABLED 0
  #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_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_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(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
#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)
#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
#if PY_VERSION_HEX >= 0x030500B1
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
#elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
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))
#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
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)

#ifndef __cplusplus
  #error "Cython files generated with the C++ option must be compiled with a C++ compiler."
#endif
#ifndef CYTHON_INLINE
  #define CYTHON_INLINE inline
#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; }
    operator T&() { return *ptr; }
  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


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

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#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_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#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 char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE 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_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((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_COMPILING_IN_CPYTHON
#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 PyObject *__pyx_m;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "cupy/core/elementwise.pxi",
  "cupy/core/core.pyx",
  "cupy/core/carray.pxi",
  "cupy/core/reduction.pxi",
  "stringsource",
  "type.pxd",
  "bool.pxd",
  "complex.pxd",
  "cupy/cuda/runtime.pxd",
  "cupy/cuda/device.pxd",
  "cupy/cuda/memory.pxd",
  "cupy/cuda/function.pxd",
};

/*--- Type declarations ---*/
struct __pyx_obj_4cupy_4cuda_7runtime_PointerAttributes;
struct __pyx_obj_4cupy_4cuda_6device_Device;
struct __pyx_obj_4cupy_4cuda_6memory_Memory;
struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer;
struct __pyx_obj_4cupy_4cuda_6memory_PooledMemory;
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_4core_4core_ndarray;
struct __pyx_obj_4cupy_4core_4core_CArray;
struct __pyx_obj_4cupy_4core_4core_CIndexer;
struct __pyx_obj_4cupy_4core_4core_Indexer;
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_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":20
 * ###############################################################################
 * 
 * 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
};
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_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_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":119
 * 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":122
 *                         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_4cuda_6memory_set_allocator;

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

/* "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_4core_7ndarray_tofile;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype;
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_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_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_ascontiguousarray;
struct __pyx_opt_args_4cupy_4core_4core_rollaxis;
struct __pyx_opt_args_4cupy_4core_4core__repeat;
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__diagonal;
struct __pyx_opt_args_4cupy_4core_4core_dot;
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;

/* "cupy/core/core.pyx":236
 *     # TODO(okuta): Implement tobytes
 * 
 *     cpdef tofile(self, fid, sep='', format='%s'):             # <<<<<<<<<<<<<<
 *         """Writes the array to a file.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tofile {
  int __pyx_n;
  PyObject *sep;
  PyObject *format;
};

/* "cupy/core/core.pyx":257
 *         return six.moves.cPickle.dumps(self, -1)
 * 
 *     cpdef ndarray astype(self, dtype, copy=True):             # <<<<<<<<<<<<<<
 *         """Casts the array to given data type.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype {
  int __pyx_n;
  PyObject *copy;
};

/* "cupy/core/core.pyx":314
 *         return newarray
 * 
 *     cpdef ndarray view(self, dtype=None):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view {
  int __pyx_n;
  PyObject *dtype;
};

/* "cupy/core/core.pyx":514
 *         return self._reshape(shape)
 * 
 *     cpdef ndarray squeeze(self, axis=None):             # <<<<<<<<<<<<<<
 *         """Returns a view with size-one axes removed.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_squeeze {
  int __pyx_n;
  PyObject *axis;
};

/* "cupy/core/core.pyx":589
 *     # Item selection and manipulation
 *     # -------------------------------------------------------------------------
 *     cpdef ndarray take(self, indices, axis=None, out=None):             # <<<<<<<<<<<<<<
 *         """Returns an array of elements at given indices along the axis.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_take {
  int __pyx_n;
  PyObject *axis;
  PyObject *out;
};

/* "cupy/core/core.pyx":601
 *     # TODO(okuta): Implement put
 * 
 *     cpdef repeat(self, repeats, axis=None):             # <<<<<<<<<<<<<<
 *         """Returns an array with repeated arrays along an axis.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_repeat {
  int __pyx_n;
  PyObject *axis;
};

/* "cupy/core/core.pyx":656
 *     # TODO(okuta): Implement compress
 * 
 *     cpdef ndarray diagonal(self, offset=0, axis1=0, axis2=1):             # <<<<<<<<<<<<<<
 *         """Returns a view of the specified diagonals.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_diagonal {
  int __pyx_n;
  PyObject *offset;
  PyObject *axis1;
  PyObject *axis2;
};

/* "cupy/core/core.pyx":669
 *     # Calculation
 *     # -------------------------------------------------------------------------
 *     cpdef ndarray max(self, axis=None, out=None, dtype=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the maximum along a given axis.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_max {
  int __pyx_n;
  PyObject *axis;
  PyObject *out;
  PyObject *dtype;
  PyObject *keepdims;
};

/* "cupy/core/core.pyx":680
 *             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.
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmax {
  int __pyx_n;
  PyObject *axis;
  PyObject *out;
  PyObject *dtype;
  PyObject *keepdims;
};

/* "cupy/core/core.pyx":692
 *             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.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_min {
  int __pyx_n;
  PyObject *axis;
  PyObject *out;
  PyObject *dtype;
  PyObject *keepdims;
};

/* "cupy/core/core.pyx":703
 *             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.
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmin {
  int __pyx_n;
  PyObject *axis;
  PyObject *out;
  PyObject *dtype;
  PyObject *keepdims;
};

/* "cupy/core/core.pyx":717
 *     # TODO(okuta): Implement ptp
 * 
 *     cpdef ndarray clip(self, a_min, a_max, out=None):             # <<<<<<<<<<<<<<
 *         """Returns an array with values limited to [a_min, a_max].
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_clip {
  int __pyx_n;
  PyObject *out;
};

/* "cupy/core/core.pyx":729
 *     # 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.
 */
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.pyx":741
 *         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.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sum {
  int __pyx_n;
  PyObject *axis;
  PyObject *dtype;
  PyObject *out;
  PyObject *keepdims;
};

/* "cupy/core/core.pyx":753
 *     # TODO(okuta): Implement cumsum
 * 
 *     cpdef ndarray mean(self, axis=None, dtype=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the mean along a given axis.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_mean {
  int __pyx_n;
  PyObject *axis;
  PyObject *dtype;
  PyObject *out;
  PyObject *keepdims;
};

/* "cupy/core/core.pyx":763
 *         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.
 */
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.pyx":774
 *         return _var(self, axis=axis, dtype=dtype, out=out, keepdims=keepdims)
 * 
 *     cpdef ndarray std(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the standard deviation along a given axis.
 */
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.pyx":785
 *         return _std(self, axis=axis, dtype=dtype, out=out, keepdims=keepdims)
 * 
 *     cpdef ndarray prod(self, axis=None, dtype=None, out=None, keepdims=None):             # <<<<<<<<<<<<<<
 *         """Returns the product along a given axis.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_prod {
  int __pyx_n;
  PyObject *axis;
  PyObject *dtype;
  PyObject *out;
  PyObject *keepdims;
};

/* "cupy/core/core.pyx":797
 *     # TODO(okuta): Implement cumprod
 * 
 *     cpdef ndarray all(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         return _all(self, axis=axis, out=out, keepdims=keepdims)
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_all {
  int __pyx_n;
  PyObject *axis;
  PyObject *out;
  PyObject *keepdims;
};

/* "cupy/core/core.pyx":800
 *         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)
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_any {
  int __pyx_n;
  PyObject *axis;
  PyObject *out;
  PyObject *keepdims;
};

/* "cupy/core/core.pyx":1246
 *         return self.data.device
 * 
 *     cpdef get(self, stream=None):             # <<<<<<<<<<<<<<
 *         """Returns a copy of the array on host memory.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_get {
  int __pyx_n;
  PyObject *stream;
};

/* "cupy/core/core.pyx":1266
 *         return a_cpu
 * 
 *     cpdef set(self, arr, stream=None):             # <<<<<<<<<<<<<<
 *         """Copies an array on the host memory to :class:`cupy.ndarray`.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set {
  int __pyx_n;
  PyObject *stream;
};

/* "cupy/core/core.pyx":1292
 *             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.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_reduced_view {
  int __pyx_n;
  PyObject *dtype;
};

/* "cupy/core/core.pyx":1346
 *         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):
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides {
  int __pyx_n;
  int update_c_contiguity;
};

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

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

/* "cupy/core/carray.pxi":84
 * 
 * 
 * cpdef function.Module compile_with_cache(             # <<<<<<<<<<<<<<
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _get_header_source() + 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":13
 * 
 * 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":368
 * 
 * 
 * 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":780
 * 
 * 
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc=''):             # <<<<<<<<<<<<<<
 *     _ops = []
 *     for t in ops:
 */
struct __pyx_opt_args_4cupy_4core_4core_create_ufunc {
  int __pyx_n;
  PyObject *routine;
  PyObject *preamble;
  PyObject *doc;
};

/* "cupy/core/reduction.pxi":448
 * 
 * 
 * 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":1621
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, Py_ssize_t ndmin=0):             # <<<<<<<<<<<<<<
 *     # TODO(beam2d): Support order and subok options
 *     cdef Py_ssize_t nvidem
 */
struct __pyx_opt_args_4cupy_4core_4core_array {
  int __pyx_n;
  PyObject *dtype;
  int copy;
  Py_ssize_t ndmin;
};

/* "cupy/core/core.pyx":1648
 * 
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         if a._c_contiguous:
 */
struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray {
  int __pyx_n;
  PyObject *dtype;
};

/* "cupy/core/core.pyx":1666
 * # -----------------------------------------------------------------------------
 * 
 * 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":1798
 * 
 * 
 * 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":1879
 * # -----------------------------------------------------------------------------
 * 
 * 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":2006
 * 
 * 
 * cpdef ndarray _take(ndarray a, indices, axis=None, ndarray out=None):             # <<<<<<<<<<<<<<
 *     if a.ndim == 0:
 *         a = a[None]
 */
struct __pyx_opt_args_4cupy_4core_4core__take {
  int __pyx_n;
  PyObject *axis;
  struct __pyx_obj_4cupy_4core_4core_ndarray *out;
};

/* "cupy/core/core.pyx":2064
 * 
 * 
 * cpdef ndarray _diagonal(ndarray a, Py_ssize_t offset=0, Py_ssize_t axis1=0,             # <<<<<<<<<<<<<<
 *                         Py_ssize_t axis2=1):
 *     if axis1 < axis2:
 */
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":2180
 * # -----------------------------------------------------------------------------
 * 
 * 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":2562
 * # -----------------------------------------------------------------------------
 * 
 * cpdef create_comparison(name, op, doc=''):             # <<<<<<<<<<<<<<
 *     return create_ufunc(
 *         'cupy_' + name,
 */
struct __pyx_opt_args_4cupy_4core_4core_create_comparison {
  int __pyx_n;
  PyObject *doc;
};

/* "cupy/core/core.pyx":2820
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                    keepdims=False):
 *     if axis is None:
 */
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":2844
 * 
 * 
 * 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;
};

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


/* "device.pxd":4
 * cpdef get_cublas_handle()
 * 
 * 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":3
 * from cupy.cuda cimport device
 * 
 * cdef class Memory:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_6memory_Memory {
  PyObject_HEAD
  struct __pyx_obj_4cupy_4cuda_6device_Device *device;
  size_t ptr;
  Py_ssize_t size;
};


/* "memory.pxd":11
 * 
 * 
 * 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":36
 * 
 * 
 * cdef class PooledMemory(Memory):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_6memory_PooledMemory {
  struct __pyx_obj_4cupy_4cuda_6memory_Memory __pyx_base;
  struct __pyx_vtabstruct_4cupy_4cuda_6memory_PooledMemory *__pyx_vtab;
  PyObject *pool;
};


/* "memory.pxd":44
 * 
 * 
 * cdef class SingleDeviceMemoryPool:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4cuda_6memory_SingleDeviceMemoryPool *__pyx_vtab;
  PyObject *_alloc;
  PyObject *_in_use;
  PyObject *_free;
  PyObject *__weakref__;
  PyObject *_weakref;
  Py_ssize_t _allocation_unit_size;
};


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


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


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


/* "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/core/core.pyx":34
 * 
 * 
 * cdef class ndarray:             # <<<<<<<<<<<<<<
 * 
 *     """Multi-dimensional array on a CUDA device.
 */
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/carray.pxi":14
 * 
 * 
 * cdef class CArray(cupy.cuda.function.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":34
 * 
 * 
 * cdef class CIndexer(cupy.cuda.function.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/carray.pxi":51
 * 
 * 
 * cdef class Indexer:             # <<<<<<<<<<<<<<
 *     cdef:
 *         public Py_ssize_t size
 */
struct __pyx_obj_4cupy_4core_4core_Indexer {
  PyObject_HEAD
  Py_ssize_t size;
  PyObject *shape;
};


/* "cupy/core/elementwise.pxi":219
 * 
 * 
 * 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":412
 * 
 * 
 * cdef class ElementwiseKernel:             # <<<<<<<<<<<<<<
 * 
 *     """User-defined elementwise kernel.
 */
struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel {
  PyObject_HEAD
  PyObject *in_params;
  PyObject *out_params;
  int nin;
  int nout;
  int nargs;
  PyObject *params;
  PyObject *operation;
  PyObject *name;
  int reduce_dims;
  PyObject *preamble;
  PyObject *kwargs;
};


/* "cupy/core/core.pyx":1689
 * 
 * 
 * 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":390
 * 
 * @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":394
 *     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":665
 * 
 *     """
 *     def __init__(self, name, nin, nout, ops, preamble='', doc=''):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self.nin = nin
 */
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":674
 *         self.__doc__ = doc
 *         _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":677
 *             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 *);
};



/* "device.pxd":4
 * cpdef get_cublas_handle()
 * 
 * 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":11
 * 
 * 
 * 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, PyObject *, int __pyx_skip_dispatch);
  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, PyObject *, int __pyx_skip_dispatch);
  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, PyObject *, int __pyx_skip_dispatch);
  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, PyObject *, int __pyx_skip_dispatch);
  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, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *__pyx_vtabptr_4cupy_4cuda_6memory_MemoryPointer;


/* "memory.pxd":36
 * 
 * 
 * cdef class PooledMemory(Memory):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_4cupy_4cuda_6memory_PooledMemory {
  PyObject *(*free)(struct __pyx_obj_4cupy_4cuda_6memory_PooledMemory *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4cupy_4cuda_6memory_PooledMemory *__pyx_vtabptr_4cupy_4cuda_6memory_PooledMemory;


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

struct __pyx_vtabstruct_4cupy_4cuda_6memory_SingleDeviceMemoryPool {
  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);
  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);
};
static struct __pyx_vtabstruct_4cupy_4cuda_6memory_SingleDeviceMemoryPool *__pyx_vtabptr_4cupy_4cuda_6memory_SingleDeviceMemoryPool;


/* "memory.pxd":61
 * 
 * 
 * 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);
  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);
};
static struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPool *__pyx_vtabptr_4cupy_4cuda_6memory_MemoryPool;


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


/* "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/core/core.pyx":34
 * 
 * 
 * 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_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);
  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 *, PyObject *, PyObject *, 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);
  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);
};
static struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *__pyx_vtabptr_4cupy_4core_4core_ndarray;

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

/* PyObjectGetAttrStr.proto */
#if CYTHON_COMPILING_IN_CPYTHON
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);

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

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

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

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

/* PyObjectLookupSpecial.proto */
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000
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_COMPILING_IN_CPYTHON
#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_COMPILING_IN_CPYTHON
#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

/* PyIntBinop.proto */
#if CYTHON_COMPILING_IN_CPYTHON
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);

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

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

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

/* SliceObject.proto */
#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);

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

/* ListAppend.proto */
#if CYTHON_COMPILING_IN_CPYTHON
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)))

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

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

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

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

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

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

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

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

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

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

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

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

/* 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) : __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_COMPILING_IN_CPYTHON
    return PyFrozenSet_Type.tp_new(&PyFrozenSet_Type, __pyx_empty_tuple, NULL);
#else
    return PyObject_Call((PyObject*)&PyFrozenSet_Type, __pyx_empty_tuple, NULL);
#endif
}

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

/* PyIntBinop.proto */
#if CYTHON_COMPILING_IN_CPYTHON
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

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

/* PyIntBinop.proto */
#if CYTHON_COMPILING_IN_CPYTHON
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

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

/* pop_index.proto */
static PyObject* __Pyx__PyObject_PopNewIndex(PyObject* L, PyObject* py_ix);
static PyObject* __Pyx__PyObject_PopIndex(PyObject* L, PyObject* py_ix);
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyList_PopIndex(PyObject* L, PyObject* py_ix, Py_ssize_t ix);
#define __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) (\
    (likely(PyList_CheckExact(L) && __Pyx_fits_Py_ssize_t(ix, type, is_signed))) ?\
        __Pyx__PyList_PopIndex(L, py_ix, ix) : (\
        (unlikely(py_ix == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) :\
            __Pyx__PyObject_PopIndex(L, py_ix)))
#define __Pyx_PyList_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) (\
    __Pyx_fits_Py_ssize_t(ix, type, is_signed) ?\
        __Pyx__PyList_PopIndex(L, py_ix, ix) : (\
        (unlikely(py_ix == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) :\
            __Pyx__PyObject_PopIndex(L, py_ix)))
#else
#define __Pyx_PyList_PopIndex(L, py_ix, ix, is_signed, type, to_py_func)\
    __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func)
#define __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) (\
    (unlikely(py_ix == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) :\
        __Pyx__PyObject_PopIndex(L, py_ix))
#endif

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

/* PyFloatBinop.proto */
#if CYTHON_COMPILING_IN_CPYTHON
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

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

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

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

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

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

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

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

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

/* SwapException.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#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

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

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

/* 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); /* 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 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, PyObject *__pyx_v_a_min, PyObject *__pyx_v_a_max, 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 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*/

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

/* Module declarations from 'libcpp' */

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

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

/* Module declarations from 'cupy.cuda.cublas' */
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_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*/

/* 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.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 PyObject *(*__pyx_f_4cupy_4cuda_6device_get_cublas_handle)(int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.cuda.memory' */
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_Memory = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_MemoryPointer = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_PooledMemory = 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;

/* Module declarations from 'cupy.core.core' */
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_ndarray = 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_Indexer = 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 PyObject *__pyx_v_4cupy_4core_4core_newaxis = 0;
static PyObject *__pyx_v_4cupy_4core_4core__header_source = 0;
static PyObject *__pyx_v_4cupy_4core_4core__typenames_base = 0;
static PyObject *__pyx_v_4cupy_4core_4core__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__amin = 0;
static PyObject *__pyx_v_4cupy_4core_4core__amax = 0;
static PyObject *__pyx_v_4cupy_4core_4core__argmin = 0;
static PyObject *__pyx_v_4cupy_4core_4core__argmax = 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__boolean_array_indexing_nth = 0;
static PyObject *__pyx_v_4cupy_4core_4core__cuda_runtime_version = 0;
static PyObject *__pyx_v_4cupy_4core_4core__all = 0;
static PyObject *__pyx_v_4cupy_4core_4core__any = 0;
static PyObject *__pyx_v_4cupy_4core_4core__sum = 0;
static PyObject *__pyx_v_4cupy_4core_4core__prod = 0;
static PyObject *__pyx_v_4cupy_4core_4core__clip = 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 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 CYTHON_INLINE struct __pyx_obj_4cupy_4core_4core_CIndexer *__pyx_f_4cupy_4core_4core_to_cindexer(Py_ssize_t, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_header_source(int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_f_4cupy_4core_4core_compile_with_cache(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_simple_elementwise_kernel(PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__get_simple_elementwise_kernel *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__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_ascontiguousarray(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_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(PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__create_bit_op(PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__create_bit_op *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__boolean_array_indexing(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__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 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 struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__adv_getitem(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); /*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 PyObject *__pyx_convert_vector_to_py_Py_ssize_t(const std::vector<Py_ssize_t>  &); /*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_size_t(const std::vector<size_t>  &); /*proto*/
#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_object;
static PyObject *__pyx_builtin_property;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_IndexError;
static PyObject *__pyx_builtin_NotImplemented;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_Ellipsis;
static PyObject *__pyx_builtin_sum;
static PyObject *__pyx_builtin_oct;
static PyObject *__pyx_builtin_hex;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_open;
static PyObject *__pyx_builtin_Exception;
static PyObject *__pyx_builtin_map;
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_zip;
static const char __pyx_k_0[] = "0";
static const char __pyx_k_B[] = "B->?";
static const char __pyx_k_H[] = "H->?";
static const char __pyx_k_I[] = "I->?";
static const char __pyx_k_L[] = "L->?";
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_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_x[] = "x";
static const char __pyx_k_BB[] = "BB->?";
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__4[] = "";
static const char __pyx_k_bb[] = "bb->?";
static const char __pyx_k_dd[] = "dd->?";
static const char __pyx_k_ee[] = "ee->?";
static const char __pyx_k_ff[] = "ff->?";
static const char __pyx_k_hh[] = "hh->?";
static const char __pyx_k_ii[] = "ii->?";
static const char __pyx_k_ll[] = "ll->?";
static const char __pyx_k_op[] = "op";
static const char __pyx_k_os[] = "os";
static const char __pyx_k_qq[] = "qq->?";
static const char __pyx_k_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_l[] = "B->l";
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_l[] = "H->l";
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_l[] = "I->l";
static const char __pyx_k_L_L[] = "L->L";
static const char __pyx_k_L_d[] = "L->d";
static const char __pyx_k_L_l[] = "L->l";
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_l[] = "Q->l";
static const char __pyx_k__33[] = ", ";
static const char __pyx_k__34[] = ",";
static const char __pyx_k__44[] = "\n";
static const char __pyx_k__53[] = "->";
static const char __pyx_k__83[] = "\077\077->?";
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_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_l[] = "d->l";
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_l[] = "e->l";
static const char __pyx_k_f_2[] = "f->?";
static const char __pyx_k_f_f[] = "f->f";
static const char __pyx_k_f_l[] = "f->l";
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_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_in0[] = "in0";
static const char __pyx_k_int[] = "int";
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_map[] = "map";
static const char __pyx_k_max[] = "max";
static const char __pyx_k_min[] = "min";
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_q_d[] = "q->d";
static const char __pyx_k_q_l[] = "q->l";
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_HH_H[] = "HH->H";
static const char __pyx_k_HH_d[] = "HH->d";
static const char __pyx_k_II_I[] = "II->I";
static const char __pyx_k_II_d[] = "II->d";
static const char __pyx_k_LL_L[] = "LL->L";
static const char __pyx_k_LL_d[] = "LL->d";
static const char __pyx_k_QQ_Q[] = "QQ->Q";
static const char __pyx_k_QQ_d[] = "QQ->d";
static const char __pyx_k__154[] = "_";
static const char __pyx_k__173[] = "?->?";
static const char __pyx_k__216[] = "&";
static const char __pyx_k__217[] = "|";
static const char __pyx_k__218[] = "^";
static const char __pyx_k__222[] = "<<";
static const char __pyx_k__223[] = ">>";
static const char __pyx_k__227[] = ">";
static const char __pyx_k__228[] = ">=";
static const char __pyx_k__229[] = "<";
static const char __pyx_k__230[] = "<=";
static const char __pyx_k__231[] = "==";
static const char __pyx_k__232[] = "!=";
static const char __pyx_k__244[] = "+";
static const char __pyx_k__248[] = "*";
static const char __pyx_k__259[] = "-";
static const char __pyx_k__281[] = "\077\077?->?";
static const char __pyx_k_arch[] = "arch";
static const char __pyx_k_args[] = "args";
static const char __pyx_k_axis[] = "axis";
static const char __pyx_k_bb_b[] = "bb->b";
static const char __pyx_k_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_copy[] = "copy";
static const char __pyx_k_cuda[] = "cuda";
static const char __pyx_k_cupy[] = "cupy_";
static const char __pyx_k_dd_d[] = "dd->d";
static const char __pyx_k_ddof[] = "ddof";
static const char __pyx_k_dump[] = "dump";
static const char __pyx_k_ee_e[] = "ee->e";
static const char __pyx_k_exit[] = "__exit__";
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_init[] = "__init__";
static const char __pyx_k_int8[] = "int8";
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_mean[] = "mean";
static const char __pyx_k_name[] = "name";
static const char __pyx_k_ndim[] = "ndim";
static const char __pyx_k_nout[] = "nout";
static const char __pyx_k_open[] = "open";
static const char __pyx_k_path[] = "path";
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_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_scan[] = "scan";
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_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_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_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_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_close[] = "close";
static const char __pyx_k_const[] = "const ";
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_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_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_index[] = "index";
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_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_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_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_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_std_2[] = "_std";
static const char __pyx_k_strip[] = "strip";
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_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_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_extend[] = "extend";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_in_str[] = "in_str";
static const char __pyx_k_insert[] = "insert";
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_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_a[] = "out0 = a";
static const char __pyx_k_params[] = "params";
static const char __pyx_k_remove[] = "remove";
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_string[] = "string";
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_unsafe[] = "unsafe";
static const char __pyx_k_T_out_d[] = "T out%d";
static const char __pyx_k_cPickle[] = "cPickle";
static const char __pyx_k_casting[] = "casting";
static const char __pyx_k_data_as[] = "data_as";
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_genexpr[] = "genexpr";
static const char __pyx_k_greater[] = "greater";
static const char __pyx_k_in_args[] = "in_args";
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_memoize[] = "memoize";
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_prepare[] = "__prepare__";
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_s_s_s_s[] = "%s%s %s%s";
static const char __pyx_k_shape_2[] = "_shape";
static const char __pyx_k_six_zip[] = "six_zip";
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_c_void_p[] = "c_void_p";
static const char __pyx_k_can_cast[] = "can_cast";
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_identity[] = "identity";
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_kern_add[] = "kern_add";
static const char __pyx_k_map_expr[] = "map_expr";
static const char __pyx_k_module_2[] = "module";
static const char __pyx_k_multiply[] = "multiply";
static const char __pyx_k_negative[] = "negative";
static const char __pyx_k_newshape[] = "newshape";
static const char __pyx_k_out0_in0[] = "out0 = in0";
static const char __pyx_k_out_args[] = "out_args";
static const char __pyx_k_params_2[] = "_params";
static const char __pyx_k_preamble[] = "preamble";
static const char __pyx_k_property[] = "property";
static const char __pyx_k_qualname[] = "__qualname__";
static const char __pyx_k_rtruediv[] = "__rtruediv__";
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_Exception[] = "Exception";
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_cupy_clip[] = "cupy_clip";
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_mean[] = "cupy_mean";
static const char __pyx_k_cupy_prod[] = "cupy_prod";
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_enumerate[] = "enumerate";
static const char __pyx_k_in_params[] = "in_params";
static const char __pyx_k_kern_scan[] = "kern_scan";
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_raw_T_out[] = "raw T out";
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_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_carray_cuh[] = "carray.cuh";
static const char __pyx_k_clp2_count[] = "clp2_count";
static const char __pyx_k_cupy_power[] = "cupy_power";
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_vtable[] = "__pyx_vtable__";
static const char __pyx_k_shared_mem[] = "shared_mem";
static const char __pyx_k_substitute[] = "substitute";
static const char __pyx_k_bitwise_and[] = "bitwise_and";
static const char __pyx_k_bitwise_xor[] = "bitwise_xor";
static const char __pyx_k_blocked_sum[] = "blocked_sum";
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_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_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_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_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_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_reduced_view[] = "reduced_view";
static const char __pyx_k_sgemmBatched[] = "sgemmBatched";
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_bhilqBHILQefd[] = "?bhilqBHILQefd";
static const char __pyx_k_boolean_array[] = "boolean_array";
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_dfeqlihbQLIHB[] = "dfeqlihbQLIHB?";
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_fabs_in0[] = "out0 = fabs(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_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_Shape_mismatch[] = "Shape mismatch";
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_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_types_preamble[] = "types_preamble";
static const char __pyx_k_unsigned_short[] = "unsigned short";
static const char __pyx_k_ReductionKernel[] = "ReductionKernel";
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_for_each_device[] = "for_each_device";
static const char __pyx_k_if_in1_out0_in0[] = "if (in1) out0 = in0";
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_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_out_of_range[] = "Axis out of range";
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_nonzero_1d_kernel[] = "_nonzero_1d_kernel";
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_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_compile_with_cache[] = "compile_with_cache";
static const char __pyx_k_decide_params_type[] = "_decide_params_type";
static const char __pyx_k_elementwise_copy_2[] = "_elementwise_copy";
static const char __pyx_k_incompatible_shape[] = "incompatible shape";
static const char __pyx_k_out0_in0_0_in0_in0[] = "out0 = in0 > 0 ? in0 : -in0";
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_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_const_0_1__raw__1__j[] = "const {0} {1} = _raw_{1}[_j];";
static const char __pyx_k_get_reduction_kernel[] = "_get_reduction_kernel";
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_Output_dtype_mismatch[] = "Output dtype mismatch";
static const char __pyx_k_Output_shape_mismatch[] = "Output shape mismatch";
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_ReductionKernel___call[] = "ReductionKernel.__call__";
static const char __pyx_k_ReductionKernel___init[] = "ReductionKernel.__init__";
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_Axis_dimension_mismatch[] = "Axis dimension mismatch";
static const char __pyx_k_Out_shape_is_mismatched[] = "Out shape is mismatched";
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_Type_is_mismatched_s_s_s[] = "Type is mismatched. %s %s %s";
static const char __pyx_k_elementwise_copy_where_2[] = "elementwise_copy_where";
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_const_t_n__raw__n__ind_get[] = "const {t} {n} = _raw_{n}[_ind.get()];";
static const char __pyx_k_if_boolean_array_out_nth_a[] = "if (boolean_array) out[nth] = a";
static const char __pyx_k_out0__floor_divide_in0_in1[] = "out0 = _floor_divide(in0, in1)";
static const char __pyx_k_too_many_indices_for_array[] = "too many indices for array";
static const char __pyx_k_1_out_0__raw_out_0__ind_get[] = "{1} &out{0} = _raw_out{0}[_ind.get()];";
static const char __pyx_k_add_scan_blocked_sum_kernel[] = "add_scan_blocked_sum_kernel";
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_boolean_array_S_nth[] = "T a, bool boolean_array, S nth";
static const char __pyx_k_array_cannot_be_set_to_array[] = "{} array cannot be set to {} array";
static const char __pyx_k_Wrong_type_of_arguments_for_s[] = "Wrong type of arguments for %s";
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_ndarray___getitem___line_1016[] = "ndarray.__getitem__ (line 1016)";
static const char __pyx_k_ufunc___init___locals_genexpr[] = "ufunc.__init__.<locals>.genexpr";
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_min_max_st_type_in0_raw_in0__J[] = "min_max_st<type_in0_raw>(in0, _J)";
static const char __pyx_k_repeats_should_not_be_negative[] = "'repeats' should not be negative: {}";
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_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_Input_type_must_be_cupy_ndarray[] = "Input type must be cupy.ndarray";
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      int li = i / (rdim * cdim);\n      int ri = i % rdim;\n      out = a[(li * adim + wrap_indices) * rdim + ri];\n    ";
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_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_Wrong_number_of_arguments_for_s[] = "Wrong number 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_should_be_specified_if_rep[] = "'axis' should be specified if 'repeats' is sequence";
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_cupy_boolean_array_indexing_nth[] = "cupy_boolean_array_indexing_nth";
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_home_beam2d_src_github_com_pfne[] = "/home/beam2d/src/github.com/pfnet/chainer/cupy/core/elementwise.pxi";
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_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_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_Adds_two_arrays_elementwise_seea[] = "Adds two arrays elementwise.\n\n    .. seealso:: :data:`numpy.add`\n\n    ";
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_Boolean_array_indexing_is_suppor[] = "Boolean array indexing is supported only for same sized array.";
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_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_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_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_basic_indexing_is_supported[] = "Only basic indexing is supported for __setitem__";
static const char __pyx_k_Only_numpy_ndarray_can_be_set_to[] = "Only numpy.ndarray can be set to cupy.ndarray";
static const char __pyx_k_Output_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_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_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_Universal_function_Attributes_na[] = "Universal function.\n\n    Attributes:\n        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_arrays_used_as_indices_must_be_o[] = "arrays used as indices must be of integer or boolean type. (actual: {})";
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_input_operand_has_more_dimension[] = "input operand has more dimensions than allowed by the axis remapping";
static const char __pyx_k_only_integers_slices_ellipsis_nu[] = "only integers, slices (`:`), ellipsis (`...`),numpy.newaxis (`None`) and integer orboolean arrays are valid indices";
static const char __pyx_k_out0_a__in_ind_size__out_ind_siz[] = "out0 = a / (_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_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_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_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_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_x___getitem___y_x_y_note_CuPy_ha[] = "x.__getitem__(y) <==> x[y]\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_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        int 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_home_beam2d_src_github_com_pfne_2[] = "/home/beam2d/src/github.com/pfnet/chainer/cupy/core/reduction.pxi";
static const char __pyx_k_home_beam2d_src_github_com_pfne_3[] = "/home/beam2d/src/github.com/pfnet/chainer/cupy/core/core.pyx";
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_kp_s_1_out_0__raw_out_0__ind_get;
static PyObject *__pyx_kp_s_Adds_two_arrays_elementwise_seea;
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_kp_s_Axis_dimension_mismatch;
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_l;
static PyObject *__pyx_kp_s_Boolean_array_indexing_is_suppor;
static PyObject *__pyx_kp_s_Broadcasting_failed;
static PyObject *__pyx_kp_s_CArray_s_d;
static PyObject *__pyx_n_s_CIndexer;
static PyObject *__pyx_kp_s_CIndexer__in_ind_CIndexer__out_i;
static PyObject *__pyx_kp_s_CIndexer__ind;
static PyObject *__pyx_kp_s_CIndexer_d;
static PyObject *__pyx_kp_s_Can_not_use_i_as_a_parameter_nam;
static PyObject *__pyx_kp_s_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_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_n_s_Exception;
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_l;
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_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_l;
static PyObject *__pyx_kp_s_Illegal_conditions;
static PyObject *__pyx_n_s_IndexError;
static PyObject *__pyx_kp_s_Index_s_is_out_of_bounds_for_axi;
static PyObject *__pyx_kp_s_Input_array_should_be_1D_array;
static PyObject *__pyx_kp_s_Input_type_must_be_cupy_ndarray;
static PyObject *__pyx_kp_s_Invalid_axes_value_s;
static PyObject *__pyx_kp_s_Invalid_index_type_s;
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_l;
static PyObject *__pyx_kp_s_Loop_size_is_Undecided;
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_kp_s_Only_basic_indexing_is_supported;
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_shape_is_mismatched;
static PyObject *__pyx_kp_s_Output_arguments_must_be_cupy_nd;
static PyObject *__pyx_kp_s_Output_arguments_type_must_be_cu;
static PyObject *__pyx_kp_s_Output_array_has_an_invalid_size;
static PyObject *__pyx_kp_s_Output_array_must_be_C_contiguou;
static PyObject *__pyx_kp_s_Output_array_size_is_Undecided;
static PyObject *__pyx_kp_s_Output_dtype_mismatch;
static PyObject *__pyx_kp_s_Output_shape_mismatch;
static PyObject *__pyx_n_s_PY3;
static PyObject *__pyx_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_l;
static PyObject *__pyx_n_s_ReductionKernel;
static PyObject *__pyx_n_s_ReductionKernel___call;
static PyObject *__pyx_n_s_ReductionKernel___init;
static PyObject *__pyx_n_s_RuntimeError;
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_n_s_Sequence;
static PyObject *__pyx_kp_s_Shape_mismatch;
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_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_bool_boolean_array_S_nth;
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_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_truth_value_of_an_array_with;
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_Universal_function_Attributes_na;
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_Wrong_arguments_s;
static PyObject *__pyx_kp_s_Wrong_number_of_arguments_for_s;
static PyObject *__pyx_kp_s_Wrong_type_of_arguments_for_s;
static PyObject *__pyx_kp_s_Wrong_type_s;
static PyObject *__pyx_n_s__154;
static PyObject *__pyx_kp_s__173;
static PyObject *__pyx_kp_s__216;
static PyObject *__pyx_kp_s__217;
static PyObject *__pyx_kp_s__218;
static PyObject *__pyx_kp_s__222;
static PyObject *__pyx_kp_s__223;
static PyObject *__pyx_kp_s__227;
static PyObject *__pyx_kp_s__228;
static PyObject *__pyx_kp_s__229;
static PyObject *__pyx_kp_s__230;
static PyObject *__pyx_kp_s__231;
static PyObject *__pyx_kp_s__232;
static PyObject *__pyx_kp_s__244;
static PyObject *__pyx_kp_s__248;
static PyObject *__pyx_kp_s__259;
static PyObject *__pyx_kp_s__281;
static PyObject *__pyx_kp_s__33;
static PyObject *__pyx_kp_s__34;
static PyObject *__pyx_kp_s__4;
static PyObject *__pyx_kp_s__44;
static PyObject *__pyx_kp_s__53;
static PyObject *__pyx_kp_s__83;
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_absolute;
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_kp_s_all_elements_of_repeats_should_n;
static PyObject *__pyx_n_s_any;
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_arr;
static PyObject *__pyx_n_s_array;
static PyObject *__pyx_kp_s_array_cannot_be_set_to_array;
static PyObject *__pyx_n_s_array_priority;
static PyObject *__pyx_n_s_arrays;
static PyObject *__pyx_kp_s_arrays_used_as_indices_must_be_o;
static PyObject *__pyx_n_s_ascontiguousarray;
static PyObject *__pyx_n_s_astype;
static PyObject *__pyx_n_s_axis;
static PyObject *__pyx_n_s_axis1;
static PyObject *__pyx_n_s_axis2;
static PyObject *__pyx_kp_s_axis_entry_d_is_out_of_bounds_d;
static PyObject *__pyx_kp_s_axis_should_be_specified_if_rep;
static PyObject *__pyx_n_s_b;
static PyObject *__pyx_kp_s_b_b;
static PyObject *__pyx_kp_s_b_b_2;
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_bhilqBHILQefd;
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_blocked_sum;
static PyObject *__pyx_n_s_bool;
static PyObject *__pyx_n_s_bool_2;
static PyObject *__pyx_n_s_boolean_array;
static PyObject *__pyx_n_s_broad;
static PyObject *__pyx_n_s_broad_shape;
static PyObject *__pyx_n_s_cPickle;
static PyObject *__pyx_n_s_c_void_p;
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_kp_s_carray_cuh;
static PyObject *__pyx_n_s_casting;
static PyObject *__pyx_n_s_char;
static PyObject *__pyx_n_s_clip;
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_kp_s_const;
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_t_n__raw__n__ind_get;
static PyObject *__pyx_kp_s_const_type_in0_raw_in0__raw_in0;
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_any;
static PyObject *__pyx_n_s_cupy_argmax;
static PyObject *__pyx_n_s_cupy_argmin;
static PyObject *__pyx_n_s_cupy_boolean_array_indexing_nth;
static PyObject *__pyx_n_s_cupy_clip;
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_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_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_n_s_cupy_negative;
static PyObject *__pyx_n_s_cupy_power;
static PyObject *__pyx_n_s_cupy_prod;
static PyObject *__pyx_n_s_cupy_remainder;
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_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_2;
static PyObject *__pyx_kp_s_d_l;
static PyObject *__pyx_n_s_data_as;
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_device;
static PyObject *__pyx_kp_s_dfeqlihbQLIHB;
static PyObject *__pyx_n_s_dgemmBatched;
static PyObject *__pyx_n_s_diagonal;
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_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_l;
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_elementwise_copy;
static PyObject *__pyx_n_s_elementwise_copy_2;
static PyObject *__pyx_n_s_elementwise_copy_where;
static PyObject *__pyx_n_s_elementwise_copy_where_2;
static PyObject *__pyx_n_s_empty;
static PyObject *__pyx_n_s_enter;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_n_s_equal;
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_2;
static PyObject *__pyx_kp_s_f_l;
static PyObject *__pyx_n_s_false;
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_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_genexpr;
static PyObject *__pyx_n_s_get;
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_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_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_kp_s_home_beam2d_src_github_com_pfne;
static PyObject *__pyx_kp_s_home_beam2d_src_github_com_pfne_2;
static PyObject *__pyx_kp_s_home_beam2d_src_github_com_pfne_3;
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_n_s_identity;
static PyObject *__pyx_kp_s_if_boolean_array_out_nth_a;
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_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_import;
static PyObject *__pyx_n_s_in0;
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_shape;
static PyObject *__pyx_n_s_in_str;
static PyObject *__pyx_n_s_in_types;
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_n_s_indexer;
static PyObject *__pyx_n_s_indices;
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_insert;
static PyObject *__pyx_n_s_int;
static PyObject *__pyx_n_s_int16;
static PyObject *__pyx_n_s_int32;
static PyObject *__pyx_kp_s_int32__block_stride;
static PyObject *__pyx_n_s_int64;
static PyObject *__pyx_n_s_int8;
static PyObject *__pyx_n_s_integer;
static PyObject *__pyx_n_s_integer_types;
static PyObject *__pyx_n_s_invert;
static PyObject *__pyx_n_s_is_const;
static PyObject *__pyx_n_s_isscalar;
static PyObject *__pyx_n_s_items;
static PyObject *__pyx_n_s_itemsize;
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_kern_add;
static PyObject *__pyx_n_s_kern_scan;
static PyObject *__pyx_n_s_kernel;
static PyObject *__pyx_n_s_kernel_params;
static PyObject *__pyx_n_s_kind;
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_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_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_max;
static PyObject *__pyx_n_s_maximum;
static PyObject *__pyx_n_s_mean;
static PyObject *__pyx_n_s_memoize;
static PyObject *__pyx_n_s_memptr;
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_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_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_1016;
static PyObject *__pyx_n_s_ndim;
static PyObject *__pyx_n_s_ndmin;
static PyObject *__pyx_n_s_negative;
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_n_s_nonzero_1d_kernel;
static PyObject *__pyx_n_s_nonzero_1d_kernel_2;
static PyObject *__pyx_n_s_nonzero_kernel;
static PyObject *__pyx_n_s_nonzero_kernel_2;
static PyObject *__pyx_n_s_not_equal;
static PyObject *__pyx_n_s_nout;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_n_s_obj;
static PyObject *__pyx_n_s_object;
static PyObject *__pyx_n_s_oct;
static PyObject *__pyx_n_s_offset;
static PyObject *__pyx_kp_s_only_integers_slices_ellipsis_nu;
static PyObject *__pyx_n_s_op;
static PyObject *__pyx_n_s_open;
static PyObject *__pyx_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_os;
static PyObject *__pyx_n_s_out;
static PyObject *__pyx_kp_s_out0__floor_divide_in0_in1;
static PyObject *__pyx_kp_s_out0_a;
static PyObject *__pyx_kp_s_out0_a__in_ind_size__out_ind_siz;
static PyObject *__pyx_kp_s_out0_a_index;
static PyObject *__pyx_kp_s_out0_a_value;
static PyObject *__pyx_kp_s_out0_fabs_in0;
static PyObject *__pyx_kp_s_out0_fabsf_in0;
static PyObject *__pyx_kp_s_out0_in0;
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_in1;
static PyObject *__pyx_kp_s_out0_in0_in1_in1_in0_in2_in2_in0;
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_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_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_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_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_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_prod;
static PyObject *__pyx_n_s_property;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_kp_s_q;
static PyObject *__pyx_kp_s_q_d;
static PyObject *__pyx_kp_s_q_l;
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_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_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_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_reduce_dims;
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_remove;
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_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_right_shift;
static PyObject *__pyx_n_s_rlshift;
static PyObject *__pyx_n_s_rmatmul;
static PyObject *__pyx_n_s_rmod;
static PyObject *__pyx_n_s_rmul;
static PyObject *__pyx_n_s_ror;
static PyObject *__pyx_n_s_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_s;
static PyObject *__pyx_n_s_same_kind;
static PyObject *__pyx_n_s_scan;
static PyObject *__pyx_n_s_self;
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_sgemmBatched;
static PyObject *__pyx_n_s_shape;
static PyObject *__pyx_n_s_shape_2;
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_six_zip;
static PyObject *__pyx_n_s_size;
static PyObject *__pyx_n_s_slices;
static PyObject *__pyx_n_s_source;
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_n_s_std;
static PyObject *__pyx_n_s_std_2;
static PyObject *__pyx_n_s_step;
static PyObject *__pyx_n_s_stop;
static PyObject *__pyx_n_s_stream;
static PyObject *__pyx_n_s_strides;
static PyObject *__pyx_n_s_string;
static PyObject *__pyx_n_s_strip;
static PyObject *__pyx_n_s_substitute;
static PyObject *__pyx_n_s_subtract;
static PyObject *__pyx_n_s_sum;
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_test;
static PyObject *__pyx_n_s_throw;
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_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_unknown_ctype;
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_c_contiguity;
static PyObject *__pyx_n_s_update_c_contiguity_2;
static PyObject *__pyx_n_s_update_contiguity;
static PyObject *__pyx_n_s_update_f_contiguity;
static PyObject *__pyx_n_s_util;
static PyObject *__pyx_n_s_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_x;
static PyObject *__pyx_kp_u_x___getitem___y_x_y_note_CuPy_ha;
static PyObject *__pyx_kp_s_x_mean_x_mean;
static PyObject *__pyx_kp_s_zero_size_array_to_reduction_ope;
static PyObject *__pyx_n_s_zip;
static int __pyx_pf_4cupy_4core_4core_7ndarray___init__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_shape, PyObject *__pyx_v_dtype, PyObject *__pyx_v_memptr); /* 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_copy); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_12copy(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* 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_38nonzero(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_40diagonal(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_42max(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_44argmax(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_46min(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_48argmin(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_50clip(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_52trace(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_54sum(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_56mean(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_58var(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_60std(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_62prod(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_64all(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_66any(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_68__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op); /* proto */
static int __pyx_pf_4cupy_4core_4core_7ndarray_70__nonzero__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_72__neg__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_74__pos__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_76__abs__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_78__invert__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_80__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_82__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_84__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
#if PY_VERSION_HEX >= 0x03050000
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_86__matmul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
#endif
#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_88__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
#endif
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_90__truediv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_92__floordiv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_94__mod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_96__divmod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_98__pow__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, CYTHON_UNUSED PyObject *__pyx_v_modulo); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_100__lshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_102__rshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_104__and__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_106__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_108__xor__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_110__iadd__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_112__isub__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_114__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
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_116__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_118__itruediv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_120__ifloordiv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_122__imod__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_124__ipow__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_126__ilshift__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_128__irshift__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_130__iand__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_132__ior__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_134__ixor__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_136__copy__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_138__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_140__reduce__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_142__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_144__len__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_146__getitem__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_slices); /* proto */
static int __pyx_pf_4cupy_4core_4core_7ndarray_148__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_150__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_152__long__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
#endif
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_154__float__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_156__oct__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
#endif
#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_158__hex__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
#endif
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_160__repr__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_162__str__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_164dot(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_166get(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_stream); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_168set(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_170reduced_view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_172_update_c_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_174_update_f_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_176_update_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_178_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 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_2to_cindexer(CYTHON_UNUSED PyObject *__pyx_self, Py_ssize_t __pyx_v_size, PyObject *__pyx_v_shape); /* 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_7cstruct___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 int __pyx_pf_4cupy_4core_4core_7Indexer_4size_2__set__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7Indexer_5shape___get__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self); /* proto */
static int __pyx_pf_4cupy_4core_4core_7Indexer_5shape_2__set__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4cupy_4core_4core_7Indexer_5shape_4__del__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_4_get_header_source(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_6compile_with_cache(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_source, PyObject *__pyx_v_options, PyObject *__pyx_v_arch, PyObject *__pyx_v_cachd_dir); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_8_get_simple_elementwise_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_params, PyObject *__pyx_v_operation, PyObject *__pyx_v_name, PyObject *__pyx_v_preamble, PyObject *__pyx_v_loop_prep, PyObject *__pyx_v_after_loop, PyObject *__pyx_v_options); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_10_get_typename(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_12_preprocess_args(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_14_get_args_info(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_16_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_18_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_20_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_22_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_24_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_26_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); /* 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_28create_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); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_30_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_32_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_34_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_36_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_38_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_40_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, PyObject *__pyx_v_a, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__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_42_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_44create_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_46elementwise_copy(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_48elementwise_copy_where(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* 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, 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_54rollaxis(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 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_56broadcast_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_58_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_60concatenate(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_62_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_64_boolean_array_indexing(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_boolean_array); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_66_take(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_indices, PyObject *__pyx_v_axis, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_68_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_70_adv_getitem(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_72dot(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_74_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_76matmul(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); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_78tensordot_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_80_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_82_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_84create_comparison(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_op, PyObject *__pyx_v_doc); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_86_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_88_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_90_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_92_add_scan_blocked_sum_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_94_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_96_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_98scan(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_out); /* 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_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_Indexer(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 __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items = {0, &__pyx_n_s_items, 0, 0, 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_100;
static PyObject *__pyx_int_256;
static PyObject *__pyx_int_512;
static PyObject *__pyx_int_7500;
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__5;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__7;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_slice__12;
static PyObject *__pyx_slice__16;
static PyObject *__pyx_slice__17;
static PyObject *__pyx_slice__18;
static PyObject *__pyx_slice__19;
static PyObject *__pyx_slice__22;
static PyObject *__pyx_slice__73;
static PyObject *__pyx_slice__80;
static PyObject *__pyx_slice__81;
static PyObject *__pyx_slice__88;
static PyObject *__pyx_slice__94;
static PyObject *__pyx_slice__95;
static PyObject *__pyx_slice__96;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
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__35;
static PyObject *__pyx_tuple__36;
static PyObject *__pyx_tuple__37;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_tuple__39;
static PyObject *__pyx_tuple__40;
static PyObject *__pyx_tuple__41;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__43;
static PyObject *__pyx_tuple__45;
static PyObject *__pyx_tuple__46;
static PyObject *__pyx_tuple__47;
static PyObject *__pyx_tuple__48;
static PyObject *__pyx_tuple__49;
static PyObject *__pyx_tuple__50;
static PyObject *__pyx_tuple__51;
static PyObject *__pyx_tuple__52;
static PyObject *__pyx_tuple__54;
static PyObject *__pyx_tuple__55;
static PyObject *__pyx_tuple__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__63;
static PyObject *__pyx_tuple__64;
static PyObject *__pyx_tuple__65;
static PyObject *__pyx_tuple__66;
static PyObject *__pyx_tuple__67;
static PyObject *__pyx_tuple__68;
static PyObject *__pyx_tuple__69;
static PyObject *__pyx_tuple__70;
static PyObject *__pyx_tuple__71;
static PyObject *__pyx_tuple__72;
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__82;
static PyObject *__pyx_tuple__84;
static PyObject *__pyx_tuple__85;
static PyObject *__pyx_tuple__86;
static PyObject *__pyx_tuple__87;
static PyObject *__pyx_tuple__89;
static PyObject *__pyx_tuple__90;
static PyObject *__pyx_tuple__91;
static PyObject *__pyx_tuple__92;
static PyObject *__pyx_tuple__93;
static PyObject *__pyx_tuple__97;
static PyObject *__pyx_tuple__98;
static PyObject *__pyx_tuple__99;
static PyObject *__pyx_slice__102;
static PyObject *__pyx_slice__104;
static PyObject *__pyx_slice__108;
static PyObject *__pyx_slice__109;
static PyObject *__pyx_slice__110;
static PyObject *__pyx_slice__115;
static PyObject *__pyx_slice__116;
static PyObject *__pyx_tuple__100;
static PyObject *__pyx_tuple__101;
static PyObject *__pyx_tuple__103;
static PyObject *__pyx_tuple__105;
static PyObject *__pyx_tuple__106;
static PyObject *__pyx_tuple__107;
static PyObject *__pyx_tuple__111;
static PyObject *__pyx_tuple__112;
static PyObject *__pyx_tuple__113;
static PyObject *__pyx_tuple__114;
static PyObject *__pyx_tuple__117;
static PyObject *__pyx_tuple__118;
static PyObject *__pyx_tuple__119;
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__125;
static PyObject *__pyx_tuple__126;
static PyObject *__pyx_tuple__127;
static PyObject *__pyx_tuple__128;
static PyObject *__pyx_tuple__129;
static PyObject *__pyx_tuple__130;
static PyObject *__pyx_tuple__131;
static PyObject *__pyx_tuple__132;
static PyObject *__pyx_tuple__133;
static PyObject *__pyx_tuple__134;
static PyObject *__pyx_tuple__135;
static PyObject *__pyx_tuple__136;
static PyObject *__pyx_tuple__137;
static PyObject *__pyx_tuple__138;
static PyObject *__pyx_tuple__139;
static PyObject *__pyx_tuple__140;
static PyObject *__pyx_tuple__141;
static PyObject *__pyx_tuple__143;
static PyObject *__pyx_tuple__145;
static PyObject *__pyx_tuple__147;
static PyObject *__pyx_tuple__149;
static PyObject *__pyx_tuple__151;
static PyObject *__pyx_tuple__152;
static PyObject *__pyx_tuple__155;
static PyObject *__pyx_tuple__157;
static PyObject *__pyx_tuple__159;
static PyObject *__pyx_tuple__161;
static PyObject *__pyx_tuple__163;
static PyObject *__pyx_tuple__165;
static PyObject *__pyx_tuple__166;
static PyObject *__pyx_tuple__168;
static PyObject *__pyx_tuple__170;
static PyObject *__pyx_tuple__171;
static PyObject *__pyx_tuple__174;
static PyObject *__pyx_tuple__175;
static PyObject *__pyx_tuple__177;
static PyObject *__pyx_tuple__178;
static PyObject *__pyx_tuple__180;
static PyObject *__pyx_tuple__181;
static PyObject *__pyx_tuple__182;
static PyObject *__pyx_tuple__183;
static PyObject *__pyx_tuple__184;
static PyObject *__pyx_tuple__185;
static PyObject *__pyx_tuple__186;
static PyObject *__pyx_tuple__187;
static PyObject *__pyx_tuple__188;
static PyObject *__pyx_tuple__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__215;
static PyObject *__pyx_tuple__219;
static PyObject *__pyx_tuple__220;
static PyObject *__pyx_tuple__221;
static PyObject *__pyx_tuple__224;
static PyObject *__pyx_tuple__225;
static PyObject *__pyx_tuple__226;
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__239;
static PyObject *__pyx_tuple__240;
static PyObject *__pyx_tuple__241;
static PyObject *__pyx_tuple__242;
static PyObject *__pyx_tuple__243;
static PyObject *__pyx_tuple__245;
static PyObject *__pyx_tuple__246;
static PyObject *__pyx_tuple__247;
static PyObject *__pyx_tuple__249;
static PyObject *__pyx_tuple__250;
static PyObject *__pyx_tuple__251;
static PyObject *__pyx_tuple__252;
static PyObject *__pyx_tuple__253;
static PyObject *__pyx_tuple__254;
static PyObject *__pyx_tuple__255;
static PyObject *__pyx_tuple__256;
static PyObject *__pyx_tuple__257;
static PyObject *__pyx_tuple__258;
static PyObject *__pyx_tuple__260;
static PyObject *__pyx_tuple__261;
static PyObject *__pyx_tuple__262;
static PyObject *__pyx_tuple__263;
static PyObject *__pyx_tuple__264;
static PyObject *__pyx_tuple__265;
static PyObject *__pyx_tuple__266;
static PyObject *__pyx_tuple__267;
static PyObject *__pyx_tuple__268;
static PyObject *__pyx_tuple__269;
static PyObject *__pyx_tuple__270;
static PyObject *__pyx_tuple__271;
static PyObject *__pyx_tuple__272;
static PyObject *__pyx_tuple__273;
static PyObject *__pyx_tuple__274;
static PyObject *__pyx_tuple__275;
static PyObject *__pyx_tuple__276;
static PyObject *__pyx_tuple__277;
static PyObject *__pyx_tuple__278;
static PyObject *__pyx_tuple__279;
static PyObject *__pyx_tuple__280;
static PyObject *__pyx_tuple__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__291;
static PyObject *__pyx_tuple__293;
static PyObject *__pyx_tuple__295;
static PyObject *__pyx_tuple__297;
static PyObject *__pyx_codeobj__142;
static PyObject *__pyx_codeobj__144;
static PyObject *__pyx_codeobj__146;
static PyObject *__pyx_codeobj__148;
static PyObject *__pyx_codeobj__150;
static PyObject *__pyx_codeobj__153;
static PyObject *__pyx_codeobj__156;
static PyObject *__pyx_codeobj__158;
static PyObject *__pyx_codeobj__160;
static PyObject *__pyx_codeobj__162;
static PyObject *__pyx_codeobj__164;
static PyObject *__pyx_codeobj__167;
static PyObject *__pyx_codeobj__169;
static PyObject *__pyx_codeobj__172;
static PyObject *__pyx_codeobj__176;
static PyObject *__pyx_codeobj__179;
static PyObject *__pyx_codeobj__290;
static PyObject *__pyx_codeobj__292;
static PyObject *__pyx_codeobj__294;
static PyObject *__pyx_codeobj__296;
static PyObject *__pyx_codeobj__298;

/* "cupy/core/core.pyx":28
 * 
 * @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":29
 * @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(1, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_xp = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":30
 * 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(1, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_yp = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":31
 *     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(1, 31, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 31, __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(1, 31, __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":28
 * 
 * @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":76
 *         readonly ndarray base
 * 
 *     def __init__(self, shape, dtype=float, memptr=None):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t size
 *         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;
  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,0};
    PyObject* values[3] = {0,0,0};
    values[1] = __pyx_k_;
    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);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_memptr);
          if (value) { values[2] = 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, 76, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        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];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 76, __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);

  /* 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) {
  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":78
 *     def __init__(self, shape, dtype=float, memptr=None):
 *         cdef Py_ssize_t size
 *         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(1, 78, __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(1, 78, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->_shape = __pyx_t_2;

  /* "cupy/core/core.pyx":79
 *         cdef Py_ssize_t size
 *         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":80
 *         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":81
 *         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(1, 81, __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, 81, __pyx_L1_error)

      /* "cupy/core/core.pyx":80
 *         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":79
 *         cdef Py_ssize_t size
 *         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":82
 *             if x < 0:
 *                 raise ValueError('Negative dimensions are not allowed')
 *         self.dtype = numpy.dtype(dtype)             # <<<<<<<<<<<<<<
 *         self.size = internal.prod_ssize_t(self._shape)
 *         self._strides = internal.get_contiguous_strides(
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 82, __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, 82, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 82, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 82, __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(1, 82, __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":83
 *                 raise ValueError('Negative dimensions are not allowed')
 *         self.dtype = numpy.dtype(dtype)
 *         self.size = internal.prod_ssize_t(self._shape)             # <<<<<<<<<<<<<<
 *         self._strides = internal.get_contiguous_strides(
 *             self._shape, self.itemsize)
 */
  __pyx_v_self->size = __pyx_f_4cupy_4core_8internal_prod_ssize_t(__pyx_v_self->_shape, 0, NULL);

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

  /* "cupy/core/core.pyx":84
 *         self.dtype = numpy.dtype(dtype)
 *         self.size = internal.prod_ssize_t(self._shape)
 *         self._strides = internal.get_contiguous_strides(             # <<<<<<<<<<<<<<
 *             self._shape, self.itemsize)
 * 
 */
  __pyx_t_2 = __pyx_f_4cupy_4core_8internal_get_contiguous_strides(__pyx_v_self->_shape, __pyx_t_5, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 84, __pyx_L1_error)
  __pyx_v_self->_strides = __pyx_t_2;

  /* "cupy/core/core.pyx":87
 *             self._shape, self.itemsize)
 * 
 *         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":88
 * 
 *         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(1, 88, __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(1, 88, __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(1, 88, __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(1, 88, __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(1, 88, __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":87
 *             self._shape, self.itemsize)
 * 
 *         if memptr is None:             # <<<<<<<<<<<<<<
 *             self.data = memory.alloc(self.size * self.dtype.itemsize)
 *         else:
 */
    goto __pyx_L6;
  }

  /* "cupy/core/core.pyx":90
 *             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(1, 90, __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":91
 *         else:
 *             self.data = memptr
 *         self.base = None             # <<<<<<<<<<<<<<
 * 
 *         self._c_contiguous = True
 */
  __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":93
 *         self.base = None
 * 
 *         self._c_contiguous = True             # <<<<<<<<<<<<<<
 *         self._update_f_contiguity()
 * 
 */
  __pyx_v_self->_c_contiguous = 1;

  /* "cupy/core/core.pyx":94
 * 
 *         self._c_contiguous = True
 *         self._update_f_contiguity()             # <<<<<<<<<<<<<<
 * 
 *     # The definition order of attributes and methods are borrowed from the
 */
  __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(1, 94, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":76
 *         readonly ndarray base
 * 
 *     def __init__(self, shape, dtype=float, memptr=None):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t size
 *         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":104
 *     # -------------------------------------------------------------------------
 *     @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;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

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

  /* "cupy/core/core.pyx":115
 *         """
 *         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(1, 115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 114, __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(1, 114, __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":104
 *     # -------------------------------------------------------------------------
 *     @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":127
 *         """
 * 
 *         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":128
 * 
 *         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(1, 128, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 128, __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":127
 *         """
 * 
 *         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":130
 *             return tuple(self._shape)
 * 
 *         def __set__(self, newshape):             # <<<<<<<<<<<<<<
 *             cdef vector.vector[Py_ssize_t] shape, strides
 *             shape = internal.infer_unknown_dimension(newshape, self.size)
 */

/* 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
  std::vector<Py_ssize_t>  __pyx_t_1;
  std::vector<Py_ssize_t>  __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "cupy/core/core.pyx":132
 *         def __set__(self, newshape):
 *             cdef vector.vector[Py_ssize_t] shape, strides
 *             shape = internal.infer_unknown_dimension(newshape, self.size)             # <<<<<<<<<<<<<<
 *             strides = _get_strides_for_nocopy_reshape(self, newshape)
 *             if strides.size() != shape.size():
 */
  __pyx_t_1 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_newshape); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 132, __pyx_L1_error)
  __pyx_t_2 = __pyx_f_4cupy_4core_8internal_infer_unknown_dimension(__pyx_t_1, __pyx_v_self->size, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 132, __pyx_L1_error)
  __pyx_v_shape = __pyx_t_2;

  /* "cupy/core/core.pyx":133
 *             cdef vector.vector[Py_ssize_t] shape, strides
 *             shape = internal.infer_unknown_dimension(newshape, self.size)
 *             strides = _get_strides_for_nocopy_reshape(self, newshape)             # <<<<<<<<<<<<<<
 *             if strides.size() != shape.size():
 *                 raise AttributeError('incompatible shape')
 */
  __pyx_t_2 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_newshape); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 133, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_strides_for_nocopy_reshape(__pyx_v_self, __pyx_t_2, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 133, __pyx_L1_error)
  __pyx_v_strides = __pyx_t_1;

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

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

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

  /* "cupy/core/core.pyx":136
 *             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":137
 *                 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":138
 *             self._shape = shape
 *             self._strides = strides
 *             self._update_f_contiguity()             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_update_f_contiguity(__pyx_v_self, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":130
 *             return tuple(self._shape)
 * 
 *         def __set__(self, newshape):             # <<<<<<<<<<<<<<
 *             cdef vector.vector[Py_ssize_t] shape, strides
 *             shape = internal.infer_unknown_dimension(newshape, self.size)
 */

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

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

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

  /* "cupy/core/core.pyx":161
 * 
 *     @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":170
 * 
 *     @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":178
 * 
 *         """
 *         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(1, 178, __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(1, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 178, __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":170
 * 
 *     @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":184
 *     # -------------------------------------------------------------------------
 *     @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":190
 * 
 *         """
 *         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(1, 190, __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(1, 190, __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(1, 190, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":191
 *         """
 *         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":190
 * 
 *         """
 *         if self.ndim < 2:             # <<<<<<<<<<<<<<
 *             return self
 *         else:
 */
  }

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

  /* "cupy/core/core.pyx":184
 *     # -------------------------------------------------------------------------
 *     @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":206
 *     # -------------------------------------------------------------------------
 *     @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":214
 * 
 *         """
 *         return CArray(self)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 214, __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(1, 214, __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":206
 *     # -------------------------------------------------------------------------
 *     @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":221
 *     # 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(1, 221, __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_COMPILING_IN_CPYTHON && 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(1, 221, __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, 221, __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":230
 * 
 *         """
 *         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(1, 230, __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(1, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 230, __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(1, 230, __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":221
 *     # 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[] = "Converts 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(1, 221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":236
 *     # 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__4);
  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;
  Py_ssize_t __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(1, 236, __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 236, __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(1, 236, __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":242
 * 
 *         """
 *         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(1, 242, __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(1, 242, __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_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 242, __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(1, 242, __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":236
 *     # 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[] = "Writes 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__4);
    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);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sep);
          if (value) { values[1] = value; kw_args--; }
        }
        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(1, 236, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        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(1, 236, __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(1, 236, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":244
 *         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;
  Py_ssize_t __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(1, 244, __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_COMPILING_IN_CPYTHON && 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(1, 244, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 244, __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(1, 244, __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":251
 * 
 *         """
 *         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(1, 251, __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(1, 251, __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(1, 251, __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(1, 251, __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_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 251, __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(1, 251, __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":244
 *         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[] = "Dumps 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(1, 244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":253
 *         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;
  Py_ssize_t __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(1, 253, __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_COMPILING_IN_CPYTHON && 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(1, 253, __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, 253, __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":255
 *     cpdef dumps(self):
 *         """Dumps a pickle of the array to a string."""
 *         return six.moves.cPickle.dumps(self, -1)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray astype(self, dtype, copy=True):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 255, __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(1, 255, __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(1, 255, __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(1, 255, __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_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 255, __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(1, 255, __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":253
 *         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[] = "Dumps 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(1, 253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":257
 *         return six.moves.cPickle.dumps(self, -1)
 * 
 *     cpdef ndarray astype(self, dtype, 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_copy = ((PyObject *)Py_True);
  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;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("astype", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_copy = __pyx_optional_args->copy;
    }
  }
  __Pyx_INCREF(__pyx_v_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_astype); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 257, __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 257, __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_copy);
      __Pyx_GIVEREF(__pyx_v_copy);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__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(1, 257, __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(1, 257, __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":278
 *         """
 *         # TODO(beam2d): Support ordering, casting, and subok option
 *         dtype = numpy.dtype(dtype)             # <<<<<<<<<<<<<<
 *         if dtype == self.dtype:
 *             if copy:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 278, __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(1, 278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 278, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __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(1, 278, __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":279
 *         # TODO(beam2d): Support ordering, casting, and subok option
 *         dtype = numpy.dtype(dtype)
 *         if dtype == self.dtype:             # <<<<<<<<<<<<<<
 *             if copy:
 *                 return self.copy()
 */
  __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(1, 279, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(1, 279, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":280
 *         dtype = numpy.dtype(dtype)
 *         if dtype == self.dtype:
 *             if copy:             # <<<<<<<<<<<<<<
 *                 return self.copy()
 *             else:
 */
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_copy); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(1, 280, __pyx_L1_error)
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":281
 *         if dtype == self.dtype:
 *             if copy:
 *                 return self.copy()             # <<<<<<<<<<<<<<
 *             else:
 *                 return self
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->copy(__pyx_v_self, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 281, __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":280
 *         dtype = numpy.dtype(dtype)
 *         if dtype == self.dtype:
 *             if copy:             # <<<<<<<<<<<<<<
 *                 return self.copy()
 *             else:
 */
    }

    /* "cupy/core/core.pyx":283
 *                 return self.copy()
 *             else:
 *                 return self             # <<<<<<<<<<<<<<
 *         else:
 *             newarray = ndarray(self.shape, dtype=dtype)
 */
    /*else*/ {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __pyx_r = __pyx_v_self;
      goto __pyx_L0;
    }

    /* "cupy/core/core.pyx":279
 *         # TODO(beam2d): Support ordering, casting, and subok option
 *         dtype = numpy.dtype(dtype)
 *         if dtype == self.dtype:             # <<<<<<<<<<<<<<
 *             if copy:
 *                 return self.copy()
 */
  }

  /* "cupy/core/core.pyx":285
 *                 return self
 *         else:
 *             newarray = ndarray(self.shape, dtype=dtype)             # <<<<<<<<<<<<<<
 *             elementwise_copy(self, newarray)
 *             return newarray
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 285, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 285, __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(1, 285, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 285, __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(1, 285, __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":286
 *         else:
 *             newarray = ndarray(self.shape, dtype=dtype)
 *             elementwise_copy(self, newarray)             # <<<<<<<<<<<<<<
 *             return newarray
 * 
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 286, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_5 = 1;
      }
    }
    __pyx_t_2 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 286, __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_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_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 286, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

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

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.astype", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_newarray);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_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[] = "Casts the array to given data type.\n\n        Args:\n            dtype: Type specifier.\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 ``order``, ``casting``, and\n           ``subok`` 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_copy = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("astype (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dtype,&__pyx_n_s_copy,0};
    PyObject* values[2] = {0,0};
    values[1] = ((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  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_copy);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "astype") < 0)) __PYX_ERR(1, 257, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_dtype = values[0];
    __pyx_v_copy = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("astype", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 257, __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_copy);

  /* 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_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 = 1;
  __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(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.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":291
 *     # TODO(okuta): Implement byteswap
 * 
 *     cpdef ndarray copy(self):             # <<<<<<<<<<<<<<
 *         """Returns a copy of the array.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_13copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*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_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  __Pyx_RefNannySetupContext("copy", 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_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 291, __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_COMPILING_IN_CPYTHON && 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(1, 291, __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, 291, __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(1, 291, __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":301
 *         cdef ndarray a, newarray
 *         # TODO(beam2d): Support ordering option
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return ndarray(self.shape, self.dtype)
 * 
 */
  __pyx_t_5 = ((__pyx_v_self->size == 0) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":302
 *         # TODO(beam2d): Support ordering option
 *         if self.size == 0:
 *             return ndarray(self.shape, self.dtype)             # <<<<<<<<<<<<<<
 * 
 *         a = self
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 302, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 302, __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->dtype);
    __Pyx_GIVEREF(__pyx_v_self->dtype);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->dtype);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 302, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":301
 *         cdef ndarray a, newarray
 *         # TODO(beam2d): Support ordering option
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return ndarray(self.shape, self.dtype)
 * 
 */
  }

  /* "cupy/core/core.pyx":304
 *             return ndarray(self.shape, self.dtype)
 * 
 *         a = self             # <<<<<<<<<<<<<<
 *         if not self._c_contiguous:
 *             with self.device:
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_v_a = __pyx_v_self;

  /* "cupy/core/core.pyx":305
 * 
 *         a = self
 *         if not self._c_contiguous:             # <<<<<<<<<<<<<<
 *             with self.device:
 *                 a = ascontiguousarray(self)
 */
  __pyx_t_5 = ((!(__pyx_v_self->_c_contiguous != 0)) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":306
 *         a = self
 *         if not self._c_contiguous:
 *             with self.device:             # <<<<<<<<<<<<<<
 *                 a = ascontiguousarray(self)
 *             if a.data.device.id == device.get_device_id():
 */
    /*with:*/ {
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 306, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 306, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 306, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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, 306, __pyx_L5_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, 306, __pyx_L5_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_7, &__pyx_t_8, &__pyx_t_9);
          __Pyx_XGOTREF(__pyx_t_7);
          __Pyx_XGOTREF(__pyx_t_8);
          __Pyx_XGOTREF(__pyx_t_9);
          /*try:*/ {

            /* "cupy/core/core.pyx":307
 *         if not self._c_contiguous:
 *             with self.device:
 *                 a = ascontiguousarray(self)             # <<<<<<<<<<<<<<
 *             if a.data.device.id == device.get_device_id():
 *                 return a
 */
            __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_ascontiguousarray(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 307, __pyx_L9_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":306
 *         a = self
 *         if not self._c_contiguous:
 *             with self.device:             # <<<<<<<<<<<<<<
 *                 a = ascontiguousarray(self)
 *             if a.data.device.id == device.get_device_id():
 */
          }
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          goto __pyx_L16_try_end;
          __pyx_L9_error:;
          __Pyx_PyThreadState_assign
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          /*except:*/ {
            __Pyx_AddTraceback("cupy.core.core.ndarray.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(1, 306, __pyx_L11_except_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_4 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 306, __pyx_L11_except_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 306, __pyx_L11_except_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (__pyx_t_5 < 0) __PYX_ERR(1, 306, __pyx_L11_except_error)
            __pyx_t_11 = ((!(__pyx_t_5 != 0)) != 0);
            if (__pyx_t_11) {
              __Pyx_GIVEREF(__pyx_t_1);
              __Pyx_GIVEREF(__pyx_t_2);
              __Pyx_XGIVEREF(__pyx_t_3);
              __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_2, __pyx_t_3);
              __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; 
              __PYX_ERR(1, 306, __pyx_L11_except_error)
            }
            __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;
            goto __pyx_L10_exception_handled;
          }
          __pyx_L11_except_error:;
          __Pyx_PyThreadState_assign
          __Pyx_XGIVEREF(__pyx_t_7);
          __Pyx_XGIVEREF(__pyx_t_8);
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
          goto __pyx_L1_error;
          __pyx_L10_exception_handled:;
          __Pyx_PyThreadState_assign
          __Pyx_XGIVEREF(__pyx_t_7);
          __Pyx_XGIVEREF(__pyx_t_8);
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
          __pyx_L16_try_end:;
        }
      }
      /*finally:*/ {
        /*normal exit:*/{
          if (__pyx_t_6) {
            __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__5, NULL);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 306, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          }
          goto __pyx_L8;
        }
        __pyx_L8:;
      }
      goto __pyx_L20;
      __pyx_L5_error:;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L1_error;
      __pyx_L20:;
    }

    /* "cupy/core/core.pyx":308
 *             with self.device:
 *                 a = ascontiguousarray(self)
 *             if a.data.device.id == device.get_device_id():             # <<<<<<<<<<<<<<
 *                 return a
 *         newarray = ndarray(a.shape, a.dtype)
 */
    __pyx_t_12 = __pyx_f_4cupy_4cuda_6device_get_device_id(0); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 308, __pyx_L1_error)
    __pyx_t_11 = ((__pyx_v_a->data->device->id == __pyx_t_12) != 0);
    if (__pyx_t_11) {

      /* "cupy/core/core.pyx":309
 *                 a = ascontiguousarray(self)
 *             if a.data.device.id == device.get_device_id():
 *                 return a             # <<<<<<<<<<<<<<
 *         newarray = ndarray(a.shape, a.dtype)
 *         newarray.data.copy_from_device(a.data, a.nbytes)
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __pyx_r = __pyx_v_a;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":308
 *             with self.device:
 *                 a = ascontiguousarray(self)
 *             if a.data.device.id == device.get_device_id():             # <<<<<<<<<<<<<<
 *                 return a
 *         newarray = ndarray(a.shape, a.dtype)
 */
    }

    /* "cupy/core/core.pyx":305
 * 
 *         a = self
 *         if not self._c_contiguous:             # <<<<<<<<<<<<<<
 *             with self.device:
 *                 a = ascontiguousarray(self)
 */
  }

  /* "cupy/core/core.pyx":310
 *             if a.data.device.id == device.get_device_id():
 *                 return a
 *         newarray = ndarray(a.shape, a.dtype)             # <<<<<<<<<<<<<<
 *         newarray.data.copy_from_device(a.data, a.nbytes)
 *         return newarray
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_INCREF(__pyx_v_a->dtype);
  __Pyx_GIVEREF(__pyx_v_a->dtype);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_a->dtype);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":311
 *                 return a
 *         newarray = ndarray(a.shape, a.dtype)
 *         newarray.data.copy_from_device(a.data, a.nbytes)             # <<<<<<<<<<<<<<
 *         return newarray
 * 
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_a->data);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 311, __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_3), __pyx_t_13, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":312
 *         newarray = ndarray(a.shape, a.dtype)
 *         newarray.data.copy_from_device(a.data, a.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":291
 *     # TODO(okuta): Implement byteswap
 * 
 *     cpdef ndarray copy(self):             # <<<<<<<<<<<<<<
 *         """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_AddTraceback("cupy.core.core.ndarray.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __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, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_12copy[] = "Returns a copy of the array.\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, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_12copy(((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_12copy(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);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_7ndarray_copy(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":314
 *         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;
  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;
  std::vector<Py_ssize_t>  __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("view", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_dtype = __pyx_optional_args->dtype;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_view); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 314, __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_COMPILING_IN_CPYTHON && 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(1, 314, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 314, __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(1, 314, __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(1, 314, __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":331
 *         # Use __new__ instead of __init__ to skip recomputation of contiguity
 *         cdef ndarray v
 *         v = ndarray.__new__(ndarray)             # <<<<<<<<<<<<<<
 *         v.size = self.size
 *         v._shape = self._shape
 */
  __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(1, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray)))) __PYX_ERR(1, 331, __pyx_L1_error)
  __pyx_v_v = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":332
 *         cdef ndarray v
 *         v = ndarray.__new__(ndarray)
 *         v.size = self.size             # <<<<<<<<<<<<<<
 *         v._shape = self._shape
 *         v._strides = self._strides
 */
  __pyx_t_6 = __pyx_v_self->size;
  __pyx_v_v->size = __pyx_t_6;

  /* "cupy/core/core.pyx":333
 *         v = ndarray.__new__(ndarray)
 *         v.size = self.size
 *         v._shape = self._shape             # <<<<<<<<<<<<<<
 *         v._strides = self._strides
 *         v._c_contiguous = self._c_contiguous
 */
  __pyx_t_7 = __pyx_v_self->_shape;
  __pyx_v_v->_shape = __pyx_t_7;

  /* "cupy/core/core.pyx":334
 *         v.size = self.size
 *         v._shape = self._shape
 *         v._strides = self._strides             # <<<<<<<<<<<<<<
 *         v._c_contiguous = self._c_contiguous
 *         v._f_contiguous = self._f_contiguous
 */
  __pyx_t_7 = __pyx_v_self->_strides;
  __pyx_v_v->_strides = __pyx_t_7;

  /* "cupy/core/core.pyx":335
 *         v._shape = self._shape
 *         v._strides = self._strides
 *         v._c_contiguous = self._c_contiguous             # <<<<<<<<<<<<<<
 *         v._f_contiguous = self._f_contiguous
 *         v.dtype = self.dtype if dtype is None else numpy.dtype(dtype)
 */
  __pyx_t_8 = __pyx_v_self->_c_contiguous;
  __pyx_v_v->_c_contiguous = __pyx_t_8;

  /* "cupy/core/core.pyx":336
 *         v._strides = self._strides
 *         v._c_contiguous = self._c_contiguous
 *         v._f_contiguous = self._f_contiguous             # <<<<<<<<<<<<<<
 *         v.dtype = self.dtype if dtype is None else numpy.dtype(dtype)
 *         v.data = self.data
 */
  __pyx_t_8 = __pyx_v_self->_f_contiguous;
  __pyx_v_v->_f_contiguous = __pyx_t_8;

  /* "cupy/core/core.pyx":337
 *         v._c_contiguous = self._c_contiguous
 *         v._f_contiguous = self._f_contiguous
 *         v.dtype = self.dtype if dtype is None else numpy.dtype(dtype)             # <<<<<<<<<<<<<<
 *         v.data = self.data
 *         v.base = self.base if self.base is not None else self
 */
  __pyx_t_8 = (__pyx_v_dtype == Py_None);
  if ((__pyx_t_8 != 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(1, 337, __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(1, 337, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 337, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 337, __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(1, 337, __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":338
 *         v._f_contiguous = self._f_contiguous
 *         v.dtype = self.dtype if dtype is None else numpy.dtype(dtype)
 *         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":339
 *         v.dtype = self.dtype if dtype is None else numpy.dtype(dtype)
 *         v.data = self.data
 *         v.base = self.base if self.base is not None else self             # <<<<<<<<<<<<<<
 *         return v
 * 
 */
  __pyx_t_8 = (((PyObject *)__pyx_v_self->base) != Py_None);
  if ((__pyx_t_8 != 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":340
 *         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":314
 *         return newarray
 * 
 *     cpdef ndarray view(self, dtype=None):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array.
 * 
 */

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_15view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_14view[] = "Returns 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);
        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(1, 314, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 314, __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(1, 314, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":345
 *     # 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);
  /* 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(1, 345, __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_COMPILING_IN_CPYTHON && 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(1, 345, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 345, __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(1, 345, __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":354
 * 
 *         """
 *         if value == 0 and self._c_contiguous:             # <<<<<<<<<<<<<<
 *             self.data.memset_async(0, self.nbytes, stream.Stream(True))
 *         else:
 */
  __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_v_value, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(1, 354, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_7) {
  } else {
    __pyx_t_6 = __pyx_t_7;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_7 = (__pyx_v_self->_c_contiguous != 0);
  __pyx_t_6 = __pyx_t_7;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":355
 *         """
 *         if value == 0 and self._c_contiguous:
 *             self.data.memset_async(0, self.nbytes, stream.Stream(True))             # <<<<<<<<<<<<<<
 *         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(1, 355, __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(1, 355, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_stream); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Stream); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 355, __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__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_self->data->__pyx_vtab)->memset_async(__pyx_v_self->data, 0, __pyx_t_8, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":354
 * 
 *         """
 *         if value == 0 and self._c_contiguous:             # <<<<<<<<<<<<<<
 *             self.data.memset_async(0, self.nbytes, stream.Stream(True))
 *         else:
 */
    goto __pyx_L3;
  }

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

  /* "cupy/core/core.pyx":345
 *     # 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_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[] = "Fills 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(1, 345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":362
 *     # 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(1, 362, __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(1, 362, __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_COMPILING_IN_CPYTHON && 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(1, 362, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 362, __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(1, 362, __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(1, 362, __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":365
 *         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(1, 365, __pyx_L1_error)
  __pyx_v_shape = __pyx_t_7;

  /* "cupy/core/core.pyx":366
 *         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":367
 *         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(1, 367, __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":366
 *         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":369
 *             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(1, 369, __pyx_L1_error)
  __pyx_v_strides = __pyx_t_7;

  /* "cupy/core/core.pyx":370
 * 
 *         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":371
 *         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(1, 371, __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":370
 * 
 *         strides = _get_strides_for_nocopy_reshape(self, shape)
 *         if strides.size() == shape.size():             # <<<<<<<<<<<<<<
 *             newarray = self.view()
 *         else:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":373
 *             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)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 373, __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":374
 *         else:
 *             newarray = self.copy()
 *             strides = _get_strides_for_nocopy_reshape(newarray, shape)             # <<<<<<<<<<<<<<
 * 
 *         assert 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(1, 374, __pyx_L1_error)
    __pyx_v_strides = __pyx_t_7;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":376
 *             strides = _get_strides_for_nocopy_reshape(newarray, shape)
 * 
 *         assert shape.size() == strides.size()             # <<<<<<<<<<<<<<
 *         newarray._set_shape_and_strides(shape, strides, False)
 *         return newarray
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_shape.size() == __pyx_v_strides.size()) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(1, 376, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/core/core.pyx":377
 * 
 *         assert shape.size() == strides.size()
 *         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(1, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":378
 *         assert shape.size() == strides.size()
 *         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":362
 *     # 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 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(1, 362, __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(1, 362, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":380
 *         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[] = "Returns 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":389
 *         """
 *         # 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(1, 389, __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(1, 389, __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":390
 *         # 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(1, 390, __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":389
 *         """
 *         # 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":391
 *         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(1, 391, __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(1, 391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":380
 *         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":394
 * 
 *     # 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(1, 394, __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(1, 394, __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_COMPILING_IN_CPYTHON && 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(1, 394, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 394, __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(1, 394, __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(1, 394, __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":399
 *         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":400
 * 
 *         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(1, 400, __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":401
 *         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":402
 *         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(1, 402, __pyx_L1_error)
    }

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

    /* "cupy/core/core.pyx":404
 *             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":405
 *             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":406
 *             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":401
 *         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":408
 *             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":409
 * 
 *         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(1, 409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 409, __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(1, 409, __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(1, 409, __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(1, 409, __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(1, 409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(1, 409, __pyx_L1_error)

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

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

    /* "cupy/core/core.pyx":413
 *         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":414
 *             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":415
 *             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__7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 415, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(1, 415, __pyx_L1_error)

      /* "cupy/core/core.pyx":414
 *             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":416
 *             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(1, 416, __pyx_L1_error)
    }
    (__pyx_v_axes[__pyx_v_i]) = __Pyx_mod_Py_ssize_t(__pyx_v_axis, __pyx_v_ndim);
  }

  /* "cupy/core/core.pyx":418
 *             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":419
 * 
 *         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":418
 *             axes[i] = axis % ndim
 * 
 *         if internal.vector_equal(a_axes, axes):             # <<<<<<<<<<<<<<
 *             return ret
 *         rev_axes.assign(axes.rbegin(), axes.rend())
 */
  }

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

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

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

    /* "cupy/core/core.pyx":424
 *             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":425
 *             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":426
 *             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":421
 *             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":428
 *             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(1, 428, __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(1, 428, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(PySet_Add(__pyx_t_2, (PyObject*)__pyx_t_1))) __PYX_ERR(1, 428, __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(1, 428, __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":429
 * 
 *         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(1, 429, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 429, __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(1, 429, __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(1, 429, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 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 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 429, __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, 429, __pyx_L1_error)

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

  /* "cupy/core/core.pyx":431
 *             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":432
 * 
 *         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":433
 *         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":434
 *         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(1, 434, __pyx_L1_error)
    }

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

    /* "cupy/core/core.pyx":433
 *         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":436
 *             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(1, 436, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":437
 *             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":394
 * 
 *     # 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 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(1, 394, __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(1, 394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":439
 *         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[] = "Returns 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":450
 *         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(1, 450, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_1 == 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":451
 *         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(1, 451, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_a = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":452
 *         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":453
 *             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":452
 *         if len(axes) == 1:
 *             a = axes[0]
 *             if a is None:             # <<<<<<<<<<<<<<
 *                 axes = ()
 *             elif cpython.PySequence_Check(a):
 */
      goto __pyx_L4;
    }

    /* "cupy/core/core.pyx":454
 *             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":455
 *                 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":454
 *             if a is None:
 *                 axes = ()
 *             elif cpython.PySequence_Check(a):             # <<<<<<<<<<<<<<
 *                 axes = a
 *         return self._transpose(axes)
 */
    }
    __pyx_L4:;

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

  /* "cupy/core/core.pyx":439
 *         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":458
 *         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;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  __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(1, 458, __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(1, 458, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_axis2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 458, __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 458, __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(1, 458, __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(1, 458, __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":466
 * 
 *         """
 *         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(1, 466, __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(1, 466, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_7;

  /* "cupy/core/core.pyx":468
 *         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_10 = ((__pyx_v_axis1 < (-__pyx_v_ndim)) != 0);
  if (!__pyx_t_10) {
  } else {
    __pyx_t_9 = __pyx_t_10;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_10 = ((__pyx_v_axis1 >= __pyx_v_ndim) != 0);
  if (!__pyx_t_10) {
  } else {
    __pyx_t_9 = __pyx_t_10;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_10 = ((__pyx_v_axis2 < (-__pyx_v_ndim)) != 0);
  if (!__pyx_t_10) {
  } else {
    __pyx_t_9 = __pyx_t_10;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_10 = ((__pyx_v_axis2 >= __pyx_v_ndim) != 0);
  __pyx_t_9 = __pyx_t_10;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_9) {

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

    /* "cupy/core/core.pyx":468
 *         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":470
 *         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(1, 470, __pyx_L1_error)
  }
  __pyx_v_axis1 = __Pyx_mod_Py_ssize_t(__pyx_v_axis1, __pyx_v_ndim);

  /* "cupy/core/core.pyx":471
 *             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(1, 471, __pyx_L1_error)
  }
  __pyx_v_axis2 = __Pyx_mod_Py_ssize_t(__pyx_v_axis2, __pyx_v_ndim);

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

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

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

  /* "cupy/core/core.pyx":475
 *             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(1, 475, __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":458
 *         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[] = "Returns 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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 458, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "swapaxes") < 0)) __PYX_ERR(1, 458, __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(1, 458, __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(1, 458, __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(1, 458, __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(1, 458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":477
 *         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;
  int __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(1, 477, __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_COMPILING_IN_CPYTHON && 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(1, 477, __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, 477, __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(1, 477, __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":489
 *         """
 *         # TODO(beam2d): Support ordering option
 *         if self._c_contiguous:             # <<<<<<<<<<<<<<
 *             newarray = self.copy()
 *         else:
 */
  __pyx_t_5 = (__pyx_v_self->_c_contiguous != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":490
 *         # TODO(beam2d): Support ordering option
 *         if self._c_contiguous:
 *             newarray = self.copy()             # <<<<<<<<<<<<<<
 *         else:
 *             newarray = ndarray(self.shape, self.dtype)
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->copy(__pyx_v_self, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 490, __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":489
 *         """
 *         # TODO(beam2d): Support ordering option
 *         if self._c_contiguous:             # <<<<<<<<<<<<<<
 *             newarray = self.copy()
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":492
 *             newarray = self.copy()
 *         else:
 *             newarray = ndarray(self.shape, self.dtype)             # <<<<<<<<<<<<<<
 *             elementwise_copy(self, newarray)
 * 
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 492, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 492, __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->dtype);
    __Pyx_GIVEREF(__pyx_v_self->dtype);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->dtype);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 492, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":493
 *         else:
 *             newarray = ndarray(self.shape, self.dtype)
 *             elementwise_copy(self, newarray)             # <<<<<<<<<<<<<<
 * 
 *         newarray._shape.assign(<Py_ssize_t>1, self.size)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 493, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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_6 = 1;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 493, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_newarray));
    PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, ((PyObject *)__pyx_v_newarray));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":495
 *             elementwise_copy(self, newarray)
 * 
 *         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->_shape.assign(((Py_ssize_t)1), __pyx_v_self->size);
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(1, 495, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":496
 * 
 *         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(1, 496, __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(1, 496, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  try {
    __pyx_v_newarray->_strides.assign(((Py_ssize_t)1), ((Py_ssize_t)__pyx_t_6));
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(1, 496, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":497
 *         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
 *         return newarray
 */
  __pyx_v_newarray->_c_contiguous = 1;

  /* "cupy/core/core.pyx":498
 *         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->_f_contiguous = 1;

  /* "cupy/core/core.pyx":499
 *         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":477
 *         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[] = "Returns 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(1, 477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":501
 *         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(1, 501, __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_COMPILING_IN_CPYTHON && 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(1, 501, __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, 501, __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(1, 501, __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":511
 *         # 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(1, 511, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":512
 *         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(1, 512, __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":501
 *         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[] = "Returns 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(1, 501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":514
 *         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;
  PyObject *__pyx_v_msg = NULL;
  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;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides __pyx_t_12;
  __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(1, 514, __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_COMPILING_IN_CPYTHON && 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(1, 514, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 514, __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(1, 514, __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(1, 514, __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":527
 *         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":528
 * 
 *         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(1, 528, __pyx_L1_error)
  }
  __pyx_v_axis_flags = __pyx_t_6;

  /* "cupy/core/core.pyx":531
 * 
 *         # 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":532
 *         # 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":533
 *         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":534
 *             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":533
 *         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":531
 * 
 *         # 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":535
 *                 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":536
 *                     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(1, 536, __pyx_L1_error)
    __pyx_v_naxes = ((Py_ssize_t)__pyx_t_9);

    /* "cupy/core/core.pyx":537
 *         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":538
 *             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(1, 538, __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(1, 538, __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":539
 *             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":540
 *                 _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":541
 *                 axis_orig = _axis
 *                 if _axis < 0:
 *                     _axis += ndim             # <<<<<<<<<<<<<<
 *                 if _axis < 0 or _axis >= ndim:
 *                     msg = "'axis' entry %d is out of bounds [-%d, %d)"
 */
        __pyx_v__axis = (__pyx_v__axis + __pyx_v_ndim);

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

      /* "cupy/core/core.pyx":542
 *                 if _axis < 0:
 *                     _axis += ndim
 *                 if _axis < 0 or _axis >= ndim:             # <<<<<<<<<<<<<<
 *                     msg = "'axis' entry %d is out of bounds [-%d, %d)"
 *                     raise ValueError(msg % (axis_orig, ndim, ndim))
 */
      __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":543
 *                     _axis += ndim
 *                 if _axis < 0 or _axis >= ndim:
 *                     msg = "'axis' entry %d is out of bounds [-%d, %d)"             # <<<<<<<<<<<<<<
 *                     raise ValueError(msg % (axis_orig, ndim, ndim))
 *                 if axis_flags[_axis] == 1:
 */
        __Pyx_INCREF(__pyx_kp_s_axis_entry_d_is_out_of_bounds_d);
        __pyx_v_msg = __pyx_kp_s_axis_entry_d_is_out_of_bounds_d;

        /* "cupy/core/core.pyx":544
 *                 if _axis < 0 or _axis >= ndim:
 *                     msg = "'axis' entry %d is out of bounds [-%d, %d)"
 *                     raise ValueError(msg % (axis_orig, ndim, ndim))             # <<<<<<<<<<<<<<
 *                 if axis_flags[_axis] == 1:
 *                     raise ValueError("duplicate value in 'axis'")
 */
        __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_axis_orig); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 544, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 544, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 544, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 544, __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_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
        __pyx_t_1 = 0;
        __pyx_t_2 = 0;
        __pyx_t_3 = 0;
        __pyx_t_3 = PyNumber_Remainder(__pyx_v_msg, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 544, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 544, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 544, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __PYX_ERR(1, 544, __pyx_L1_error)

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

      /* "cupy/core/core.pyx":545
 *                     msg = "'axis' entry %d is out of bounds [-%d, %d)"
 *                     raise ValueError(msg % (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":546
 *                     raise ValueError(msg % (axis_orig, ndim, ndim))
 *                 if axis_flags[_axis] == 1:
 *                     raise ValueError("duplicate value in 'axis'")             # <<<<<<<<<<<<<<
 *                 axis_flags[_axis] = 1
 *         else:
 */
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 546, __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, 546, __pyx_L1_error)

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

      /* "cupy/core/core.pyx":547
 *                 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":535
 *                 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":549
 *                 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(1, 549, __pyx_L1_error)
    __pyx_v__axis = ((Py_ssize_t)__pyx_t_9);

    /* "cupy/core/core.pyx":550
 *         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":551
 *             _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":552
 *             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":551
 *             _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":553
 *             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":558
 *                 pass
 *             else:
 *                 if _axis < 0 or _axis >= ndim:             # <<<<<<<<<<<<<<
 *                     msg = "'axis' entry %d is out of bounds [-%d, %d)"
 *                     raise ValueError(msg % (axis_orig, ndim, ndim))
 */
    /*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":559
 *             else:
 *                 if _axis < 0 or _axis >= ndim:
 *                     msg = "'axis' entry %d is out of bounds [-%d, %d)"             # <<<<<<<<<<<<<<
 *                     raise ValueError(msg % (axis_orig, ndim, ndim))
 *                 axis_flags[_axis] = 1
 */
        __Pyx_INCREF(__pyx_kp_s_axis_entry_d_is_out_of_bounds_d);
        __pyx_v_msg = __pyx_kp_s_axis_entry_d_is_out_of_bounds_d;

        /* "cupy/core/core.pyx":560
 *                 if _axis < 0 or _axis >= ndim:
 *                     msg = "'axis' entry %d is out of bounds [-%d, %d)"
 *                     raise ValueError(msg % (axis_orig, ndim, ndim))             # <<<<<<<<<<<<<<
 *                 axis_flags[_axis] = 1
 * 
 */
        __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_axis_orig); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 560, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 560, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 560, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 560, __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_5);
        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_2);
        __pyx_t_3 = 0;
        __pyx_t_5 = 0;
        __pyx_t_2 = 0;
        __pyx_t_2 = PyNumber_Remainder(__pyx_v_msg, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 560, __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(1, 560, __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(1, 560, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __PYX_ERR(1, 560, __pyx_L1_error)

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

      /* "cupy/core/core.pyx":561
 *                     msg = "'axis' entry %d is out of bounds [-%d, %d)"
 *                     raise ValueError(msg % (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":564
 * 
 *         # 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":565
 *         # 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":566
 *         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":567
 *         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":568
 *             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":567
 *         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":570
 *                     any_ones = 1
 *                 else:
 *                     raise ValueError('cannot select an axis to squeeze out '             # <<<<<<<<<<<<<<
 *                                      'which has size not equal to one')
 * 
 */
      /*else*/ {
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 570, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __PYX_ERR(1, 570, __pyx_L1_error)
      }
      __pyx_L24:;

      /* "cupy/core/core.pyx":566
 *         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":574
 * 
 *         # 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":575
 *         # 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":574
 * 
 *         # If there were no axes to squeeze out, return the same array
 *         if any_ones == 0:             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  }

  /* "cupy/core/core.pyx":577
 *             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":578
 * 
 *         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":579
 *         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(1, 579, __pyx_L1_error)
      }

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

      /* "cupy/core/core.pyx":578
 * 
 *         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":582
 *                 newstrides.push_back(self._strides[i])
 * 
 *         v = self.view()             # <<<<<<<<<<<<<<
 *         v._set_shape_and_strides(newshape, newstrides, False)
 *         return v
 */
  __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->view(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 582, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_v = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":583
 * 
 *         v = self.view()
 *         v._set_shape_and_strides(newshape, newstrides, False)             # <<<<<<<<<<<<<<
 *         return v
 * 
 */
  __pyx_t_12.__pyx_n = 1;
  __pyx_t_12.update_c_contiguity = 0;
  __pyx_t_2 = ((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_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":584
 *         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":514
 *         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_AddTraceback("cupy.core.core.ndarray.squeeze", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_msg);
  __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[] = "Returns 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);
        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(1, 514, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 514, __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(1, 514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":589
 *     # 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;
  Py_ssize_t __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(1, 589, __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 589, __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(1, 589, __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(1, 589, __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":597
 * 
 *         """
 *         return _take(self, indices, axis, 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(1, 597, __pyx_L1_error)
  __pyx_t_7.__pyx_n = 2;
  __pyx_t_7.axis = __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(1, 597, __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":589
 *     # 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[] = "Returns 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);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[1] = value; kw_args--; }
        }
        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(1, 589, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        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(1, 589, __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(1, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":601
 *     # 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;
  Py_ssize_t __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(1, 601, __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 601, __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(1, 601, __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":609
 * 
 *         """
 *         return _repeat(self, repeats, axis)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement choose
 */
  __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(1, 609, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":601
 *     # 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[] = "Returns 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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 601, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        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(1, 601, __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(1, 601, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":618
 *     # 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_39nonzero(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_38nonzero[] = "Return 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_39nonzero(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_38nonzero(((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_38nonzero(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_v_condition = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_scan_index = NULL;
  PyObject *__pyx_v_count_nonzero = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dst = NULL;
  PyObject *__pyx_v_kern = NULL;
  PyObject *__pyx_v_i = 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;
  Py_ssize_t __pyx_t_9;
  PyObject *(*__pyx_t_10)(PyObject *);
  __Pyx_RefNannySetupContext("nonzero", 0);

  /* "cupy/core/core.pyx":631
 * 
 *         """
 *         condition = self != 0             # <<<<<<<<<<<<<<
 *         dtype = numpy.int64
 * 
 */
  __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_self), __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 631, __pyx_L1_error)
  __pyx_v_condition = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":632
 *         """
 *         condition = self != 0
 *         dtype = numpy.int64             # <<<<<<<<<<<<<<
 * 
 *         scan_index = scan(condition.astype(dtype).ravel())
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 632, __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(1, 632, __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":634
 *         dtype = numpy.int64
 * 
 *         scan_index = scan(condition.astype(dtype).ravel())             # <<<<<<<<<<<<<<
 *         count_nonzero = int(scan_index[-1])
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_scan); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 634, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_condition, __pyx_n_s_astype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 634, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_v_dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 634, __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_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_dtype);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ravel); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 634, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 634, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 634, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 634, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_scan_index = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":635
 * 
 *         scan_index = scan(condition.astype(dtype).ravel())
 *         count_nonzero = int(scan_index[-1])             # <<<<<<<<<<<<<<
 * 
 *         if self.ndim <= 1:
 */
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_scan_index, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 635, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 635, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_count_nonzero = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":637
 *         count_nonzero = int(scan_index[-1])
 * 
 *         if self.ndim <= 1:             # <<<<<<<<<<<<<<
 *             dst = ndarray((count_nonzero,), dtype=dtype)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 637, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_1, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 637, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 637, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":638
 * 
 *         if self.ndim <= 1:
 *             dst = ndarray((count_nonzero,), dtype=dtype)             # <<<<<<<<<<<<<<
 * 
 *             kern = _nonzero_1d_kernel(self.dtype, dtype)
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 638, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_count_nonzero);
    __Pyx_GIVEREF(__pyx_v_count_nonzero);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_count_nonzero);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 638, __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(1, 638, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 638, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 638, __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_v_dst = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":640
 *             dst = ndarray((count_nonzero,), dtype=dtype)
 * 
 *             kern = _nonzero_1d_kernel(self.dtype, dtype)             # <<<<<<<<<<<<<<
 *             kern.linear_launch(self.size, (self.ravel(), scan_index, dst))
 * 
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_nonzero_1d_kernel); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 640, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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_9 = 1;
      }
    }
    __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 640, __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_self->dtype);
    __Pyx_GIVEREF(__pyx_v_self->dtype);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_v_self->dtype);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_v_dtype);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 640, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_kern = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":641
 * 
 *             kern = _nonzero_1d_kernel(self.dtype, dtype)
 *             kern.linear_launch(self.size, (self.ravel(), scan_index, dst))             # <<<<<<<<<<<<<<
 * 
 *             return dst,
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_kern, __pyx_n_s_linear_launch); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->ravel(__pyx_v_self, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_scan_index);
    __Pyx_GIVEREF(__pyx_v_scan_index);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_scan_index);
    __Pyx_INCREF(((PyObject *)__pyx_v_dst));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_dst));
    PyTuple_SET_ITEM(__pyx_t_5, 2, ((PyObject *)__pyx_v_dst));
    __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(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_9 = 1;
      }
    }
    __pyx_t_7 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 641, __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_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_9, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_9, __pyx_t_5);
    __pyx_t_3 = 0;
    __pyx_t_5 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":643
 *             kern.linear_launch(self.size, (self.ravel(), scan_index, dst))
 * 
 *             return dst,             # <<<<<<<<<<<<<<
 *         else:
 *             dst = ndarray((count_nonzero * self.ndim,), dtype=dtype)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_dst));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_dst));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_dst));
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":637
 *         count_nonzero = int(scan_index[-1])
 * 
 *         if self.ndim <= 1:             # <<<<<<<<<<<<<<
 *             dst = ndarray((count_nonzero,), dtype=dtype)
 * 
 */
  }

  /* "cupy/core/core.pyx":645
 *             return dst,
 *         else:
 *             dst = ndarray((count_nonzero * self.ndim,), dtype=dtype)             # <<<<<<<<<<<<<<
 * 
 *             kern = _nonzero_kernel(self.dtype, self.ndim, dtype, dtype)
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 645, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyNumber_Multiply(__pyx_v_count_nonzero, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 645, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 645, __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(1, 645, __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(1, 645, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 645, __pyx_L1_error)
    __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 645, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_dst = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":647
 *             dst = ndarray((count_nonzero * self.ndim,), dtype=dtype)
 * 
 *             kern = _nonzero_kernel(self.dtype, self.ndim, dtype, dtype)             # <<<<<<<<<<<<<<
 *             kern.linear_launch(self.size,
 *                                (self.ravel(), Indexer(self.shape),
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_nonzero_kernel); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 647, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 647, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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_9 = 1;
      }
    }
    __pyx_t_3 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 647, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(__pyx_v_self->dtype);
    __Pyx_GIVEREF(__pyx_v_self->dtype);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_v_self->dtype);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_9, __pyx_v_dtype);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_3, 3+__pyx_t_9, __pyx_v_dtype);
    __pyx_t_2 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 647, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_kern = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":648
 * 
 *             kern = _nonzero_kernel(self.dtype, self.ndim, dtype, dtype)
 *             kern.linear_launch(self.size,             # <<<<<<<<<<<<<<
 *                                (self.ravel(), Indexer(self.shape),
 *                                 scan_index, dst))
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_kern, __pyx_n_s_linear_launch); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 648, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 648, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "cupy/core/core.pyx":649
 *             kern = _nonzero_kernel(self.dtype, self.ndim, dtype, dtype)
 *             kern.linear_launch(self.size,
 *                                (self.ravel(), Indexer(self.shape),             # <<<<<<<<<<<<<<
 *                                 scan_index, dst))
 *             return tuple([dst[i::self.ndim]
 */
    __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(1, 649, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 649, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 649, __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 *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 649, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":650
 *             kern.linear_launch(self.size,
 *                                (self.ravel(), Indexer(self.shape),
 *                                 scan_index, dst))             # <<<<<<<<<<<<<<
 *             return tuple([dst[i::self.ndim]
 *                           for i in six.moves.range(self.ndim)])
 */
    __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 649, __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_5);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_scan_index);
    __Pyx_GIVEREF(__pyx_v_scan_index);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_scan_index);
    __Pyx_INCREF(((PyObject *)__pyx_v_dst));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_dst));
    PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_v_dst));
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_2 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 648, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_9, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_9, __pyx_t_1);
    __pyx_t_3 = 0;
    __pyx_t_1 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 648, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":651
 *                                (self.ravel(), Indexer(self.shape),
 *                                 scan_index, dst))
 *             return tuple([dst[i::self.ndim]             # <<<<<<<<<<<<<<
 *                           for i in six.moves.range(self.ndim)])
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 651, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);

    /* "cupy/core/core.pyx":652
 *                                 scan_index, dst))
 *             return tuple([dst[i::self.ndim]
 *                           for i in six.moves.range(self.ndim)])             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement compress
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_moves); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 652, __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_range); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 652, __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_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 652, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 652, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 652, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
      __pyx_t_2 = __pyx_t_4; __Pyx_INCREF(__pyx_t_2); __pyx_t_9 = 0;
      __pyx_t_10 = NULL;
    } else {
      __pyx_t_9 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 652, __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, 652, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    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_COMPILING_IN_CPYTHON
          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(1, 652, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 652, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        } else {
          if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(1, 652, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 652, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        }
      } else {
        __pyx_t_4 = __pyx_t_10(__pyx_t_2);
        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, 652, __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":651
 *                                (self.ravel(), Indexer(self.shape),
 *                                 scan_index, dst))
 *             return tuple([dst[i::self.ndim]             # <<<<<<<<<<<<<<
 *                           for i in six.moves.range(self.ndim)])
 * 
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 651, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PySlice_New(__pyx_v_i, Py_None, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 651, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_dst), __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 651, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_7, (PyObject*)__pyx_t_4))) __PYX_ERR(1, 651, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":652
 *                                 scan_index, dst))
 *             return tuple([dst[i::self.ndim]
 *                           for i in six.moves.range(self.ndim)])             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement compress
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":651
 *                                (self.ravel(), Indexer(self.shape),
 *                                 scan_index, dst))
 *             return tuple([dst[i::self.ndim]             # <<<<<<<<<<<<<<
 *                           for i in six.moves.range(self.ndim)])
 * 
 */
    __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_7)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 651, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":618
 *     # 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_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.nonzero", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_condition);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_scan_index);
  __Pyx_XDECREF(__pyx_v_count_nonzero);
  __Pyx_XDECREF((PyObject *)__pyx_v_dst);
  __Pyx_XDECREF(__pyx_v_kern);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":656
 *     # 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_41diagonal(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;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  struct __pyx_opt_args_4cupy_4core_4core__diagonal __pyx_t_9;
  __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(1, 656, __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_41diagonal)) {
      __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 656, __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(1, 656, __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(1, 656, __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":664
 * 
 *         """
 *         return _diagonal(self, offset, axis1, axis2)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_offset); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 664, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_v_axis1); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 664, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_v_axis2); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 664, __pyx_L1_error)
  __pyx_t_9.__pyx_n = 3;
  __pyx_t_9.offset = __pyx_t_5;
  __pyx_t_9.axis1 = __pyx_t_7;
  __pyx_t_9.axis2 = __pyx_t_8;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__diagonal(__pyx_v_self, 0, &__pyx_t_9)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 664, __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":656
 *     # 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_41diagonal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_40diagonal[] = "Returns 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_41diagonal(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);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis1);
          if (value) { values[1] = value; kw_args--; }
        }
        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(1, 656, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 656, __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_40diagonal(((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_40diagonal(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(1, 656, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":669
 *     # 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_43max(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;
  Py_ssize_t __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(1, 669, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_43max)) {
      __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 669, __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(1, 669, __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(1, 669, __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":677
 * 
 *         """
 *         return _amax(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":678
 *         """
 *         return _amax(
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray argmax(self, axis=None, out=None, dtype=None,
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 677, __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(1, 678, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(1, 678, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(1, 678, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 678, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(1, 678, __pyx_L1_error)

  /* "cupy/core/core.pyx":677
 * 
 *         """
 *         return _amax(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__amax, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 677, __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(1, 677, __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":669
 *     # 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_43max(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_42max[] = "Returns 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_43max(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);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        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(1, 669, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 669, __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_42max(((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_42max(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(1, 669, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.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":680
 *             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_45argmax(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":681
 * 
 *     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;
  Py_ssize_t __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":680
 *             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(1, 680, __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_45argmax)) {
      __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 680, __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(1, 680, __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(1, 680, __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":689
 * 
 *         """
 *         return _argmax(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":690
 *         """
 *         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(1, 689, __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(1, 690, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(1, 690, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(1, 690, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 690, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(1, 690, __pyx_L1_error)

  /* "cupy/core/core.pyx":689
 * 
 *         """
 *         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(1, 689, __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(1, 689, __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":680
 *             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_45argmax(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_44argmax[] = "Returns 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_45argmax(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":681
 * 
 *     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);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        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(1, 680, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 680, __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_44argmax(((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":680
 *             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_44argmax(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(1, 680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":692
 *             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_47min(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;
  Py_ssize_t __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(1, 692, __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_47min)) {
      __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 692, __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(1, 692, __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(1, 692, __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":700
 * 
 *         """
 *         return _amin(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":701
 *         """
 *         return _amin(
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray argmin(self, axis=None, out=None, dtype=None,
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 700, __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(1, 701, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(1, 701, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(1, 701, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 701, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(1, 701, __pyx_L1_error)

  /* "cupy/core/core.pyx":700
 * 
 *         """
 *         return _amin(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__amin, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 700, __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(1, 700, __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":692
 *             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_47min(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_46min[] = "Returns 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_47min(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);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        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(1, 692, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 692, __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_46min(((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_46min(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(1, 692, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":703
 *             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_49argmin(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":704
 * 
 *     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;
  Py_ssize_t __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":703
 *             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(1, 703, __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_49argmin)) {
      __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 703, __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(1, 703, __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(1, 703, __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":712
 * 
 *         """
 *         return _argmin(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":713
 *         """
 *         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(1, 712, __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(1, 713, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(1, 713, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(1, 713, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 713, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(1, 713, __pyx_L1_error)

  /* "cupy/core/core.pyx":712
 * 
 *         """
 *         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(1, 712, __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(1, 712, __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":703
 *             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_49argmin(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_48argmin[] = "Returns 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_49argmin(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":704
 * 
 *     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);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        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(1, 703, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 703, __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_48argmin(((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":703
 *             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_48argmin(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(1, 703, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":717
 *     # TODO(okuta): Implement ptp
 * 
 *     cpdef ndarray clip(self, a_min, a_max, out=None):             # <<<<<<<<<<<<<<
 *         """Returns an array with values limited to [a_min, a_max].
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_51clip(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, PyObject *__pyx_v_a_min, PyObject *__pyx_v_a_max, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_clip *__pyx_optional_args) {
  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;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("clip", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_out = __pyx_optional_args->out;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clip); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 717, __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_51clip)) {
      __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 717, __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(1, 717, __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(1, 717, __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":725
 * 
 *         """
 *         return _clip(self, a_min, a_max, out=out)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement round
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 725, __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_INCREF(__pyx_v_a_min);
  __Pyx_GIVEREF(__pyx_v_a_min);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_a_min);
  __Pyx_INCREF(__pyx_v_a_max);
  __Pyx_GIVEREF(__pyx_v_a_max);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_a_max);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 725, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(1, 725, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__clip, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 725, __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(1, 725, __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":717
 *     # TODO(okuta): Implement ptp
 * 
 *     cpdef ndarray clip(self, a_min, a_max, out=None):             # <<<<<<<<<<<<<<
 *         """Returns an array with values limited to [a_min, a_max].
 * 
 */

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_51clip(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_50clip[] = "Returns 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_51clip(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[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);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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_min)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a_max)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("clip", 0, 2, 3, 1); __PYX_ERR(1, 717, __pyx_L3_error)
        }
        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(1, 717, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        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_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, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 717, __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_50clip(((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_50clip(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 = 1;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->clip(__pyx_v_self, __pyx_v_a_min, __pyx_v_a_max, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 717, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":729
 *     # 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_53trace(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":730
 * 
 *     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;
  Py_ssize_t __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":729
 *     # 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(1, 729, __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_53trace)) {
      __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 729, __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(1, 729, __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(1, 729, __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":738
 * 
 *         """
 *         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(1, 738, __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":739
 *         """
 *         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(1, 739, __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":729
 *     # 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_53trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_52trace[] = "Returns 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_53trace(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":730
 * 
 *     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);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis1);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis2);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[3] = value; kw_args--; }
        }
        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(1, 729, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 729, __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_52trace(((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":729
 *     # 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_52trace(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(1, 729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":741
 *         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_55sum(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;
  Py_ssize_t __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(1, 741, __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_55sum)) {
      __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 741, __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(1, 741, __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(1, 741, __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":749
 * 
 *         """
 *         return _sum(self, axis, dtype, out, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement cumsum
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__sum);
  __pyx_t_2 = __pyx_v_4cupy_4core_4core__sum; __pyx_t_3 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 749, __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(1, 749, __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(1, 749, __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":741
 *         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_55sum(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_54sum[] = "Returns 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_55sum(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);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
        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(1, 741, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 741, __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_54sum(((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_54sum(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(1, 741, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":753
 *     # 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_57mean(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;
  Py_ssize_t __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(1, 753, __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_57mean)) {
      __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 753, __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(1, 753, __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(1, 753, __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":761
 * 
 *         """
 *         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(1, 761, __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(1, 761, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(1, 761, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 761, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(1, 761, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(1, 761, __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(1, 761, __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(1, 761, __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":753
 *     # 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_57mean(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_56mean[] = "Returns 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_57mean(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);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
        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(1, 753, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 753, __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_56mean(((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_56mean(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(1, 753, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":763
 *         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_59var(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":764
 * 
 *     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;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("var", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_dtype = __pyx_optional_args->dtype;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_ddof = __pyx_optional_args->ddof;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_keepdims = __pyx_optional_args->keepdims;
            }
          }
        }
      }
    }
  }

  /* "cupy/core/core.pyx":763
 *         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(1, 763, __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_59var)) {
      __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 763, __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(1, 763, __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(1, 763, __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":772
 * 
 *         """
 *         return _var(self, axis=axis, dtype=dtype, out=out, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray std(self, axis=None, dtype=None, out=None, ddof=0,
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_var_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 772, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 772, __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(1, 772, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(1, 772, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 772, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(1, 772, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(1, 772, __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(1, 772, __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(1, 772, __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":763
 *         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_59var(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_58var[] = "Returns 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_59var(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":764
 * 
 *     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);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ddof);
          if (value) { values[3] = value; kw_args--; }
        }
        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(1, 763, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 763, __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_58var(((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":763
 *         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_58var(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(1, 763, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":774
 *         return _var(self, axis=axis, dtype=dtype, out=out, 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_61std(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":775
 * 
 *     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;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("std", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_dtype = __pyx_optional_args->dtype;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_ddof = __pyx_optional_args->ddof;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_keepdims = __pyx_optional_args->keepdims;
            }
          }
        }
      }
    }
  }

  /* "cupy/core/core.pyx":774
 *         return _var(self, axis=axis, dtype=dtype, out=out, 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(1, 774, __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_61std)) {
      __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 774, __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(1, 774, __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(1, 774, __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":783
 * 
 *         """
 *         return _std(self, axis=axis, dtype=dtype, out=out, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray prod(self, axis=None, dtype=None, out=None, keepdims=None):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_std_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 783, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 783, __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(1, 783, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(1, 783, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 783, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(1, 783, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(1, 783, __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(1, 783, __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(1, 783, __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":774
 *         return _var(self, axis=axis, dtype=dtype, out=out, 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_61std(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_60std[] = "Returns 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_61std(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":775
 * 
 *     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);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ddof);
          if (value) { values[3] = value; kw_args--; }
        }
        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(1, 774, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 774, __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_60std(((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":774
 *         return _var(self, axis=axis, dtype=dtype, out=out, 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_60std(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(1, 774, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":785
 *         return _std(self, axis=axis, dtype=dtype, out=out, 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_63prod(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;
  Py_ssize_t __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(1, 785, __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_63prod)) {
      __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 785, __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(1, 785, __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(1, 785, __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":793
 * 
 *         """
 *         return _prod(self, axis, dtype, out, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement cumprod
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__prod);
  __pyx_t_2 = __pyx_v_4cupy_4core_4core__prod; __pyx_t_3 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 793, __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(1, 793, __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(1, 793, __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":785
 *         return _std(self, axis=axis, dtype=dtype, out=out, 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_63prod(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_62prod[] = "Returns 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_63prod(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);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
        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(1, 785, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 785, __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_62prod(((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_62prod(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(1, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":797
 *     # 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_65all(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;
  Py_ssize_t __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(1, 797, __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_65all)) {
      __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 797, __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(1, 797, __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(1, 797, __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":798
 * 
 *     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 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 798, __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(1, 798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(1, 798, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(1, 798, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(1, 798, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__all, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 798, __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(1, 798, __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":797
 *     # 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_65all(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_65all(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);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        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(1, 797, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 797, __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_64all(((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_64all(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(1, 797, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":800
 *         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_67any(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;
  Py_ssize_t __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(1, 800, __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_67any)) {
      __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 800, __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(1, 800, __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(1, 800, __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":801
 * 
 *     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 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 801, __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(1, 801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(1, 801, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(1, 801, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(1, 801, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__any, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 801, __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(1, 801, __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":800
 *         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_67any(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_67any(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);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        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(1, 800, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 800, __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_66any(((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_66any(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(1, 800, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":808
 *     # 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_69__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_69__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_68__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_68__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;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__richcmp__", 0);

  /* "cupy/core/core.pyx":809
 * 
 *     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":810
 *     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(1, 810, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 810, __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(1, 810, __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":809
 * 
 *     def __richcmp__(object self, object other, int op):
 *         if op == 0:             # <<<<<<<<<<<<<<
 *             return less(self, other)
 *         if op == 1:
 */
  }

  /* "cupy/core/core.pyx":811
 *         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":812
 *             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(1, 812, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 812, __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(1, 812, __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":811
 *         if op == 0:
 *             return less(self, other)
 *         if op == 1:             # <<<<<<<<<<<<<<
 *             return less_equal(self, other)
 *         if op == 2:
 */
  }

  /* "cupy/core/core.pyx":813
 *         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":814
 *             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(1, 814, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 814, __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(1, 814, __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":813
 *         if op == 1:
 *             return less_equal(self, other)
 *         if op == 2:             # <<<<<<<<<<<<<<
 *             return equal(self, other)
 *         if op == 3:
 */
  }

  /* "cupy/core/core.pyx":815
 *         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":816
 *             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(1, 816, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 816, __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(1, 816, __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":815
 *         if op == 2:
 *             return equal(self, other)
 *         if op == 3:             # <<<<<<<<<<<<<<
 *             return not_equal(self, other)
 *         if op == 4:
 */
  }

  /* "cupy/core/core.pyx":817
 *         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":818
 *             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(1, 818, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 818, __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(1, 818, __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":817
 *         if op == 3:
 *             return not_equal(self, other)
 *         if op == 4:             # <<<<<<<<<<<<<<
 *             return greater(self, other)
 *         if op == 5:
 */
  }

  /* "cupy/core/core.pyx":819
 *         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":820
 *             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(1, 820, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 820, __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(1, 820, __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":819
 *         if op == 4:
 *             return greater(self, other)
 *         if op == 5:             # <<<<<<<<<<<<<<
 *             return greater_equal(self, other)
 *         return NotImplemented
 */
  }

  /* "cupy/core/core.pyx":821
 *         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":808
 *     # 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":825
 *     # 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_71__nonzero__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_71__nonzero__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__nonzero__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_70__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_70__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":826
 * 
 *     def __nonzero__(self):
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return False
 *         elif self.size == 1:
 */
  switch (__pyx_v_self->size) {
    case 0:

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

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

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

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

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

  /* "cupy/core/core.pyx":825
 *     # 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":837
 *     # Unary operations:
 * 
 *     def __neg__(self):             # <<<<<<<<<<<<<<
 *         return negative(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_73__neg__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_73__neg__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__neg__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_72__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_72__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":838
 * 
 *     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(1, 838, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 838, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 838, __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(1, 838, __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":837
 *     # 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":840
 *         return negative(self)
 * 
 *     def __pos__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_75__pos__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_75__pos__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pos__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_74__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_74__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":841
 * 
 *     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":840
 *         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":843
 *         return self
 * 
 *     def __abs__(self):             # <<<<<<<<<<<<<<
 *         return absolute(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_77__abs__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_77__abs__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__abs__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_76__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_76__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":844
 * 
 *     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(1, 844, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 844, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 844, __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(1, 844, __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":843
 *         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":846
 *         return absolute(self)
 * 
 *     def __invert__(self):             # <<<<<<<<<<<<<<
 *         return invert(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_79__invert__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_79__invert__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__invert__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_78__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_78__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":847
 * 
 *     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(1, 847, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 847, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 847, __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(1, 847, __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":846
 *         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":851
 *     # 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_81__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_81__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_80__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_80__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;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__add__", 0);

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

    /* "cupy/core/core.pyx":853
 *     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(1, 853, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 853, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 853, __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(1, 853, __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":852
 * 
 *     def __add__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__radd__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":855
 *             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(1, 855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 855, __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(1, 855, __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":851
 *     # 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":857
 *             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_83__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_83__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_82__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_82__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;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__sub__", 0);

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

    /* "cupy/core/core.pyx":859
 *     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(1, 859, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 859, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 859, __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(1, 859, __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":858
 * 
 *     def __sub__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rsub__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":861
 *             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(1, 861, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 861, __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(1, 861, __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":857
 *             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":863
 *             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_85__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_85__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_84__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_84__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;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__mul__", 0);

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

    /* "cupy/core/core.pyx":865
 *     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(1, 865, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 865, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 865, __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(1, 865, __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":864
 * 
 *     def __mul__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rmul__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":867
 *             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(1, 867, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 867, __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(1, 867, __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":863
 *             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":869
 *             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_87__matmul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_87__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_86__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_86__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":870
 * 
 *     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(1, 870, __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(1, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":871
 *     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(1, 871, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 871, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 871, __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(1, 871, __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":870
 * 
 *     def __matmul__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rmatmul__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":873
 *             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(1, 873, __pyx_L1_error)
    if (!(likely(((__pyx_v_y) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_y, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 873, __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)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 873, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":869
 *             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":875
 *             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
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_89__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_89__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_88__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)*/

#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_88__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;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__div__", 0);

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

    /* "cupy/core/core.pyx":877
 *     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(1, 877, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 877, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 877, __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(1, 877, __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":876
 * 
 *     def __div__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rdiv__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":879
 *             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(1, 879, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 879, __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(1, 879, __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":875
 *             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)*/

/* "cupy/core/core.pyx":881
 *             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_91__truediv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_91__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_90__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_90__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;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__truediv__", 0);

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

    /* "cupy/core/core.pyx":883
 *     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(1, 883, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 883, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 883, __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(1, 883, __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":882
 * 
 *     def __truediv__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rtruediv__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":885
 *             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(1, 885, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 885, __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(1, 885, __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":881
 *             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":887
 *             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_93__floordiv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_93__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_92__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_92__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;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__floordiv__", 0);

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

    /* "cupy/core/core.pyx":889
 *     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(1, 889, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 889, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 889, __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(1, 889, __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":888
 * 
 *     def __floordiv__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rfloordiv__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":891
 *             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(1, 891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 891, __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(1, 891, __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":887
 *             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":893
 *             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_95__mod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_95__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_94__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_94__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;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__mod__", 0);

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

    /* "cupy/core/core.pyx":895
 *     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(1, 895, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 895, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 895, __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(1, 895, __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":894
 * 
 *     def __mod__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rmod__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":897
 *             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(1, 897, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 897, __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(1, 897, __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":893
 *             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":899
 *             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_97__divmod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_97__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_96__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_96__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;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__divmod__", 0);

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

    /* "cupy/core/core.pyx":901
 *     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(1, 901, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 901, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 901, __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(1, 901, __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":900
 * 
 *     def __divmod__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rdivmod__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":903
 *             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(1, 903, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 903, __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(1, 903, __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":899
 *             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":905
 *             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_99__pow__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_modulo); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_99__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_98__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_98__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;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__pow__", 0);

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

    /* "cupy/core/core.pyx":908
 *         # 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(1, 908, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 908, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 908, __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(1, 908, __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":907
 *     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":910
 *             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(1, 910, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 910, __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(1, 910, __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":905
 *             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":912
 *             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_101__lshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_101__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_100__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_100__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;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__lshift__", 0);

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

    /* "cupy/core/core.pyx":914
 *     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(1, 914, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 914, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 914, __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(1, 914, __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":913
 * 
 *     def __lshift__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rlshift__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":916
 *             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(1, 916, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 916, __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(1, 916, __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":912
 *             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":918
 *             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_103__rshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_103__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_102__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_102__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;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__rshift__", 0);

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

    /* "cupy/core/core.pyx":920
 *     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(1, 920, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 920, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 920, __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(1, 920, __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":919
 * 
 *     def __rshift__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rrshift__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":922
 *             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(1, 922, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 922, __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(1, 922, __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":918
 *             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":924
 *             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_105__and__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_105__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_104__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_104__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;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__and__", 0);

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

    /* "cupy/core/core.pyx":926
 *     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(1, 926, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 926, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 926, __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(1, 926, __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":925
 * 
 *     def __and__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rand__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":928
 *             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(1, 928, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 928, __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(1, 928, __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":924
 *             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":930
 *             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_107__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_107__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_106__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_106__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;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__or__", 0);

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

    /* "cupy/core/core.pyx":932
 *     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(1, 932, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 932, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 932, __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(1, 932, __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":931
 * 
 *     def __or__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__ror__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":934
 *             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(1, 934, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 934, __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(1, 934, __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":930
 *             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":936
 *             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_109__xor__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_109__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_108__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_108__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;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__xor__", 0);

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

    /* "cupy/core/core.pyx":938
 *     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(1, 938, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 938, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 938, __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(1, 938, __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":937
 * 
 *     def __xor__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rxor__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":940
 *             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(1, 940, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 940, __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(1, 940, __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":936
 *             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":944
 *     # Arithmetic, in-place:
 * 
 *     def __iadd__(self, other):             # <<<<<<<<<<<<<<
 *         return add(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_111__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_111__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_110__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_110__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;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__iadd__", 0);

  /* "cupy/core/core.pyx":945
 * 
 *     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(1, 945, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 945, __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(1, 945, __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":944
 *     # 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":947
 *         return add(self, other, self)
 * 
 *     def __isub__(self, other):             # <<<<<<<<<<<<<<
 *         return subtract(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_113__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_113__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_112__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_112__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;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__isub__", 0);

  /* "cupy/core/core.pyx":948
 * 
 *     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(1, 948, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 948, __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(1, 948, __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":947
 *         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":950
 *         return subtract(self, other, self)
 * 
 *     def __imul__(self, other):             # <<<<<<<<<<<<<<
 *         return multiply(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_115__imul__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_115__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_114__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_114__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;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__imul__", 0);

  /* "cupy/core/core.pyx":951
 * 
 *     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(1, 951, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 951, __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(1, 951, __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":950
 *         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":953
 *         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
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_117__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_117__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_116__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)*/

#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_116__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;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__idiv__", 0);

  /* "cupy/core/core.pyx":954
 * 
 *     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(1, 954, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 954, __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(1, 954, __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":953
 *         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)*/

/* "cupy/core/core.pyx":956
 *         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_119__itruediv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_119__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_118__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_118__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;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__itruediv__", 0);

  /* "cupy/core/core.pyx":957
 * 
 *     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(1, 957, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 957, __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(1, 957, __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":956
 *         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":959
 *         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_121__ifloordiv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_121__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_120__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_120__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;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__ifloordiv__", 0);

  /* "cupy/core/core.pyx":960
 * 
 *     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(1, 960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 960, __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(1, 960, __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":959
 *         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":962
 *         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_123__imod__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_123__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_122__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_122__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;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__imod__", 0);

  /* "cupy/core/core.pyx":963
 * 
 *     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(1, 963, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 963, __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(1, 963, __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":962
 *         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":965
 *         return remainder(self, other, self)
 * 
 *     def __ipow__(self, other):             # <<<<<<<<<<<<<<
 *         return power(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_125__ipow__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_125__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_124__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_124__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;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__ipow__", 0);

  /* "cupy/core/core.pyx":966
 * 
 *     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(1, 966, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 966, __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(1, 966, __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":965
 *         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":968
 *         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_127__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_127__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_126__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_126__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;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__ilshift__", 0);

  /* "cupy/core/core.pyx":969
 * 
 *     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(1, 969, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 969, __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(1, 969, __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":968
 *         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":971
 *         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_129__irshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_129__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_128__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_128__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;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__irshift__", 0);

  /* "cupy/core/core.pyx":972
 * 
 *     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(1, 972, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 972, __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(1, 972, __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":971
 *         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":974
 *         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_131__iand__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_131__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_130__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_130__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;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__iand__", 0);

  /* "cupy/core/core.pyx":975
 * 
 *     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(1, 975, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 975, __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(1, 975, __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":974
 *         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":977
 *         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_133__ior__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_133__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_132__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_132__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;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__ior__", 0);

  /* "cupy/core/core.pyx":978
 * 
 *     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(1, 978, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 978, __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(1, 978, __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":977
 *         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":980
 *         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_135__ixor__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_135__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_134__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_134__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;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__ixor__", 0);

  /* "cupy/core/core.pyx":981
 * 
 *     def __ixor__(self, other):
 *         return bitwise_xor(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_bitwise_xor); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 981, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 981, __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(1, 981, __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":980
 *         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":988
 *     # For standard library functions:
 * 
 *     def __copy__(self):             # <<<<<<<<<<<<<<
 *         return self.copy()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_137__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_137__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_136__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_136__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":989
 * 
 *     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)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 989, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_139__deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_139__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_138__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_138__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;
  __Pyx_RefNannySetupContext("__deepcopy__", 0);

  /* "cupy/core/core.pyx":992
 * 
 *     def __deepcopy__(self, memo):
 *         return self.copy()             # <<<<<<<<<<<<<<
 * 
 *     def __reduce__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->copy(__pyx_v_self, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __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":994
 *         return self.copy()
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return array, (self.get(),)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_141__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_141__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_140__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_140__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":995
 * 
 *     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(1, 995, __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(1, 995, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 995, __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(1, 995, __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":994
 *         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":1001
 *     # 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_143__array__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_143__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);
        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(1, 1001, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 1001, __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_142__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_142__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":1002
 * 
 *     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(1, 1002, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 1002, __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":1003
 *     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":1002
 * 
 *     def __array__(self, dtype=None):
 *         if dtype is None or self.dtype == dtype:             # <<<<<<<<<<<<<<
 *             return self
 *         else:
 */
  }

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

  /* "cupy/core/core.pyx":1001
 *     # 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":1011
 *     # 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_145__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_4cupy_4core_4core_7ndarray_145__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_144__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_144__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":1012
 * 
 *     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":1013
 *     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__11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1013, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(1, 1013, __pyx_L1_error)

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

  /* "cupy/core/core.pyx":1014
 *         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":1011
 *     # 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":1016
 *         return self._shape[0]
 * 
 *     def __getitem__(self, slices):             # <<<<<<<<<<<<<<
 *         """x.__getitem__(y) <==> x[y]
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_147__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_slices); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_146__getitem__[] = "x.__getitem__(y) <==> x[y]\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_146__getitem__;
#endif
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_147__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_146__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_146__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;
  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;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  std::vector<Py_ssize_t>  __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  Py_ssize_t __pyx_t_15;
  __Pyx_RefNannySetupContext("__getitem__", 0);
  __Pyx_INCREF(__pyx_v_slices);

  /* "cupy/core/core.pyx":1037
 *         cdef Py_ssize_t ellipsis_sizem, s_start, s_stop, s_step, dim, ind
 *         cdef vector.vector[Py_ssize_t] shape, strides
 *         if not isinstance(slices, tuple):             # <<<<<<<<<<<<<<
 *             slices = [slices]
 *         else:
 */
  __pyx_t_1 = PyTuple_Check(__pyx_v_slices); 
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1038
 *         cdef vector.vector[Py_ssize_t] shape, strides
 *         if not isinstance(slices, tuple):
 *             slices = [slices]             # <<<<<<<<<<<<<<
 *         else:
 *             slices = list(slices)
 */
    __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1038, __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":1037
 *         cdef Py_ssize_t ellipsis_sizem, s_start, s_stop, s_step, dim, ind
 *         cdef vector.vector[Py_ssize_t] shape, strides
 *         if not isinstance(slices, tuple):             # <<<<<<<<<<<<<<
 *             slices = [slices]
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1040
 *             slices = [slices]
 *         else:
 *             slices = list(slices)             # <<<<<<<<<<<<<<
 * 
 *         # Expand ellipsis into empty slices
 */
  /*else*/ {
    __pyx_t_3 = PySequence_List(__pyx_v_slices); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1040, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_slices, __pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1043
 * 
 *         # 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":1044
 *         # 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":1045
 *         ellipsis = -1
 *         n_newaxes = n_ellipses = 0
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if s is None:
 *                 n_newaxes += 1
 */
  __pyx_t_4 = 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(1, 1045, __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, 1045, __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_COMPILING_IN_CPYTHON
        __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, 1045, __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, 1045, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 1045, __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, 1045, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      }
    } else {
      __pyx_t_7 = __pyx_t_6(__pyx_t_3);
      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(1, 1045, __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_4;
    __pyx_t_4 = (__pyx_t_4 + 1);

    /* "cupy/core/core.pyx":1046
 *         n_newaxes = n_ellipses = 0
 *         for i, s in enumerate(slices):
 *             if s is None:             # <<<<<<<<<<<<<<
 *                 n_newaxes += 1
 *             elif s is Ellipsis:
 */
    __pyx_t_2 = (__pyx_v_s == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1047
 *         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":1046
 *         n_newaxes = n_ellipses = 0
 *         for i, s in enumerate(slices):
 *             if s is None:             # <<<<<<<<<<<<<<
 *                 n_newaxes += 1
 *             elif s is Ellipsis:
 */
      goto __pyx_L6;
    }

    /* "cupy/core/core.pyx":1048
 *             if s is None:
 *                 n_newaxes += 1
 *             elif s is Ellipsis:             # <<<<<<<<<<<<<<
 *                 n_ellipses += 1
 *                 ellipsis = i
 */
    __pyx_t_1 = (__pyx_v_s == __pyx_builtin_Ellipsis);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1049
 *                 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":1050
 *             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":1048
 *             if s is None:
 *                 n_newaxes += 1
 *             elif s is Ellipsis:             # <<<<<<<<<<<<<<
 *                 n_ellipses += 1
 *                 ellipsis = i
 */
    }
    __pyx_L6:;

    /* "cupy/core/core.pyx":1045
 *         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":1051
 *                 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":1052
 *                 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(1, 1052, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_slice__12);
  __Pyx_GIVEREF(__pyx_slice__12);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_slice__12);
  __pyx_v_noneslices = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1053
 *         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_2 = ((__pyx_v_n_ellipses > 0) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1054
 *         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_2 = ((__pyx_v_n_ellipses > 1) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1055
 *         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__13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1055, __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, 1055, __pyx_L1_error)

      /* "cupy/core/core.pyx":1054
 *         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":1056
 *             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_4 = PyObject_Length(__pyx_v_slices); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 1056, __pyx_L1_error)
    __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_ndim - ((((Py_ssize_t)__pyx_t_4) - __pyx_v_n_newaxes) - 1))); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1056, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_ellipsis_size = __pyx_t_3;
    __pyx_t_3 = 0;

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

    /* "cupy/core/core.pyx":1053
 *         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":1059
 *             slices[ellipsis:ellipsis + 1] = noneslices * ellipsis_size
 * 
 *         slices += noneslices * (ndim - <Py_ssize_t>len(slices) + n_newaxes)             # <<<<<<<<<<<<<<
 * 
 *         if len(slices) > self.ndim + n_newaxes:
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_slices); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 1059, __pyx_L1_error)
  __pyx_t_3 = PyInt_FromSsize_t(((__pyx_v_ndim - ((Py_ssize_t)__pyx_t_4)) + __pyx_v_n_newaxes)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1059, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = PyNumber_Multiply(__pyx_v_noneslices, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1059, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_slices, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1059, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF_SET(__pyx_v_slices, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1061
 *         slices += noneslices * (ndim - <Py_ssize_t>len(slices) + n_newaxes)
 * 
 *         if len(slices) > self.ndim + n_newaxes:             # <<<<<<<<<<<<<<
 *             raise IndexError('too many indices for array')
 * 
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_slices); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 1061, __pyx_L1_error)
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1061, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1061, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_n_newaxes); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1061, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = PyNumber_Add(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1061, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyObject_RichCompare(__pyx_t_3, __pyx_t_9, Py_GT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1061, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 1061, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1062
 * 
 *         if len(slices) > self.ndim + n_newaxes:
 *             raise IndexError('too many indices for array')             # <<<<<<<<<<<<<<
 * 
 *         # Check if advanced is true, and convert list/NumPy arrays to ndarray
 */
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1062, __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(1, 1062, __pyx_L1_error)

    /* "cupy/core/core.pyx":1061
 *         slices += noneslices * (ndim - <Py_ssize_t>len(slices) + n_newaxes)
 * 
 *         if len(slices) > self.ndim + n_newaxes:             # <<<<<<<<<<<<<<
 *             raise IndexError('too many indices for array')
 * 
 */
  }

  /* "cupy/core/core.pyx":1065
 * 
 *         # Check if advanced is true, and convert list/NumPy arrays to ndarray
 *         advanced = False             # <<<<<<<<<<<<<<
 *         for i, s in enumerate(slices):
 *             if isinstance(s, (list, numpy.ndarray)):
 */
  __pyx_v_advanced = 0;

  /* "cupy/core/core.pyx":1066
 *         # Check if advanced is true, and convert list/NumPy arrays to ndarray
 *         advanced = False
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if isinstance(s, (list, numpy.ndarray)):
 *                 s = array(s)
 */
  __pyx_t_4 = 0;
  if (likely(PyList_CheckExact(__pyx_v_slices)) || PyTuple_CheckExact(__pyx_v_slices)) {
    __pyx_t_8 = __pyx_v_slices; __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_slices); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1066, __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(1, 1066, __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_COMPILING_IN_CPYTHON
        __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(1, 1066, __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(1, 1066, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(1, 1066, __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(1, 1066, __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(1, 1066, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_9);
    }
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_v_i = __pyx_t_4;
    __pyx_t_4 = (__pyx_t_4 + 1);

    /* "cupy/core/core.pyx":1067
 *         advanced = False
 *         for i, s in enumerate(slices):
 *             if isinstance(s, (list, numpy.ndarray)):             # <<<<<<<<<<<<<<
 *                 s = array(s)
 *                 slices[i] = s
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1067, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1067, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_1 = PyList_Check(__pyx_v_s); 
    __pyx_t_10 = (__pyx_t_1 != 0);
    if (!__pyx_t_10) {
    } else {
      __pyx_t_2 = __pyx_t_10;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_10 = PyObject_IsInstance(__pyx_v_s, __pyx_t_3); 
    __pyx_t_1 = (__pyx_t_10 != 0);
    __pyx_t_2 = __pyx_t_1;
    __pyx_L13_bool_binop_done:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1068
 *         for i, s in enumerate(slices):
 *             if isinstance(s, (list, numpy.ndarray)):
 *                 s = array(s)             # <<<<<<<<<<<<<<
 *                 slices[i] = s
 *             if isinstance(s, ndarray):
 */
      __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_v_s, 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1068, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":1069
 *             if isinstance(s, (list, numpy.ndarray)):
 *                 s = array(s)
 *                 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(1, 1069, __pyx_L1_error)

      /* "cupy/core/core.pyx":1067
 *         advanced = False
 *         for i, s in enumerate(slices):
 *             if isinstance(s, (list, numpy.ndarray)):             # <<<<<<<<<<<<<<
 *                 s = array(s)
 *                 slices[i] = s
 */
    }

    /* "cupy/core/core.pyx":1070
 *                 s = array(s)
 *                 slices[i] = s
 *             if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *                 if issubclass(s.dtype.type, numpy.integer):
 *                     advanced = True
 */
    __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) {

      /* "cupy/core/core.pyx":1071
 *                 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_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1071, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1071, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __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(1, 1071, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_integer); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1071, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_2 = PyObject_IsSubclass(__pyx_t_9, __pyx_t_7); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(1, 1071, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_1 = (__pyx_t_2 != 0);
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":1072
 *             if isinstance(s, ndarray):
 *                 if issubclass(s.dtype.type, numpy.integer):
 *                     advanced = True             # <<<<<<<<<<<<<<
 *                 elif issubclass(s.dtype.type, numpy.bool_):
 *                     if i == 0 and internal.vector_equal(self._shape, s._shape):
 */
        __pyx_v_advanced = 1;

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

      /* "cupy/core/core.pyx":1073
 *                 if issubclass(s.dtype.type, numpy.integer):
 *                     advanced = True
 *                 elif issubclass(s.dtype.type, numpy.bool_):             # <<<<<<<<<<<<<<
 *                     if i == 0 and internal.vector_equal(self._shape, s._shape):
 *                         return _boolean_array_indexing(self, s)
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1073, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1073, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __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(1, 1073, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_bool); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1073, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_1 = PyObject_IsSubclass(__pyx_t_9, __pyx_t_3); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 1073, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 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":1074
 *                     advanced = True
 *                 elif issubclass(s.dtype.type, numpy.bool_):
 *                     if i == 0 and internal.vector_equal(self._shape, s._shape):             # <<<<<<<<<<<<<<
 *                         return _boolean_array_indexing(self, s)
 *                     else:
 */
        __pyx_t_1 = ((__pyx_v_i == 0) != 0);
        if (__pyx_t_1) {
        } else {
          __pyx_t_2 = __pyx_t_1;
          goto __pyx_L18_bool_binop_done;
        }
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_shape_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1074, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_11 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 1074, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_1 = (__pyx_f_4cupy_4core_8internal_vector_equal(__pyx_v_self->_shape, __pyx_t_11, 0) != 0);
        __pyx_t_2 = __pyx_t_1;
        __pyx_L18_bool_binop_done:;
        if (__pyx_t_2) {

          /* "cupy/core/core.pyx":1075
 *                 elif issubclass(s.dtype.type, numpy.bool_):
 *                     if i == 0 and internal.vector_equal(self._shape, s._shape):
 *                         return _boolean_array_indexing(self, s)             # <<<<<<<<<<<<<<
 *                     else:
 *                         raise ValueError('Boolean array indexing is supported '
 */
          __Pyx_XDECREF(__pyx_r);
          if (!(likely(((__pyx_v_s) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 1075, __pyx_L1_error)
          __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core__boolean_array_indexing(__pyx_v_self, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_s), 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1075, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_r = __pyx_t_3;
          __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          goto __pyx_L0;

          /* "cupy/core/core.pyx":1074
 *                     advanced = True
 *                 elif issubclass(s.dtype.type, numpy.bool_):
 *                     if i == 0 and internal.vector_equal(self._shape, s._shape):             # <<<<<<<<<<<<<<
 *                         return _boolean_array_indexing(self, s)
 *                     else:
 */
        }

        /* "cupy/core/core.pyx":1077
 *                         return _boolean_array_indexing(self, s)
 *                     else:
 *                         raise ValueError('Boolean array indexing is supported '             # <<<<<<<<<<<<<<
 *                                          'only for same sized array.')
 *                 else:
 */
        /*else*/ {
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1077, __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, 1077, __pyx_L1_error)
        }

        /* "cupy/core/core.pyx":1073
 *                 if issubclass(s.dtype.type, numpy.integer):
 *                     advanced = True
 *                 elif issubclass(s.dtype.type, numpy.bool_):             # <<<<<<<<<<<<<<
 *                     if i == 0 and internal.vector_equal(self._shape, s._shape):
 *                         return _boolean_array_indexing(self, s)
 */
      }

      /* "cupy/core/core.pyx":1080
 *                                          'only for same sized array.')
 *                 else:
 *                     raise IndexError(             # <<<<<<<<<<<<<<
 *                         'arrays used as indices must be of integer or boolean '
 *                         'type. (actual: {})'.format(s.dtype.type))
 */
      /*else*/ {

        /* "cupy/core/core.pyx":1082
 *                     raise IndexError(
 *                         'arrays used as indices must be of integer or boolean '
 *                         'type. (actual: {})'.format(s.dtype.type))             # <<<<<<<<<<<<<<
 * 
 *         if advanced:
 */
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_arrays_used_as_indices_must_be_o, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1082, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1082, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_type); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 1082, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && 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_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1082, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_GOTREF(__pyx_t_3);
        } else {
          __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1082, __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_GIVEREF(__pyx_t_12);
          PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_12);
          __pyx_t_12 = 0;
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1082, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

        /* "cupy/core/core.pyx":1080
 *                                          'only for same sized array.')
 *                 else:
 *                     raise IndexError(             # <<<<<<<<<<<<<<
 *                         'arrays used as indices must be of integer or boolean '
 *                         'type. (actual: {})'.format(s.dtype.type))
 */
        __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1080, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1080, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __PYX_ERR(1, 1080, __pyx_L1_error)
      }
      __pyx_L16:;

      /* "cupy/core/core.pyx":1070
 *                 s = array(s)
 *                 slices[i] = s
 *             if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *                 if issubclass(s.dtype.type, numpy.integer):
 *                     advanced = True
 */
    }

    /* "cupy/core/core.pyx":1066
 *         # Check if advanced is true, and convert list/NumPy arrays to ndarray
 *         advanced = False
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if isinstance(s, (list, numpy.ndarray)):
 *                 s = array(s)
 */
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":1084
 *                         'type. (actual: {})'.format(s.dtype.type))
 * 
 *         if advanced:             # <<<<<<<<<<<<<<
 *             # split slices that can be handled by basic-indexing
 *             basic_slices = []
 */
  __pyx_t_2 = (__pyx_v_advanced != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1086
 *         if advanced:
 *             # split slices that can be handled by basic-indexing
 *             basic_slices = []             # <<<<<<<<<<<<<<
 *             adv_slices = []
 *             for i, s in enumerate(slices):
 */
    __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1086, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_v_basic_slices = ((PyObject*)__pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":1087
 *             # 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_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1087, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_v_adv_slices = ((PyObject*)__pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":1088
 *             basic_slices = []
 *             adv_slices = []
 *             for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *                 if type(s) is slice:
 *                     basic_slices.append(s)
 */
    __pyx_t_4 = 0;
    if (likely(PyList_CheckExact(__pyx_v_slices)) || PyTuple_CheckExact(__pyx_v_slices)) {
      __pyx_t_8 = __pyx_v_slices; __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_slices); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1088, __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(1, 1088, __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_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 1088, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1088, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 1088, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1088, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_6(__pyx_t_8);
        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(1, 1088, __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_4;
      __pyx_t_4 = (__pyx_t_4 + 1);

      /* "cupy/core/core.pyx":1089
 *             adv_slices = []
 *             for i, s in enumerate(slices):
 *                 if type(s) is slice:             # <<<<<<<<<<<<<<
 *                     basic_slices.append(s)
 *                     adv_slices.append(slice(None))
 */
      __pyx_t_2 = (((PyObject *)Py_TYPE(__pyx_v_s)) == ((PyObject *)(&PySlice_Type)));
      __pyx_t_1 = (__pyx_t_2 != 0);
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":1090
 *             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(1, 1090, __pyx_L1_error)

        /* "cupy/core/core.pyx":1091
 *                 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__16); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(1, 1091, __pyx_L1_error)

        /* "cupy/core/core.pyx":1089
 *             adv_slices = []
 *             for i, s in enumerate(slices):
 *                 if type(s) is slice:             # <<<<<<<<<<<<<<
 *                     basic_slices.append(s)
 *                     adv_slices.append(slice(None))
 */
        goto __pyx_L23;
      }

      /* "cupy/core/core.pyx":1092
 *                     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_2 = (__pyx_t_1 != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1093
 *                     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(1, 1093, __pyx_L1_error)

        /* "cupy/core/core.pyx":1094
 *                 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__17); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(1, 1094, __pyx_L1_error)

        /* "cupy/core/core.pyx":1092
 *                     basic_slices.append(s)
 *                     adv_slices.append(slice(None))
 *                 elif s is None:             # <<<<<<<<<<<<<<
 *                     basic_slices.append(None)
 *                     adv_slices.append(slice(None))
 */
        goto __pyx_L23;
      }

      /* "cupy/core/core.pyx":1095
 *                     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_10 = (__pyx_t_1 != 0);
      if (__pyx_t_10) {
      } else {
        __pyx_t_2 = __pyx_t_10;
        goto __pyx_L24_bool_binop_done;
      }

      /* "cupy/core/core.pyx":1096
 *                     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_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1096, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1096, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __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(1, 1096, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_integer); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1096, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_10 = PyObject_IsSubclass(__pyx_t_9, __pyx_t_13); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(1, 1096, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_1 = (__pyx_t_10 != 0);
      __pyx_t_2 = __pyx_t_1;
      __pyx_L24_bool_binop_done:;

      /* "cupy/core/core.pyx":1095
 *                     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_2) {

        /* "cupy/core/core.pyx":1097
 *                 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__18); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(1, 1097, __pyx_L1_error)

        /* "cupy/core/core.pyx":1098
 *                         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(1, 1098, __pyx_L1_error)

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

      /* "cupy/core/core.pyx":1099
 *                     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_2 = PyInt_Check(__pyx_v_s); 
      __pyx_t_1 = (__pyx_t_2 != 0);
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":1100
 *                     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__19); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(1, 1100, __pyx_L1_error)

        /* "cupy/core/core.pyx":1101
 *                 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_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1101, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1101, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_int64); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1101, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_dtype, __pyx_t_3) < 0) __PYX_ERR(1, 1101, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_tuple__20, __pyx_t_13); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1101, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF_SET(__pyx_v_scalar_array, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
        __pyx_t_3 = 0;

        /* "cupy/core/core.pyx":1102
 *                     basic_slices.append(slice(None))
 *                     scalar_array = ndarray((), dtype=numpy.int64)
 *                     scalar_array.fill(s)             # <<<<<<<<<<<<<<
 *                     adv_slices.append(scalar_array)
 *                 else:
 */
        __pyx_t_3 = ((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_3)) __PYX_ERR(1, 1102, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "cupy/core/core.pyx":1103
 *                     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(1, 1103, __pyx_L1_error)

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

      /* "cupy/core/core.pyx":1105
 *                     adv_slices.append(scalar_array)
 *                 else:
 *                     raise IndexError(             # <<<<<<<<<<<<<<
 *                         'only integers, slices (`:`), ellipsis (`...`),'
 *                         'numpy.newaxis (`None`) and integer or'
 */
      /*else*/ {
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1105, __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, 1105, __pyx_L1_error)
      }
      __pyx_L23:;

      /* "cupy/core/core.pyx":1088
 *             basic_slices = []
 *             adv_slices = []
 *             for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *                 if type(s) is slice:
 *                     basic_slices.append(s)
 */
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":1111
 * 
 *             # 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":1112
 *             # 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_8 = __pyx_v_basic_slices; __Pyx_INCREF(__pyx_t_8); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_8)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 1112, __pyx_L1_error)
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":1113
 *             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_2 = (__pyx_v_s == Py_None);
      __pyx_t_10 = (__pyx_t_2 != 0);
      if (!__pyx_t_10) {
      } else {
        __pyx_t_1 = __pyx_t_10;
        goto __pyx_L29_bool_binop_done;
      }
      __pyx_t_10 = PySlice_Check(__pyx_v_s); 
      __pyx_t_2 = (__pyx_t_10 != 0);
      if (__pyx_t_2) {
      } else {
        __pyx_t_1 = __pyx_t_2;
        goto __pyx_L29_bool_binop_done;
      }
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_s, __pyx_slice__22, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1113, __pyx_L1_error)
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 1113, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_1 = __pyx_t_2;
      __pyx_L29_bool_binop_done:;
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":1114
 *             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_3 = PyList_AsTuple(__pyx_v_basic_slices); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1114, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_13 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_t_3); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1114, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF_SET(__pyx_v_a, __pyx_t_13);
        __pyx_t_13 = 0;

        /* "cupy/core/core.pyx":1115
 *                 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_L27_break;

        /* "cupy/core/core.pyx":1113
 *             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":1112
 *             # 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_L27_break:;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":1117
 *                     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_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_13 = __pyx_v_adv_slices; __Pyx_INCREF(__pyx_t_13); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_13)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_13, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 1117, __pyx_L1_error)
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_13, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1117, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_1 = PySlice_Check(__pyx_v_s); 
      __pyx_t_3 = __Pyx_PyBool_FromLong((!(__pyx_t_1 != 0))); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1117, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_8, (PyObject*)__pyx_t_3))) __PYX_ERR(1, 1117, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_v_arr_slices_mask = ((PyObject*)__pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":1118
 * 
 *             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_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1118, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v_arr_slices_mask);
    __Pyx_GIVEREF(__pyx_v_arr_slices_mask);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_arr_slices_mask);
    __pyx_t_13 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_8, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1118, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyInt_EqObjC(__pyx_t_13, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1118, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 1118, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1119
 *             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 _adv_getitem(a, adv_slices)
 */
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr_slices_mask, __pyx_n_s_index); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1119, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1119, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_v_axis = __pyx_t_13;
      __pyx_t_13 = 0;

      /* "cupy/core/core.pyx":1120
 *             if sum(arr_slices_mask) == 1:
 *                 axis = arr_slices_mask.index(True)
 *                 return a.take(adv_slices[axis], axis)             # <<<<<<<<<<<<<<
 *             return _adv_getitem(a, adv_slices)
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_take); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1120, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_3 = PyObject_GetItem(__pyx_v_adv_slices, __pyx_v_axis); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1120, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = NULL;
      __pyx_t_4 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && 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_4 = 1;
        }
      }
      __pyx_t_12 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 1120, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_9) {
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9); __pyx_t_9 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_4, __pyx_t_3);
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_4, __pyx_v_axis);
      __pyx_t_3 = 0;
      __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_12, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1120, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_13;
      __pyx_t_13 = 0;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":1118
 * 
 *             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":1121
 *                 axis = arr_slices_mask.index(True)
 *                 return a.take(adv_slices[axis], axis)
 *             return _adv_getitem(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(1, 1121, __pyx_L1_error)
    __pyx_t_13 = ((PyObject *)__pyx_f_4cupy_4core_4core__adv_getitem(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_a), __pyx_v_adv_slices, 0)); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_r = __pyx_t_13;
    __pyx_t_13 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1084
 *                         'type. (actual: {})'.format(s.dtype.type))
 * 
 *         if advanced:             # <<<<<<<<<<<<<<
 *             # split slices that can be handled by basic-indexing
 *             basic_slices = []
 */
  }

  /* "cupy/core/core.pyx":1124
 * 
 *         # Create new shape and stride
 *         j = 0             # <<<<<<<<<<<<<<
 *         offset = 0
 *         for i, s in enumerate(slices):
 */
  __pyx_v_j = 0;

  /* "cupy/core/core.pyx":1125
 *         # 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":1126
 *         j = 0
 *         offset = 0
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if s is None:
 *                 shape.push_back(1)
 */
  __pyx_t_4 = 0;
  if (likely(PyList_CheckExact(__pyx_v_slices)) || PyTuple_CheckExact(__pyx_v_slices)) {
    __pyx_t_13 = __pyx_v_slices; __Pyx_INCREF(__pyx_t_13); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_13 = PyObject_GetIter(__pyx_v_slices); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1126, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_6 = Py_TYPE(__pyx_t_13)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1126, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_13))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_13)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_8 = PyList_GET_ITEM(__pyx_t_13, __pyx_t_5); __Pyx_INCREF(__pyx_t_8); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 1126, __pyx_L1_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_13, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1126, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_13)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_13, __pyx_t_5); __Pyx_INCREF(__pyx_t_8); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 1126, __pyx_L1_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_13, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1126, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      }
    } else {
      __pyx_t_8 = __pyx_t_6(__pyx_t_13);
      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, 1126, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_8);
    }
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_v_i = __pyx_t_4;
    __pyx_t_4 = (__pyx_t_4 + 1);

    /* "cupy/core/core.pyx":1127
 *         offset = 0
 *         for i, s in enumerate(slices):
 *             if s is None:             # <<<<<<<<<<<<<<
 *                 shape.push_back(1)
 *                 if j < ndim:
 */
    __pyx_t_1 = (__pyx_v_s == Py_None);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

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

      /* "cupy/core/core.pyx":1129
 *             if s is None:
 *                 shape.push_back(1)
 *                 if j < ndim:             # <<<<<<<<<<<<<<
 *                     strides.push_back(self._strides[j])
 *                 elif ndim > 0:
 */
      __pyx_t_2 = ((__pyx_v_j < __pyx_v_ndim) != 0);
      if (__pyx_t_2) {

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

        /* "cupy/core/core.pyx":1129
 *             if s is None:
 *                 shape.push_back(1)
 *                 if j < ndim:             # <<<<<<<<<<<<<<
 *                     strides.push_back(self._strides[j])
 *                 elif ndim > 0:
 */
        goto __pyx_L38;
      }

      /* "cupy/core/core.pyx":1131
 *                 if j < ndim:
 *                     strides.push_back(self._strides[j])
 *                 elif ndim > 0:             # <<<<<<<<<<<<<<
 *                     strides.push_back(self._strides[ndim - 1])
 *                 else:
 */
      __pyx_t_2 = ((__pyx_v_ndim > 0) != 0);
      if (__pyx_t_2) {

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

        /* "cupy/core/core.pyx":1131
 *                 if j < ndim:
 *                     strides.push_back(self._strides[j])
 *                 elif ndim > 0:             # <<<<<<<<<<<<<<
 *                     strides.push_back(self._strides[ndim - 1])
 *                 else:
 */
        goto __pyx_L38;
      }

      /* "cupy/core/core.pyx":1134
 *                     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_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1134, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1134, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        try {
          __pyx_v_strides.push_back(__pyx_t_15);
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(1, 1134, __pyx_L1_error)
        }
      }
      __pyx_L38:;

      /* "cupy/core/core.pyx":1127
 *         offset = 0
 *         for i, s in enumerate(slices):
 *             if s is None:             # <<<<<<<<<<<<<<
 *                 shape.push_back(1)
 *                 if j < ndim:
 */
      goto __pyx_L37;
    }

    /* "cupy/core/core.pyx":1135
 *                 else:
 *                     strides.push_back(self.itemsize)
 *             elif ndim <= j:             # <<<<<<<<<<<<<<
 *                 raise IndexError("too many indices for array")
 *             elif isinstance(s, slice):
 */
    __pyx_t_2 = ((__pyx_v_ndim <= __pyx_v_j) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1136
 *                     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_8 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1136, __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(1, 1136, __pyx_L1_error)

      /* "cupy/core/core.pyx":1135
 *                 else:
 *                     strides.push_back(self.itemsize)
 *             elif ndim <= j:             # <<<<<<<<<<<<<<
 *                 raise IndexError("too many indices for array")
 *             elif isinstance(s, slice):
 */
    }

    /* "cupy/core/core.pyx":1137
 *             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_2 = PySlice_Check(__pyx_v_s); 
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1138
 *                 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(1, 1138, __pyx_L1_error)
      __pyx_t_8 = __pyx_f_4cupy_4core_8internal_complete_slice(((PyObject*)__pyx_v_s), (__pyx_v_self->_shape[__pyx_v_j]), 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":1139
 *             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_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_start); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1139, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1139, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_v_s_start = __pyx_t_15;

      /* "cupy/core/core.pyx":1140
 *                 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_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_stop); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1140, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1140, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_v_s_stop = __pyx_t_15;

      /* "cupy/core/core.pyx":1141
 *                 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_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_step); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1141, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_v_s_step = __pyx_t_15;

      /* "cupy/core/core.pyx":1142
 *                 s_stop = s.stop
 *                 s_step = s.step
 *                 if s_step > 0:             # <<<<<<<<<<<<<<
 *                     dim = (s_stop - s_start - 1) // s_step + 1
 *                 else:
 */
      __pyx_t_1 = ((__pyx_v_s_step > 0) != 0);
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":1143
 *                 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(1, 1143, __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(1, 1143, __pyx_L1_error)
        }
        __pyx_v_dim = (__Pyx_div_Py_ssize_t(__pyx_t_15, __pyx_v_s_step) + 1);

        /* "cupy/core/core.pyx":1142
 *                 s_stop = s.stop
 *                 s_step = s.step
 *                 if s_step > 0:             # <<<<<<<<<<<<<<
 *                     dim = (s_stop - s_start - 1) // s_step + 1
 *                 else:
 */
        goto __pyx_L39;
      }

      /* "cupy/core/core.pyx":1145
 *                     dim = (s_stop - s_start - 1) // s_step + 1
 *                 else:
 *                     dim = (s_stop - s_start + 1) // s_step + 1             # <<<<<<<<<<<<<<
 * 
 *                 shape.push_back(dim)
 */
      /*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(1, 1145, __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(1, 1145, __pyx_L1_error)
        }
        __pyx_v_dim = (__Pyx_div_Py_ssize_t(__pyx_t_15, __pyx_v_s_step) + 1);
      }
      __pyx_L39:;

      /* "cupy/core/core.pyx":1147
 *                     dim = (s_stop - s_start + 1) // s_step + 1
 * 
 *                 shape.push_back(dim)             # <<<<<<<<<<<<<<
 *                 strides.push_back(self._strides[j] * s_step)
 * 
 */
      try {
        __pyx_v_shape.push_back(__pyx_v_dim);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(1, 1147, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":1148
 * 
 *                 shape.push_back(dim)
 *                 strides.push_back(self._strides[j] * s_step)             # <<<<<<<<<<<<<<
 * 
 *                 offset += s_start * self._strides[j]
 */
      try {
        __pyx_v_strides.push_back(((__pyx_v_self->_strides[__pyx_v_j]) * __pyx_v_s_step));
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(1, 1148, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":1150
 *                 strides.push_back(self._strides[j] * s_step)
 * 
 *                 offset += s_start * self._strides[j]             # <<<<<<<<<<<<<<
 *                 j += 1
 *             elif numpy.isscalar(s):
 */
      __pyx_v_offset = (__pyx_v_offset + (__pyx_v_s_start * (__pyx_v_self->_strides[__pyx_v_j])));

      /* "cupy/core/core.pyx":1151
 * 
 *                 offset += s_start * self._strides[j]
 *                 j += 1             # <<<<<<<<<<<<<<
 *             elif numpy.isscalar(s):
 *                 ind = int(s)
 */
      __pyx_v_j = (__pyx_v_j + 1);

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

    /* "cupy/core/core.pyx":1152
 *                 offset += s_start * self._strides[j]
 *                 j += 1
 *             elif numpy.isscalar(s):             # <<<<<<<<<<<<<<
 *                 ind = int(s)
 *                 if ind < 0:
 */
    __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 1152, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_isscalar); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1152, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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);
      }
    }
    if (!__pyx_t_12) {
      __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_s); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
    } else {
      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1152, __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_s);
      __Pyx_GIVEREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_s);
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 1152, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1153
 *                 j += 1
 *             elif numpy.isscalar(s):
 *                 ind = int(s)             # <<<<<<<<<<<<<<
 *                 if ind < 0:
 *                     ind += self._shape[j]
 */
      __pyx_t_8 = __Pyx_PyNumber_Int(__pyx_v_s); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1153, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1153, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_v_ind = __pyx_t_15;

      /* "cupy/core/core.pyx":1154
 *             elif numpy.isscalar(s):
 *                 ind = int(s)
 *                 if ind < 0:             # <<<<<<<<<<<<<<
 *                     ind += self._shape[j]
 *                 if not (0 <= ind < self._shape[j]):
 */
      __pyx_t_1 = ((__pyx_v_ind < 0) != 0);
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":1155
 *                 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":1154
 *             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":1156
 *                 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_1 = (0 <= __pyx_v_ind);
      if (__pyx_t_1) {
        __pyx_t_1 = (__pyx_v_ind < (__pyx_v_self->_shape[__pyx_v_j]));
      }
      __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1158
 *                 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)
 *                 offset += ind * self._strides[j]
 */
        __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_j); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1158, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_self->_shape[__pyx_v_j])); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1158, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1158, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_v_s);
        __Pyx_GIVEREF(__pyx_v_s);
        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_s);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_3);
        __pyx_t_8 = 0;
        __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Index_s_is_out_of_bounds_for_axi, __pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1158, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_v_msg = ((PyObject*)__pyx_t_3);
        __pyx_t_3 = 0;

        /* "cupy/core/core.pyx":1159
 *                     msg = ('Index %s is out of bounds for axis %s with '
 *                            'size %s' % (s, j, self._shape[j]))
 *                     raise IndexError(msg)             # <<<<<<<<<<<<<<
 *                 offset += ind * self._strides[j]
 *                 j += 1
 */
        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1159, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_v_msg);
        __Pyx_GIVEREF(__pyx_v_msg);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_msg);
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1159, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_Raise(__pyx_t_9, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __PYX_ERR(1, 1159, __pyx_L1_error)

        /* "cupy/core/core.pyx":1156
 *                 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":1160
 *                            'size %s' % (s, j, self._shape[j]))
 *                     raise IndexError(msg)
 *                 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":1161
 *                     raise IndexError(msg)
 *                 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":1152
 *                 offset += s_start * self._strides[j]
 *                 j += 1
 *             elif numpy.isscalar(s):             # <<<<<<<<<<<<<<
 *                 ind = int(s)
 *                 if ind < 0:
 */
      goto __pyx_L37;
    }

    /* "cupy/core/core.pyx":1163
 *                 j += 1
 *             else:
 *                 raise TypeError('Invalid index type: %s' % type(slices[i]))             # <<<<<<<<<<<<<<
 * 
 *         v = self.view()
 */
    /*else*/ {
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_slices, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1163, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_index_type_s, ((PyObject *)Py_TYPE(__pyx_t_9))); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1163, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1163, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1163, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(1, 1163, __pyx_L1_error)
    }
    __pyx_L37:;

    /* "cupy/core/core.pyx":1126
 *         j = 0
 *         offset = 0
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if s is None:
 *                 shape.push_back(1)
 */
  }
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":1165
 *                 raise TypeError('Invalid index type: %s' % type(slices[i]))
 * 
 *         v = self.view()             # <<<<<<<<<<<<<<
 *         v.data = self.data + offset
 *         v._set_shape_and_strides(shape, strides)
 */
  __pyx_t_13 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->view(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_v_v = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_13);
  __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":1166
 * 
 *         v = self.view()
 *         v.data = self.data + offset             # <<<<<<<<<<<<<<
 *         v._set_shape_and_strides(shape, strides)
 *         return v
 */
  __pyx_t_13 = PyInt_FromSsize_t(__pyx_v_offset); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_3 = PyNumber_Add(((PyObject *)__pyx_v_self->data), __pyx_t_13); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer))))) __PYX_ERR(1, 1166, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_3);
  __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_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1167
 *         v = self.view()
 *         v.data = self.data + offset
 *         v._set_shape_and_strides(shape, strides)             # <<<<<<<<<<<<<<
 *         return v
 * 
 */
  __pyx_t_3 = ((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_3)) __PYX_ERR(1, 1167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1168
 *         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":1016
 *         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_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.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_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":1170
 *         return v
 * 
 *     def __setitem__(self, slices, value):             # <<<<<<<<<<<<<<
 *         cdef ndarray v, x, y
 *         if not isinstance(slices, tuple):
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_149__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_slices, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_149__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_148__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_148__setitem__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_slices, PyObject *__pyx_v_value) {
  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;
  PyObject *__pyx_v_s = NULL;
  int __pyx_r;
  __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)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  size_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("__setitem__", 0);
  __Pyx_INCREF(__pyx_v_slices);

  /* "cupy/core/core.pyx":1172
 *     def __setitem__(self, slices, value):
 *         cdef ndarray v, x, y
 *         if not isinstance(slices, tuple):             # <<<<<<<<<<<<<<
 *             slices = (slices,)
 * 
 */
  __pyx_t_1 = PyTuple_Check(__pyx_v_slices); 
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1173
 *         cdef ndarray v, x, y
 *         if not isinstance(slices, tuple):
 *             slices = (slices,)             # <<<<<<<<<<<<<<
 * 
 *         for s in slices:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1173, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_slices);
    __Pyx_GIVEREF(__pyx_v_slices);
    PyTuple_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":1172
 *     def __setitem__(self, slices, value):
 *         cdef ndarray v, x, y
 *         if not isinstance(slices, tuple):             # <<<<<<<<<<<<<<
 *             slices = (slices,)
 * 
 */
  }

  /* "cupy/core/core.pyx":1175
 *             slices = (slices,)
 * 
 *         for s in slices:             # <<<<<<<<<<<<<<
 *             if isinstance(s, (list, numpy.ndarray, ndarray)):
 *                 raise IndexError(
 */
  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_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_slices); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1175, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1175, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 1175, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1175, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 1175, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1175, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_5(__pyx_t_3);
      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, 1175, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":1176
 * 
 *         for s in slices:
 *             if isinstance(s, (list, numpy.ndarray, ndarray)):             # <<<<<<<<<<<<<<
 *                 raise IndexError(
 *                     'Only basic indexing is supported for __setitem__')
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1176, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1176, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_1 = PyList_Check(__pyx_v_s); 
    __pyx_t_8 = (__pyx_t_1 != 0);
    if (!__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_8 = PyObject_IsInstance(__pyx_v_s, __pyx_t_7); 
    __pyx_t_1 = (__pyx_t_8 != 0);
    if (!__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_8 = (__pyx_t_1 != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L7_bool_binop_done:;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = (__pyx_t_2 != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":1177
 *         for s in slices:
 *             if isinstance(s, (list, numpy.ndarray, ndarray)):
 *                 raise IndexError(             # <<<<<<<<<<<<<<
 *                     'Only basic indexing is supported for __setitem__')
 * 
 */
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1177, __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, 1177, __pyx_L1_error)

      /* "cupy/core/core.pyx":1176
 * 
 *         for s in slices:
 *             if isinstance(s, (list, numpy.ndarray, ndarray)):             # <<<<<<<<<<<<<<
 *                 raise IndexError(
 *                     'Only basic indexing is supported for __setitem__')
 */
    }

    /* "cupy/core/core.pyx":1175
 *             slices = (slices,)
 * 
 *         for s in slices:             # <<<<<<<<<<<<<<
 *             if isinstance(s, (list, numpy.ndarray, ndarray)):
 *                 raise IndexError(
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1180
 *                     'Only basic indexing is supported for __setitem__')
 * 
 *         v = self[slices]             # <<<<<<<<<<<<<<
 *         if isinstance(value, ndarray):
 *             y, x = broadcast(v, value).values
 */
  __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_slices); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1180, __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_ndarray))))) __PYX_ERR(1, 1180, __pyx_L1_error)
  __pyx_v_v = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1181
 * 
 *         v = self[slices]
 *         if isinstance(value, ndarray):             # <<<<<<<<<<<<<<
 *             y, x = broadcast(v, value).values
 *             if (internal.vector_equal(y._shape, x._shape) and
 */
  __pyx_t_8 = __Pyx_TypeCheck(__pyx_v_value, __pyx_ptype_4cupy_4core_4core_ndarray); 
  __pyx_t_2 = (__pyx_t_8 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1182
 *         v = self[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_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1182, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_v));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_v));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_v));
    __Pyx_INCREF(__pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_value);
    __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_broadcast), __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1182, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = ((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_t_7)->values;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (likely(__pyx_t_3 != Py_None)) {
      PyObject* sequence = __pyx_t_3;
      #if CYTHON_COMPILING_IN_CPYTHON
      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, 1182, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1182, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1182, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 1182, __pyx_L1_error)
    }
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 1182, __pyx_L1_error)
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 1182, __pyx_L1_error)
    __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":1183
 *         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_8 = (__pyx_f_4cupy_4core_8internal_vector_equal(__pyx_v_y->_shape, __pyx_v_x->_shape, 0) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L12_bool_binop_done;
    }

    /* "cupy/core/core.pyx":1184
 *             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_8 = (__pyx_f_4cupy_4core_8internal_vector_equal(__pyx_v_y->_strides, __pyx_v_x->_strides, 0) != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L12_bool_binop_done:;

    /* "cupy/core/core.pyx":1183
 *         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_2) {

      /* "cupy/core/core.pyx":1185
 *             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_2 = ((__pyx_v_y->data->ptr == __pyx_v_x->data->ptr) != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1186
 *                     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(x.data, x.nbytes)
 */
        __pyx_r = 0;
        goto __pyx_L0;

        /* "cupy/core/core.pyx":1185
 *             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":1187
 *                 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(x.data, x.nbytes)
 *                     return
 */
      __pyx_t_8 = (__pyx_v_y->_c_contiguous != 0);
      if (__pyx_t_8) {
      } else {
        __pyx_t_2 = __pyx_t_8;
        goto __pyx_L15_bool_binop_done;
      }
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_x->dtype, __pyx_v_y->dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1187, __pyx_L1_error)
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 1187, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_2 = __pyx_t_8;
      __pyx_L15_bool_binop_done:;
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1188
 *                     return  # Skip since x and y are the same array
 *                 elif y._c_contiguous and x.dtype == y.dtype:
 *                     y.data.copy_from(x.data, x.nbytes)             # <<<<<<<<<<<<<<
 *                     return
 *             elementwise_copy(x, y)
 */
        __pyx_t_3 = ((PyObject *)__pyx_v_x->data);
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1188, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_t_6); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1188, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_y->data->__pyx_vtab)->copy_from(__pyx_v_y->data, __pyx_t_3, __pyx_t_9, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1188, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "cupy/core/core.pyx":1189
 *                 elif y._c_contiguous and x.dtype == y.dtype:
 *                     y.data.copy_from(x.data, x.nbytes)
 *                     return             # <<<<<<<<<<<<<<
 *             elementwise_copy(x, y)
 *         else:
 */
        __pyx_r = 0;
        goto __pyx_L0;

        /* "cupy/core/core.pyx":1187
 *                 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(x.data, x.nbytes)
 *                     return
 */
      }

      /* "cupy/core/core.pyx":1183
 *         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":1190
 *                     y.data.copy_from(x.data, x.nbytes)
 *                     return
 *             elementwise_copy(x, y)             # <<<<<<<<<<<<<<
 *         else:
 *             v.fill(value)
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1190, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = NULL;
    __pyx_t_4 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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_4 = 1;
      }
    }
    __pyx_t_10 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 1190, __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(((PyObject *)__pyx_v_x));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_x));
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_4, ((PyObject *)__pyx_v_x));
    __Pyx_INCREF(((PyObject *)__pyx_v_y));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_y));
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_4, ((PyObject *)__pyx_v_y));
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1190, __pyx_L1_error)
    __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_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":1181
 * 
 *         v = self[slices]
 *         if isinstance(value, ndarray):             # <<<<<<<<<<<<<<
 *             y, x = broadcast(v, value).values
 *             if (internal.vector_equal(y._shape, x._shape) and
 */
    goto __pyx_L10;
  }

  /* "cupy/core/core.pyx":1192
 *             elementwise_copy(x, y)
 *         else:
 *             v.fill(value)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement __getslice__
 */
  /*else*/ {
    __pyx_t_6 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_v->__pyx_vtab)->fill(__pyx_v_v, __pyx_v_value, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1192, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __pyx_L10:;

  /* "cupy/core/core.pyx":1170
 *         return v
 * 
 *     def __setitem__(self, slices, value):             # <<<<<<<<<<<<<<
 *         cdef ndarray v, x, y
 *         if not isinstance(slices, tuple):
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_v);
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_y);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_slices);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_151__int__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_151__int__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__int__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_150__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_150__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":1201
 * 
 *     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(1, 1201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1201, __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":1200
 *     # 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":1204
 * 
 *     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_153__long__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_153__long__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__long__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_152__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_152__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":1206
 *         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(1, 1206, __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(1, 1206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 1206, __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(1, 1206, __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":1204
 * 
 *     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":1208
 *             return self.get().__long__()
 * 
 *     def __float__(self):             # <<<<<<<<<<<<<<
 *         return float(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_155__float__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_155__float__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__float__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_154__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_154__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":1209
 * 
 *     def __float__(self):
 *         return float(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(1, 1209, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyNumber_Float(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1209, __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":1208
 *             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":1211
 *         return float(self.get())
 * 
 *     def __oct__(self):             # <<<<<<<<<<<<<<
 *         return oct(self.get())
 * 
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_157__oct__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_157__oct__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__oct__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_156__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)*/

#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_156__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":1212
 * 
 *     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(1, 1212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1212, __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(1, 1212, __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":1211
 *         return float(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)*/

/* "cupy/core/core.pyx":1214
 *         return oct(self.get())
 * 
 *     def __hex__(self):             # <<<<<<<<<<<<<<
 *         return hex(self.get())
 * 
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_159__hex__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_159__hex__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__hex__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_158__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)*/

#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_158__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":1215
 * 
 *     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(1, 1215, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1215, __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(1, 1215, __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":1214
 *         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)*/

/* "cupy/core/core.pyx":1219
 *     # String representations:
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return repr(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_161__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_161__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_160__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_160__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":1220
 * 
 *     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(1, 1220, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1220, __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":1219
 *     # 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":1222
 *         return repr(self.get())
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return str(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_163__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_163__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_162__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_162__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":1223
 * 
 *     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(1, 1223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1223, __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(1, 1223, __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":1222
 *         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":1228
 *     # 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_165dot(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_164dot[] = "Returns 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_165dot(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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 1228, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        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(1, 1228, __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(1, 1228, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(1, 1228, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_164dot(((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_164dot(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":1236
 * 
 *         """
 *         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(1, 1236, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1228
 *     # 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":1242
 *     # -------------------------------------------------------------------------
 *     @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":1244
 *     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":1242
 *     # -------------------------------------------------------------------------
 *     @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":1246
 *         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_167get(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_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("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(1, 1246, __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_167get)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 1246, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1246, __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(1, 1246, __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":1257
 * 
 *         """
 *         a_gpu = ascontiguousarray(self)             # <<<<<<<<<<<<<<
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 *         ptr = a_cpu.ctypes.data_as(ctypes.c_void_p)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_ascontiguousarray(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_a_gpu = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1258
 *         """
 *         a_gpu = ascontiguousarray(self)
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)             # <<<<<<<<<<<<<<
 *         ptr = a_cpu.ctypes.data_as(ctypes.c_void_p)
 *         if stream is None:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1258, __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(1, 1258, __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(1, 1258, __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(1, 1258, __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_v_a_cpu = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":1259
 *         a_gpu = ascontiguousarray(self)
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 *         ptr = a_cpu.ctypes.data_as(ctypes.c_void_p)             # <<<<<<<<<<<<<<
 *         if stream is None:
 *             a_gpu.data.copy_to_host(ptr, a_gpu.nbytes)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_ctypes); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_data_as); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_c_void_p); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1259, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1259, __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_2);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1259, __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_ptr = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":1260
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 *         ptr = a_cpu.ctypes.data_as(ctypes.c_void_p)
 *         if stream is None:             # <<<<<<<<<<<<<<
 *             a_gpu.data.copy_to_host(ptr, a_gpu.nbytes)
 *         else:
 */
  __pyx_t_6 = (__pyx_v_stream == Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":1261
 *         ptr = a_cpu.ctypes.data_as(ctypes.c_void_p)
 *         if stream is None:
 *             a_gpu.data.copy_to_host(ptr, a_gpu.nbytes)             # <<<<<<<<<<<<<<
 *         else:
 *             a_gpu.data.copy_to_host_async(ptr, a_gpu.nbytes, stream)
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a_gpu), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1261, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_8 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1261, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = ((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_8, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1261, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1260
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 *         ptr = a_cpu.ctypes.data_as(ctypes.c_void_p)
 *         if stream is None:             # <<<<<<<<<<<<<<
 *             a_gpu.data.copy_to_host(ptr, a_gpu.nbytes)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1263
 *             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*/ {
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a_gpu), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_8 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1263, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = ((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_8, __pyx_v_stream, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1264
 *         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":1246
 *         return self.data.device
 * 
 *     cpdef get(self, stream=None):             # <<<<<<<<<<<<<<
 *         """Returns a copy of the array on host memory.
 * 
 */

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_167get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_166get[] = "Returns 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\n        Returns:\n            numpy.ndarray: Copy of the array on host memory.\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_167get(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);
        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(1, 1246, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 1246, __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_166get(((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_166get(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(1, 1246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1266
 *         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_169set(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_r = NULL;
  __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 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  size_t __pyx_t_9;
  __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(1, 1266, __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_169set)) {
      __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1266, __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(1, 1266, __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":1275
 * 
 *         """
 *         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(1, 1275, __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(1, 1275, __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(1, 1275, __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":1276
 *         """
 *         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__26, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(1, 1276, __pyx_L1_error)

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

    /* "cupy/core/core.pyx":1278
 *             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(1, 1278, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);

    /* "cupy/core/core.pyx":1279
 *         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('Shape mismatch')
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1279, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1278, __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(1, 1278, __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":1278
 *             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(1, 1278, __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, 1278, __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, 1278, __pyx_L1_error)

    /* "cupy/core/core.pyx":1277
 *         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":1280
 *             raise TypeError('{} array cannot be set to {} array'.format(
 *                 arr.dtype, self.dtype))
 *         if self.shape != arr.shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Shape mismatch')
 *         if not self._c_contiguous:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1280, __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(1, 1280, __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(1, 1280, __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(1, 1280, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1281
 *                 arr.dtype, self.dtype))
 *         if self.shape != arr.shape:
 *             raise ValueError('Shape mismatch')             # <<<<<<<<<<<<<<
 *         if not self._c_contiguous:
 *             raise RuntimeError('Cannot set to non-contiguous array')
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1281, __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, 1281, __pyx_L1_error)

    /* "cupy/core/core.pyx":1280
 *             raise TypeError('{} array cannot be set to {} array'.format(
 *                 arr.dtype, self.dtype))
 *         if self.shape != arr.shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Shape mismatch')
 *         if not self._c_contiguous:
 */
  }

  /* "cupy/core/core.pyx":1282
 *         if self.shape != arr.shape:
 *             raise ValueError('Shape mismatch')
 *         if not self._c_contiguous:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('Cannot set to non-contiguous array')
 * 
 */
  __pyx_t_8 = ((!(__pyx_v_self->_c_contiguous != 0)) != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1283
 *             raise ValueError('Shape mismatch')
 *         if not self._c_contiguous:
 *             raise RuntimeError('Cannot set to non-contiguous array')             # <<<<<<<<<<<<<<
 * 
 *         arr = numpy.ascontiguousarray(arr)
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1283, __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, 1283, __pyx_L1_error)

    /* "cupy/core/core.pyx":1282
 *         if self.shape != arr.shape:
 *             raise ValueError('Shape mismatch')
 *         if not self._c_contiguous:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('Cannot set to non-contiguous array')
 * 
 */
  }

  /* "cupy/core/core.pyx":1285
 *             raise RuntimeError('Cannot set to non-contiguous array')
 * 
 *         arr = numpy.ascontiguousarray(arr)             # <<<<<<<<<<<<<<
 *         ptr = arr.ctypes.data_as(ctypes.c_void_p)
 *         if stream is None:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ascontiguousarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_arr); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1285, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1285, __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_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1285, __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_SET(__pyx_v_arr, __pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":1286
 * 
 *         arr = numpy.ascontiguousarray(arr)
 *         ptr = arr.ctypes.data_as(ctypes.c_void_p)             # <<<<<<<<<<<<<<
 *         if stream is None:
 *             self.data.copy_from_host(ptr, self.nbytes)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_ctypes); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_data_as); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_c_void_p); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1286, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1286, __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_2);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1286, __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_v_ptr = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":1287
 *         arr = numpy.ascontiguousarray(arr)
 *         ptr = arr.ctypes.data_as(ctypes.c_void_p)
 *         if stream is None:             # <<<<<<<<<<<<<<
 *             self.data.copy_from_host(ptr, self.nbytes)
 *         else:
 */
  __pyx_t_8 = (__pyx_v_stream == Py_None);
  __pyx_t_7 = (__pyx_t_8 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":1288
 *         ptr = arr.ctypes.data_as(ctypes.c_void_p)
 *         if stream is None:
 *             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(1, 1288, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1288, __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_9, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1288, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":1287
 *         arr = numpy.ascontiguousarray(arr)
 *         ptr = arr.ctypes.data_as(ctypes.c_void_p)
 *         if stream is None:             # <<<<<<<<<<<<<<
 *             self.data.copy_from_host(ptr, self.nbytes)
 *         else:
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":1290
 *             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(1, 1290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1290, __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_async(__pyx_v_self->data, __pyx_v_ptr, __pyx_t_9, __pyx_v_stream, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L7:;

  /* "cupy/core/core.pyx":1266
 *         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_AddTraceback("cupy.core.core.ndarray.set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ptr);
  __Pyx_XDECREF(__pyx_v_arr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_169set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_168set[] = "Copies 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\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_169set(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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 1266, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        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(1, 1266, __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_168set(((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_168set(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(1, 1266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1292
 *             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_171reduced_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(1, 1292, __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_171reduced_view)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 1292, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1292, __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(1, 1292, __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(1, 1292, __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":1305
 *         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":1306
 *         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":1307
 *         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":1306
 *         cdef Py_ssize_t ndim
 *         ndim = self._shape.size()
 *         if ndim <= 1:             # <<<<<<<<<<<<<<
 *             return self
 *         internal.get_reduced_dims(
 */
  }

  /* "cupy/core/core.pyx":1309
 *             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(1, 1309, __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(1, 1309, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1308
 *         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":1310
 *         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":1311
 *             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":1310
 *         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":1313
 *             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(1, 1313, __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":1314
 * 
 *         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(1, 1314, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1315
 *         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":1292
 *             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_171reduced_view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_170reduced_view[] = "Returns 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_171reduced_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);
        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(1, 1292, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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(1, 1292, __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_170reduced_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_170reduced_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(1, 1292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1317
 *         return view
 * 
 *     cpdef _update_c_contiguity(self):             # <<<<<<<<<<<<<<
 *         if self.size == 0:
 *             self._c_contiguous = True
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_173_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(1, 1317, __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_173_update_c_contiguity)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 1317, __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, 1317, __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":1318
 * 
 *     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":1319
 *     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":1320
 *         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":1318
 * 
 *     cpdef _update_c_contiguity(self):
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             self._c_contiguous = True
 *             return
 */
  }

  /* "cupy/core/core.pyx":1322
 *             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(1, 1322, __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(1, 1322, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1321
 *             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(1, 1321, __pyx_L1_error)
  __pyx_v_self->_c_contiguous = __pyx_t_5;

  /* "cupy/core/core.pyx":1317
 *         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_173_update_c_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_173_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_172_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_172_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(1, 1317, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1324
 *             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_175_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(1, 1324, __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_175_update_f_contiguity)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 1324, __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, 1324, __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":1327
 *         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":1328
 *         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":1329
 *         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":1327
 *         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":1330
 *             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":1331
 *             return
 *         if self._c_contiguous:
 *             count = 0             # <<<<<<<<<<<<<<
 *             for i in self._shape:
 *                 if i == 1:
 */
    __pyx_v_count = 0;

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

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

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

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

  /* "cupy/core/core.pyx":1340
 *         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(1, 1340, __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(1, 1340, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1339
 *         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(1, 1339, __pyx_L1_error)
  __pyx_v_self->_f_contiguous = __pyx_t_5;

  /* "cupy/core/core.pyx":1324
 *             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_175_update_f_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_175_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_174_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_174_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(1, 1324, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1342
 *             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_177_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(1, 1342, __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_177_update_contiguity)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 1342, __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, 1342, __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":1343
 * 
 *     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(1, 1343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1344
 *     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(1, 1344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1342
 *             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_177_update_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_177_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_176_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_176_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(1, 1342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1346
 *         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_179_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":1348
 *     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;
  Py_ssize_t __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":1346
 *         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(1, 1346, __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_179_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(1, 1346, __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(1, 1346, __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(1, 1346, __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1346, __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(1, 1346, __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":1349
 *                                  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":1350
 *                                  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__29, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1350, __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, 1350, __pyx_L1_error)

    /* "cupy/core/core.pyx":1349
 *                                  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":1351
 *         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":1352
 *             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":1353
 *         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":1354
 *         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":1355
 *         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(1, 1355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1354
 *         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":1357
 *             self._update_contiguity()
 *         else:
 *             self._update_f_contiguity()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*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(1, 1357, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":1346
 *         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_179_set_shape_and_strides(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_179_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);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 1346, __pyx_L3_error)
        }
        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(1, 1346, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        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(1, 1346, __pyx_L3_error)
    __pyx_v_strides = __pyx_convert_vector_from_py_Py_ssize_t(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 1347, __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(1, 1348, __pyx_L3_error)
    } else {

      /* "cupy/core/core.pyx":1348
 *     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(1, 1346, __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_178_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":1346
 *         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_178_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(1, 1346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":67
 * 
 *     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(1, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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.pyx":68
 *     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(1, 68, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_6_shape_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_6_shape_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_6_shape_2__set__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4cupy_4core_4core_7ndarray_6_shape_2__set__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  std::vector<Py_ssize_t>  __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_value); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 68, __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.pyx":69
 *         readonly Py_ssize_t size
 *         public vector.vector[Py_ssize_t] _shape
 *         public vector.vector[Py_ssize_t] _strides             # <<<<<<<<<<<<<<
 *         readonly bint _c_contiguous
 *         readonly bint _f_contiguous
 */

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_8_strides___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_strides); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 69, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_8_strides_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_8_strides_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_8_strides_2__set__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4cupy_4core_4core_7ndarray_8_strides_2__set__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  std::vector<Py_ssize_t>  __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_value); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 69, __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.pyx":70
 *         public vector.vector[Py_ssize_t] _shape
 *         public vector.vector[Py_ssize_t] _strides
 *         readonly bint _c_contiguous             # <<<<<<<<<<<<<<
 *         readonly bint _f_contiguous
 *         readonly object dtype
 */

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_13_c_contiguous___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_c_contiguous); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 70, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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.pyx":71
 *         public vector.vector[Py_ssize_t] _strides
 *         readonly bint _c_contiguous
 *         readonly bint _f_contiguous             # <<<<<<<<<<<<<<
 *         readonly object dtype
 *         readonly memory.MemoryPointer data
 */

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

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_13_f_contiguous___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_f_contiguous); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 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.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.pyx":72
 *         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.pyx":73
 *         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.pyx":74
 *         readonly object dtype
 *         readonly memory.MemoryPointer data
 *         readonly ndarray base             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, shape, dtype=float, memptr=None):
 */

/* 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":1363
 * 
 * 
 * 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":1367
 *     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":1368
 *     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":1369
 *     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":1368
 *     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":1371
 *         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(1, 1371, __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(1, 1371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_itemsize = __pyx_t_1;

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

    /* "cupy/core/core.pyx":1374
 *     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":1372
 * 
 *     itemsize = a.itemsize
 *     if size == 1:             # <<<<<<<<<<<<<<
 *         newstrides.assign(<Py_ssize_t>newshape.size(), itemsize)
 *         return newstrides
 */
  }

  /* "cupy/core/core.pyx":1377
 * 
 *     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":1379
 *     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":1380
 * 
 *     ndim = shape.size()
 *     dim = 0             # <<<<<<<<<<<<<<
 *     sh = shape[0]
 *     st = strides[0]
 */
  __pyx_v_dim = 0;

  /* "cupy/core/core.pyx":1381
 *     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":1382
 *     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":1383
 *     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":1384
 *     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":1385
 *     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":1386
 *     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(1, 1386, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":1387
 *         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":1385
 *     last_stride = shape[0] * strides[0]
 *     for size in newshape:
 *         if size <= 1:             # <<<<<<<<<<<<<<
 *             newstrides.push_back(last_stride)
 *             continue
 */
    }

    /* "cupy/core/core.pyx":1388
 *             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(1, 1388, __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":1389
 *             continue
 *         if dim >= ndim or shape[dim] % size != 0:
 *             newstrides.clear()             # <<<<<<<<<<<<<<
 *             break
 *         shape[dim] //= size
 */
      __pyx_v_newstrides.clear();

      /* "cupy/core/core.pyx":1390
 *         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":1388
 *             newstrides.push_back(last_stride)
 *             continue
 *         if dim >= ndim or shape[dim] % size != 0:             # <<<<<<<<<<<<<<
 *             newstrides.clear()
 *             break
 */
    }

    /* "cupy/core/core.pyx":1391
 *             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(1, 1391, __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(1, 1391, __pyx_L1_error)
    }
    (__pyx_v_shape[__pyx_t_1]) = __Pyx_div_Py_ssize_t(__pyx_t_6, __pyx_v_size);

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

    /* "cupy/core/core.pyx":1394
 *         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":1395
 *         newstrides.push_back(last_stride)
 *         if shape[dim] == 1:
 *             dim += 1             # <<<<<<<<<<<<<<
 *     return newstrides
 * 
 */
      __pyx_v_dim = (__pyx_v_dim + 1);

      /* "cupy/core/core.pyx":1394
 *         last_stride = shape[dim] * strides[dim]
 *         newstrides.push_back(last_stride)
 *         if shape[dim] == 1:             # <<<<<<<<<<<<<<
 *             dim += 1
 *     return newstrides
 */
    }

    /* "cupy/core/core.pyx":1384
 *     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":1396
 *         if shape[dim] == 1:
 *             dim += 1
 *     return newstrides             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_newstrides;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1363
 * 
 * 
 * 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_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 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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 1363, __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(1, 1363, __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(1, 1364, __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(1, 1363, __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(1, 1364, __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(1, 1363, __pyx_L1_error)
  __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1363, __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":19
 *         _CArray val
 * 
 *     def __init__(self, ndarray arr):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i, ndim = arr.ndim
 *         self.val.data = <void*>arr.data.ptr
 */

/* 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);
        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, 19, __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, 19, __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, 19, __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;
  Py_ssize_t __pyx_v_ndim;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/carray.pxi":20
 * 
 *     def __init__(self, ndarray arr):
 *         cdef Py_ssize_t i, ndim = arr.ndim             # <<<<<<<<<<<<<<
 *         self.val.data = <void*>arr.data.ptr
 *         self.val.size = arr.size
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_arr), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 20, __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(2, 20, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_2;

  /* "cupy/core/carray.pxi":21
 *     def __init__(self, ndarray arr):
 *         cdef Py_ssize_t i, ndim = arr.ndim
 *         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":22
 *         cdef Py_ssize_t i, ndim = arr.ndim
 *         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_2 = __pyx_v_arr->size;
  __pyx_v_self->val.size = __pyx_t_2;

  /* "cupy/core/carray.pxi":23
 *         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_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "cupy/core/carray.pxi":24
 *         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":25
 *         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":26
 *             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":19
 *         _CArray val
 * 
 *     def __init__(self, ndarray arr):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i, ndim = arr.ndim
 *         self.val.data = <void*>arr.data.ptr
 */

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

/* "cupy/core/carray.pxi":38
 *         _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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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, 38, __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, 38, __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, 38, __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, 38, __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, 38, __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;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/carray.pxi":39
 * 
 *     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":41
 *         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, 41, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(2, 41, __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":42
 *         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, 42, __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, 42, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 42, __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":43
 *         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":38
 *         _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;
}

/* "cupy/core/carray.pxi":47
 * 
 * @cython.profile(False)
 * cpdef inline CIndexer to_cindexer(Py_ssize_t size, tuple shape):             # <<<<<<<<<<<<<<
 *     return CIndexer(size, shape)
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_3to_cindexer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static CYTHON_INLINE struct __pyx_obj_4cupy_4core_4core_CIndexer *__pyx_f_4cupy_4core_4core_to_cindexer(Py_ssize_t __pyx_v_size, PyObject *__pyx_v_shape, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_CIndexer *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("to_cindexer", 0);

  /* "cupy/core/carray.pxi":48
 * @cython.profile(False)
 * cpdef inline CIndexer to_cindexer(Py_ssize_t size, tuple shape):
 *     return CIndexer(size, shape)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 48, __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_shape);
  __Pyx_GIVEREF(__pyx_v_shape);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_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, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_CIndexer *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/carray.pxi":47
 * 
 * @cython.profile(False)
 * cpdef inline CIndexer to_cindexer(Py_ssize_t size, tuple shape):             # <<<<<<<<<<<<<<
 *     return CIndexer(size, shape)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.to_cindexer", __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_3to_cindexer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_3to_cindexer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  Py_ssize_t __pyx_v_size;
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_cindexer (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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("to_cindexer", 1, 2, 2, 1); __PYX_ERR(2, 47, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "to_cindexer") < 0)) __PYX_ERR(2, 47, __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, 47, __pyx_L3_error)
    __pyx_v_shape = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("to_cindexer", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 47, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.to_cindexer", __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(2, 47, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_2to_cindexer(__pyx_self, __pyx_v_size, __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_2to_cindexer(CYTHON_UNUSED PyObject *__pyx_self, Py_ssize_t __pyx_v_size, PyObject *__pyx_v_shape) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("to_cindexer", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_to_cindexer(__pyx_v_size, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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_cindexer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/carray.pxi":56
 *         public tuple shape
 * 
 *     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);
        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, 56, __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, 56, __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, 56, __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":57
 * 
 *     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":58
 *     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, 58, __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_COMPILING_IN_CPYTHON
    __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, 58, __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, 58, __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":59
 *         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, 59, __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, 59, __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, 59, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_size = __pyx_t_5;

    /* "cupy/core/carray.pxi":58
 *     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":60
 *         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":61
 *             size *= s
 *         self.shape = shape
 *         self.size = size             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_v_self->size = __pyx_v_size;

  /* "cupy/core/carray.pxi":56
 *         public tuple shape
 * 
 *     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":64
 * 
 *     @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":65
 *     @property
 *     def ndim(self):
 *         return len(self.shape)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __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, 65, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(2, 65, __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, 65, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/carray.pxi":64
 * 
 *     @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":68
 * 
 *     @property
 *     def cstruct(self):             # <<<<<<<<<<<<<<
 *         return to_cindexer(self.size, self.shape)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_7cstruct_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_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_7Indexer_7cstruct___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_7cstruct___get__(struct __pyx_obj_4cupy_4core_4core_Indexer *__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/carray.pxi":69
 *     @property
 *     def cstruct(self):
 *         return to_cindexer(self.size, self.shape)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_v_self->shape;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core_to_cindexer(__pyx_v_self->size, ((PyObject*)__pyx_t_1), 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 69, __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/carray.pxi":68
 * 
 *     @property
 *     def cstruct(self):             # <<<<<<<<<<<<<<
 *         return to_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.cstruct.__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":53
 * cdef class Indexer:
 *     cdef:
 *         public Py_ssize_t size             # <<<<<<<<<<<<<<
 *         public 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(2, 53, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
}

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7Indexer_4size_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7Indexer_4size_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_7Indexer_4size_2__set__(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4cupy_4core_4core_7Indexer_4size_2__set__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_value); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 53, __pyx_L1_error)
  __pyx_v_self->size = __pyx_t_1;

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

/* "cupy/core/carray.pxi":54
 *     cdef:
 *         public Py_ssize_t size
 *         public tuple shape             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, tuple shape):
 */

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

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7Indexer_5shape_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7Indexer_5shape_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_7Indexer_5shape_2__set__(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4cupy_4core_4core_7Indexer_5shape_2__set__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(2, 54, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->shape);
  __Pyx_DECREF(__pyx_v_self->shape);
  __pyx_v_self->shape = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

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

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7Indexer_5shape_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7Indexer_5shape_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7Indexer_5shape_4__del__(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v_self));

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

static int __pyx_pf_4cupy_4core_4core_7Indexer_5shape_4__del__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->shape);
  __Pyx_DECREF(__pyx_v_self->shape);
  __pyx_v_self->shape = ((PyObject*)Py_None);

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

/* "cupy/core/carray.pxi":75
 * 
 * 
 * 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_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;
  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;
  Py_ssize_t __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;
  __Pyx_RefNannySetupContext("_get_header_source", 0);

  /* "cupy/core/carray.pxi":77
 * cpdef str _get_header_source():
 *     global _header_source
 *     if _header_source is None:             # <<<<<<<<<<<<<<
 *         header_path = os.path.join(os.path.dirname(__file__), 'carray.cuh')
 *         with open(header_path) as header_file:
 */
  __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":78
 *     global _header_source
 *     if _header_source is None:
 *         header_path = os.path.join(os.path.dirname(__file__), 'carray.cuh')             # <<<<<<<<<<<<<<
 *         with open(header_path) as header_file:
 *             _header_source = header_file.read()
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 78, __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, 78, __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_join); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 78, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 78, __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, 78, __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_dirname); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 78, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_file); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 78, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 78, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 78, __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_7);
      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 78, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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_10 = 1;
      }
    }
    __pyx_t_9 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 78, __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_5);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_10, __pyx_t_5);
    __Pyx_INCREF(__pyx_kp_s_carray_cuh);
    __Pyx_GIVEREF(__pyx_kp_s_carray_cuh);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_10, __pyx_kp_s_carray_cuh);
    __pyx_t_5 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 78, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_header_path = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/carray.pxi":79
 *     if _header_source is None:
 *         header_path = os.path.join(os.path.dirname(__file__), 'carray.cuh')
 *         with open(header_path) as header_file:             # <<<<<<<<<<<<<<
 *             _header_source = header_file.read()
 *     return _header_source
 */
    /*with:*/ {
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 79, __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_4 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 79, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_11 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_n_s_exit); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 79, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_n_s_enter); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 79, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (__pyx_t_5) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 79, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else {
        __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 79, __pyx_L4_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_4); __pyx_t_4 = 0;
      /*try:*/ {
        {
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_14);
          /*try:*/ {
            __pyx_v_header_file = __pyx_t_9;
            __pyx_t_9 = 0;

            /* "cupy/core/carray.pxi":80
 *         header_path = os.path.join(os.path.dirname(__file__), 'carray.cuh')
 *         with open(header_path) as header_file:
 *             _header_source = header_file.read()             # <<<<<<<<<<<<<<
 *     return _header_source
 * 
 */
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_header_file, __pyx_n_s_read); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 80, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_3 = NULL;
            if (CYTHON_COMPILING_IN_CPYTHON && 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_9 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 80, __pyx_L8_error)
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            } else {
              __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 80, __pyx_L8_error)
            }
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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, 80, __pyx_L8_error)
            __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__header_source);
            __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__header_source, ((PyObject*)__pyx_t_9));
            __Pyx_GIVEREF(__pyx_t_9);
            __pyx_t_9 = 0;

            /* "cupy/core/carray.pxi":79
 *     if _header_source is None:
 *         header_path = os.path.join(os.path.dirname(__file__), 'carray.cuh')
 *         with open(header_path) as header_file:             # <<<<<<<<<<<<<<
 *             _header_source = header_file.read()
 *     return _header_source
 */
          }
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          goto __pyx_L15_try_end;
          __pyx_L8_error:;
          __Pyx_PyThreadState_assign
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __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_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 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_4, &__pyx_t_3) < 0) __PYX_ERR(2, 79, __pyx_L10_except_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_5 = PyTuple_Pack(3, __pyx_t_9, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 79, __pyx_L10_except_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_5, NULL);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 79, __pyx_L10_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, 79, __pyx_L10_except_error)
            __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
            if (__pyx_t_1) {
              __Pyx_GIVEREF(__pyx_t_9);
              __Pyx_GIVEREF(__pyx_t_4);
              __Pyx_XGIVEREF(__pyx_t_3);
              __Pyx_ErrRestoreWithState(__pyx_t_9, __pyx_t_4, __pyx_t_3);
              __pyx_t_9 = 0; __pyx_t_4 = 0; __pyx_t_3 = 0; 
              __PYX_ERR(2, 79, __pyx_L10_except_error)
            }
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
          goto __pyx_L1_error;
          __pyx_L9_exception_handled:;
          __Pyx_PyThreadState_assign
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
          __pyx_L15_try_end:;
        }
      }
      /*finally:*/ {
        /*normal exit:*/{
          if (__pyx_t_11) {
            __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__30, NULL);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 79, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          }
          goto __pyx_L7;
        }
        __pyx_L7:;
      }
      goto __pyx_L19;
      __pyx_L4_error:;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L1_error;
      __pyx_L19:;
    }

    /* "cupy/core/carray.pxi":77
 * cpdef str _get_header_source():
 *     global _header_source
 *     if _header_source is None:             # <<<<<<<<<<<<<<
 *         header_path = os.path.join(os.path.dirname(__file__), 'carray.cuh')
 *         with open(header_path) as header_file:
 */
  }

  /* "cupy/core/carray.pxi":81
 *         with open(header_path) as header_file:
 *             _header_source = header_file.read()
 *     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":75
 * 
 * 
 * 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_5);
  __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._get_header_source", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __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 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, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":84
 * 
 * 
 * cpdef function.Module compile_with_cache(             # <<<<<<<<<<<<<<
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _get_header_source() + source
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7compile_with_cache(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_f_4cupy_4core_4core_compile_with_cache(PyObject *__pyx_v_source, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache *__pyx_optional_args) {

  /* "cupy/core/carray.pxi":85
 * 
 * cpdef function.Module compile_with_cache(
 *         str source, tuple options=(), arch=None, cachd_dir=None):             # <<<<<<<<<<<<<<
 *     source = _get_header_source() + source
 *     return cuda.compile_with_cache(source, options, arch, cachd_dir)
 */
  PyObject *__pyx_v_options = ((PyObject*)__pyx_empty_tuple);
  PyObject *__pyx_v_arch = ((PyObject *)Py_None);
  PyObject *__pyx_v_cachd_dir = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __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);

  /* "cupy/core/carray.pxi":86
 * cpdef function.Module compile_with_cache(
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _get_header_source() + source             # <<<<<<<<<<<<<<
 *     return cuda.compile_with_cache(source, options, arch, cachd_dir)
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_header_source(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_v_source); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_source, ((PyObject*)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/core/carray.pxi":87
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _get_header_source() + source
 *     return cuda.compile_with_cache(source, options, arch, cachd_dir)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_compile_with_cache); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_4 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_1) {
    __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL;
  }
  __Pyx_INCREF(__pyx_v_source);
  __Pyx_GIVEREF(__pyx_v_source);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_source);
  __Pyx_INCREF(__pyx_v_options);
  __Pyx_GIVEREF(__pyx_v_options);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_options);
  __Pyx_INCREF(__pyx_v_arch);
  __Pyx_GIVEREF(__pyx_v_arch);
  PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_arch);
  __Pyx_INCREF(__pyx_v_cachd_dir);
  __Pyx_GIVEREF(__pyx_v_cachd_dir);
  PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_v_cachd_dir);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 87, __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_4cuda_8function_Module))))) __PYX_ERR(2, 87, __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":84
 * 
 * 
 * cpdef function.Module compile_with_cache(             # <<<<<<<<<<<<<<
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _get_header_source() + source
 */

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7compile_with_cache(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7compile_with_cache(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_source = 0;
  PyObject *__pyx_v_options = 0;
  PyObject *__pyx_v_arch = 0;
  PyObject *__pyx_v_cachd_dir = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compile_with_cache (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_source,&__pyx_n_s_options,&__pyx_n_s_arch,&__pyx_n_s_cachd_dir,0};
    PyObject* values[4] = {0,0,0,0};

    /* "cupy/core/carray.pxi":85
 * 
 * cpdef function.Module compile_with_cache(
 *         str source, tuple options=(), arch=None, cachd_dir=None):             # <<<<<<<<<<<<<<
 *     source = _get_header_source() + source
 *     return cuda.compile_with_cache(source, options, arch, cachd_dir)
 */
    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);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_options);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_arch);
          if (value) { values[2] = value; kw_args--; }
        }
        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, 84, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        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, 84, __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, 85, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_options), (&PyTuple_Type), 1, "options", 1))) __PYX_ERR(2, 85, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_6compile_with_cache(__pyx_self, __pyx_v_source, __pyx_v_options, __pyx_v_arch, __pyx_v_cachd_dir);

  /* "cupy/core/carray.pxi":84
 * 
 * 
 * cpdef function.Module compile_with_cache(             # <<<<<<<<<<<<<<
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _get_header_source() + source
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_6compile_with_cache(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_source, PyObject *__pyx_v_options, PyObject *__pyx_v_arch, PyObject *__pyx_v_cachd_dir) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache __pyx_t_2;
  __Pyx_RefNannySetupContext("compile_with_cache", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.options = __pyx_v_options;
  __pyx_t_2.arch = __pyx_v_arch;
  __pyx_t_2.cachd_dir = __pyx_v_cachd_dir;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_compile_with_cache(__pyx_v_source, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":12
 * 
 * 
 * cpdef _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):
 */

static PyObject *__pyx_pw_4cupy_4core_4core_9_get_simple_elementwise_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_simple_elementwise_kernel(PyObject *__pyx_v_params, PyObject *__pyx_v_operation, PyObject *__pyx_v_name, PyObject *__pyx_v_preamble, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__get_simple_elementwise_kernel *__pyx_optional_args) {
  PyObject *__pyx_v_loop_prep = ((PyObject *)__pyx_kp_s__4);
  PyObject *__pyx_v_after_loop = ((PyObject *)__pyx_kp_s__4);

  /* "cupy/core/elementwise.pxi":14
 * 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":15
 *         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(0, 15, __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, 15, __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__31, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":25
 *       ${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(0, 25, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":26
 *     }
 *     ''').substitute(
 *         params=params,             # <<<<<<<<<<<<<<
 *         operation=operation,
 *         name=name,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_params, __pyx_v_params) < 0) __PYX_ERR(0, 26, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":27
 *     ''').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(0, 26, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":28
 *         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(0, 26, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":29
 *         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(0, 26, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":30
 *         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(0, 26, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":31
 *         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(0, 26, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":25
 *       ${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(0, 25, __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":32
 *         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(0, 32, __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(0, 32, __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(0, 32, __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":33
 *         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(0, 33, __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, 33, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":12
 * 
 * 
 * cpdef _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):
 */

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_9_get_simple_elementwise_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_9_get_simple_elementwise_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_operation = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_loop_prep = 0;
  PyObject *__pyx_v_after_loop = 0;
  PyObject *__pyx_v_options = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_simple_elementwise_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_params,&__pyx_n_s_operation,&__pyx_n_s_name,&__pyx_n_s_preamble,&__pyx_n_s_loop_prep,&__pyx_n_s_after_loop,&__pyx_n_s_options,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    values[4] = ((PyObject *)__pyx_kp_s__4);
    values[5] = ((PyObject *)__pyx_kp_s__4);

    /* "cupy/core/elementwise.pxi":14
 * 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);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(0, 12, __pyx_L3_error)
        }
        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(0, 12, __pyx_L3_error)
        }
        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(0, 12, __pyx_L3_error)
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop_prep);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_after_loop);
          if (value) { values[5] = value; kw_args--; }
        }
        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(0, 12, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        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(0, 12, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_simple_elementwise_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_8_get_simple_elementwise_kernel(__pyx_self, __pyx_v_params, __pyx_v_operation, __pyx_v_name, __pyx_v_preamble, __pyx_v_loop_prep, __pyx_v_after_loop, __pyx_v_options);

  /* "cupy/core/elementwise.pxi":12
 * 
 * 
 * cpdef _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):
 */

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

static PyObject *__pyx_pf_4cupy_4core_4core_8_get_simple_elementwise_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_params, PyObject *__pyx_v_operation, PyObject *__pyx_v_name, PyObject *__pyx_v_preamble, PyObject *__pyx_v_loop_prep, PyObject *__pyx_v_after_loop, PyObject *__pyx_v_options) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__get_simple_elementwise_kernel __pyx_t_2;
  __Pyx_RefNannySetupContext("_get_simple_elementwise_kernel", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.loop_prep = __pyx_v_loop_prep;
  __pyx_t_2.after_loop = __pyx_v_after_loop;
  __pyx_t_2.options = __pyx_v_options;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_simple_elementwise_kernel(__pyx_v_params, __pyx_v_operation, __pyx_v_name, __pyx_v_preamble, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 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._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":79
 * 
 * 
 * cpdef str _get_typename(dtype):             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         raise ValueError('dtype is None')
 */

static PyObject *__pyx_pw_4cupy_4core_4core_11_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":80
 * 
 * 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":81
 * 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__32, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 81, __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, 81, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":80
 * 
 * cpdef str _get_typename(dtype):
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('dtype is None')
 *     if dtype not in _typenames:
 */
  }

  /* "cupy/core/elementwise.pxi":82
 *     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(0, 82, __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(0, 82, __pyx_L1_error)
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/elementwise.pxi":83
 *         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(0, 83, __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, 83, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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, 83, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 83, __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, 83, __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(0, 83, __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":82
 *     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":84
 *     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(0, 84, __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(0, 84, __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(0, 84, __pyx_L1_error)
  __pyx_r = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":79
 * 
 * 
 * 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_11_get_typename(PyObject *__pyx_self, PyObject *__pyx_v_dtype); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_11_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_10_get_typename(__pyx_self, ((PyObject *)__pyx_v_dtype));

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

static PyObject *__pyx_pf_4cupy_4core_4core_10_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(0, 79, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":87
 * 
 * 
 * cpdef list _preprocess_args(args):             # <<<<<<<<<<<<<<
 *     cdef list ret = []
 *     cdef int dev_id = device.get_device_id()
 */

static PyObject *__pyx_pw_4cupy_4core_4core_13_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;
  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;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  __Pyx_RefNannySetupContext("_preprocess_args", 0);

  /* "cupy/core/elementwise.pxi":88
 * 
 * cpdef list _preprocess_args(args):
 *     cdef list ret = []             # <<<<<<<<<<<<<<
 *     cdef int dev_id = device.get_device_id()
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":89
 * cpdef list _preprocess_args(args):
 *     cdef list ret = []
 *     cdef int dev_id = device.get_device_id()             # <<<<<<<<<<<<<<
 * 
 *     for arg in args:
 */
  __pyx_t_2 = __pyx_f_4cupy_4cuda_6device_get_device_id(0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 89, __pyx_L1_error)
  __pyx_v_dev_id = __pyx_t_2;

  /* "cupy/core/elementwise.pxi":91
 *     cdef int dev_id = device.get_device_id()
 * 
 *     for arg in args:             # <<<<<<<<<<<<<<
 *         if type(arg) in _python_scalar_type_set:
 *             arg = _python_type_to_numpy_type[type(arg)](arg)
 */
  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(0, 91, __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(0, 91, __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_COMPILING_IN_CPYTHON
        __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(0, 91, __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(0, 91, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(0, 91, __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(0, 91, __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(0, 91, __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":92
 * 
 *     for arg in args:
 *         if type(arg) in _python_scalar_type_set:             # <<<<<<<<<<<<<<
 *             arg = _python_type_to_numpy_type[type(arg)](arg)
 *         elif type(arg) in _numpy_scalar_type_set:
 */
    __pyx_t_6 = (__Pyx_PySequence_ContainsTF(((PyObject *)Py_TYPE(__pyx_v_arg)), __pyx_v_4cupy_4core_4core__python_scalar_type_set, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 92, __pyx_L1_error)
    __pyx_t_7 = (__pyx_t_6 != 0);
    if (__pyx_t_7) {

      /* "cupy/core/elementwise.pxi":93
 *     for arg in args:
 *         if type(arg) in _python_scalar_type_set:
 *             arg = _python_type_to_numpy_type[type(arg)](arg)             # <<<<<<<<<<<<<<
 *         elif type(arg) in _numpy_scalar_type_set:
 *             pass
 */
      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(0, 93, __pyx_L1_error)
      }
      __pyx_t_8 = __Pyx_PyDict_GetItem(__pyx_v_4cupy_4core_4core__python_type_to_numpy_type, ((PyObject *)Py_TYPE(__pyx_v_arg))); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 93, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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);
        }
      }
      if (!__pyx_t_9) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_arg); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 93, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
      } else {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 93, __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_arg);
        __Pyx_GIVEREF(__pyx_v_arg);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_arg);
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 93, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF_SET(__pyx_v_arg, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "cupy/core/elementwise.pxi":92
 * 
 *     for arg in args:
 *         if type(arg) in _python_scalar_type_set:             # <<<<<<<<<<<<<<
 *             arg = _python_type_to_numpy_type[type(arg)](arg)
 *         elif type(arg) in _numpy_scalar_type_set:
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":94
 *         if type(arg) in _python_scalar_type_set:
 *             arg = _python_type_to_numpy_type[type(arg)](arg)
 *         elif type(arg) in _numpy_scalar_type_set:             # <<<<<<<<<<<<<<
 *             pass
 *         elif isinstance(arg, ndarray):
 */
    __pyx_t_7 = (__Pyx_PySequence_ContainsTF(((PyObject *)Py_TYPE(__pyx_v_arg)), __pyx_v_4cupy_4core_4core__numpy_scalar_type_set, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 94, __pyx_L1_error)
    __pyx_t_6 = (__pyx_t_7 != 0);
    if (__pyx_t_6) {
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":96
 *         elif type(arg) in _numpy_scalar_type_set:
 *             pass
 *         elif isinstance(arg, ndarray):             # <<<<<<<<<<<<<<
 *             arr_dev = (<ndarray?>arg).data.device
 *             if arr_dev is not None and arr_dev.id != dev_id:
 */
    __pyx_t_6 = __Pyx_TypeCheck(__pyx_v_arg, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_7 = (__pyx_t_6 != 0);
    if (__pyx_t_7) {

      /* "cupy/core/elementwise.pxi":97
 *             pass
 *         elif isinstance(arg, 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(0, 97, __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":98
 *         elif isinstance(arg, 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_11 = (__pyx_t_6 != 0);
      if (__pyx_t_11) {
      } else {
        __pyx_t_7 = __pyx_t_11;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_11 = ((__pyx_v_arr_dev->id != __pyx_v_dev_id) != 0);
      __pyx_t_7 = __pyx_t_11;
      __pyx_L7_bool_binop_done:;
      if (__pyx_t_7) {

        /* "cupy/core/elementwise.pxi":102
 *                     'Array device must be same as the current '
 *                     'device: array device = %d while current = %d'
 *                     % (arr_dev.id, dev_id))             # <<<<<<<<<<<<<<
 *         elif isinstance(arg, _python_scalar_type + _numpy_scalar_type):
 *             arg = numpy.dtype(type(arg)).type(arg)
 */
        __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_arr_dev->id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 102, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_dev_id); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 102, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 102, __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_8);
        PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_8);
        __pyx_t_5 = 0;
        __pyx_t_8 = 0;
        __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_Array_device_must_be_same_as_the, __pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 102, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

        /* "cupy/core/elementwise.pxi":99
 *             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(0, 99, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8);
        __pyx_t_8 = 0;
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 99, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_Raise(__pyx_t_8, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __PYX_ERR(0, 99, __pyx_L1_error)

        /* "cupy/core/elementwise.pxi":98
 *         elif isinstance(arg, 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":96
 *         elif type(arg) in _numpy_scalar_type_set:
 *             pass
 *         elif isinstance(arg, 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":103
 *                     'device: array device = %d while current = %d'
 *                     % (arr_dev.id, dev_id))
 *         elif isinstance(arg, _python_scalar_type + _numpy_scalar_type):             # <<<<<<<<<<<<<<
 *             arg = numpy.dtype(type(arg)).type(arg)
 *             assert arg in _numpy_scalar_type
 */
    __pyx_t_8 = PyNumber_Add(__pyx_v_4cupy_4core_4core__python_scalar_type, __pyx_v_4cupy_4core_4core__numpy_scalar_type); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 103, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = PyObject_IsInstance(__pyx_v_arg, __pyx_t_8); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 103, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_11 = (__pyx_t_7 != 0);
    if (__pyx_t_11) {

      /* "cupy/core/elementwise.pxi":104
 *                     % (arr_dev.id, dev_id))
 *         elif isinstance(arg, _python_scalar_type + _numpy_scalar_type):
 *             arg = numpy.dtype(type(arg)).type(arg)             # <<<<<<<<<<<<<<
 *             assert arg in _numpy_scalar_type
 *         else:
 */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_9, ((PyObject *)Py_TYPE(__pyx_v_arg))); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 104, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
      } else {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 104, __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(((PyObject *)Py_TYPE(__pyx_v_arg)));
        __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_arg)));
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, ((PyObject *)Py_TYPE(__pyx_v_arg)));
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 104, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_arg); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 104, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 104, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_INCREF(__pyx_v_arg);
        __Pyx_GIVEREF(__pyx_v_arg);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_v_arg);
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 104, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF_SET(__pyx_v_arg, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "cupy/core/elementwise.pxi":105
 *         elif isinstance(arg, _python_scalar_type + _numpy_scalar_type):
 *             arg = numpy.dtype(type(arg)).type(arg)
 *             assert arg in _numpy_scalar_type             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError('Unsupported type %s' % type(arg))
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        __pyx_t_11 = (__Pyx_PySequence_ContainsTF(__pyx_v_arg, __pyx_v_4cupy_4core_4core__numpy_scalar_type, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 105, __pyx_L1_error)
        if (unlikely(!(__pyx_t_11 != 0))) {
          PyErr_SetNone(PyExc_AssertionError);
          __PYX_ERR(0, 105, __pyx_L1_error)
        }
      }
      #endif

      /* "cupy/core/elementwise.pxi":103
 *                     'device: array device = %d while current = %d'
 *                     % (arr_dev.id, dev_id))
 *         elif isinstance(arg, _python_scalar_type + _numpy_scalar_type):             # <<<<<<<<<<<<<<
 *             arg = numpy.dtype(type(arg)).type(arg)
 *             assert arg in _numpy_scalar_type
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":107
 *             assert arg in _numpy_scalar_type
 *         else:
 *             raise TypeError('Unsupported type %s' % type(arg))             # <<<<<<<<<<<<<<
 *         ret.append(arg)
 *     return ret
 */
    /*else*/ {
      __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_Unsupported_type_s, ((PyObject *)Py_TYPE(__pyx_v_arg))); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 107, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 107, __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 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 107, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(0, 107, __pyx_L1_error)
    }
    __pyx_L5:;

    /* "cupy/core/elementwise.pxi":108
 *         else:
 *             raise TypeError('Unsupported type %s' % type(arg))
 *         ret.append(arg)             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
    __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_arg); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 108, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":91
 *     cdef int dev_id = device.get_device_id()
 * 
 *     for arg in args:             # <<<<<<<<<<<<<<
 *         if type(arg) in _python_scalar_type_set:
 *             arg = _python_type_to_numpy_type[type(arg)](arg)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":109
 *             raise TypeError('Unsupported type %s' % type(arg))
 *         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":87
 * 
 * 
 * cpdef list _preprocess_args(args):             # <<<<<<<<<<<<<<
 *     cdef list ret = []
 *     cdef int dev_id = device.get_device_id()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core._preprocess_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ret);
  __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_13_preprocess_args(PyObject *__pyx_self, PyObject *__pyx_v_args); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_13_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_12_preprocess_args(__pyx_self, ((PyObject *)__pyx_v_args));

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

static PyObject *__pyx_pf_4cupy_4core_4core_12_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(0, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":112
 * 
 * 
 * cpdef tuple _get_args_info(list args):             # <<<<<<<<<<<<<<
 *     ret = []
 *     for a in args:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_15_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;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("_get_args_info", 0);

  /* "cupy/core/elementwise.pxi":113
 * 
 * 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(0, 113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":114
 * cpdef tuple _get_args_info(list args):
 *     ret = []
 *     for a in args:             # <<<<<<<<<<<<<<
 *         t = type(a)
 *         if t == Indexer:
 */
  if (unlikely(__pyx_v_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 114, __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_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 114, __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, 114, __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":115
 *     ret = []
 *     for a in args:
 *         t = type(a)             # <<<<<<<<<<<<<<
 *         if t == 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":116
 *     for a in args:
 *         t = type(a)
 *         if t == Indexer:             # <<<<<<<<<<<<<<
 *             dtype = None
 *         else:
 */
    __pyx_t_3 = PyObject_RichCompare(((PyObject *)__pyx_v_t), ((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 116, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 116, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_4) {

      /* "cupy/core/elementwise.pxi":117
 *         t = type(a)
 *         if t == Indexer:
 *             dtype = None             # <<<<<<<<<<<<<<
 *         else:
 *             dtype = a.dtype.type
 */
      __Pyx_INCREF(Py_None);
      __Pyx_XDECREF_SET(__pyx_v_dtype, Py_None);

      /* "cupy/core/elementwise.pxi":116
 *     for a in args:
 *         t = type(a)
 *         if t == Indexer:             # <<<<<<<<<<<<<<
 *             dtype = None
 *         else:
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":119
 *             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(0, 119, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_type); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 119, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_dtype, __pyx_t_5);
      __pyx_t_5 = 0;
    }
    __pyx_L5:;

    /* "cupy/core/elementwise.pxi":120
 *         else:
 *             dtype = a.dtype.type
 *         ret.append((t, dtype, a.ndim))             # <<<<<<<<<<<<<<
 *     return tuple(ret)
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_ndim); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 120, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 120, __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_5);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_t_3); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 120, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":114
 * cpdef tuple _get_args_info(list args):
 *     ret = []
 *     for a in args:             # <<<<<<<<<<<<<<
 *         t = type(a)
 *         if t == Indexer:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":121
 *             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(0, 121, __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":112
 * 
 * 
 * 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_5);
  __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_15_get_args_info(PyObject *__pyx_self, PyObject *__pyx_v_args); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_15_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(0, 112, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_14_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_14_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(0, 112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._get_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":124
 * 
 * 
 * cpdef str _get_kernel_params(tuple params, tuple args_info):             # <<<<<<<<<<<<<<
 *     cdef ParameterInfo p
 *     ret = []
 */

static PyObject *__pyx_pw_4cupy_4core_4core_17_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":126
 * 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(0, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":127
 *     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(0, 127, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v_params); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 127, __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":128
 *     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(0, 128, __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(0, 128, __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(0, 128, __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":129
 *     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(0, 129, __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(0, 129, __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_CPYTHON
      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, 129, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __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(0, 129, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 129, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 129, __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":130
 *         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(0, 130, __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":131
 *         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":132
 *         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(0, 132, __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":131
 *         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":134
 *             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(0, 134, __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":135
 *         else:
 *             t = _get_typename(dtype)
 *             if is_array:             # <<<<<<<<<<<<<<
 *                 t = 'CArray<%s, %d>' % (t, ndim)
 *         ret.append('%s%s %s%s' % ('const ' if p.is_const else '',
 */
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_is_array); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 135, __pyx_L1_error)
      if (__pyx_t_8) {

        /* "cupy/core/elementwise.pxi":136
 *             t = _get_typename(dtype)
 *             if is_array:
 *                 t = 'CArray<%s, %d>' % (t, ndim)             # <<<<<<<<<<<<<<
 *         ret.append('%s%s %s%s' % ('const ' if p.is_const else '',
 *                                   t,
 */
        __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 136, __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(0, 136, __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":135
 *         else:
 *             t = _get_typename(dtype)
 *             if is_array:             # <<<<<<<<<<<<<<
 *                 t = 'CArray<%s, %d>' % (t, ndim)
 *         ret.append('%s%s %s%s' % ('const ' if p.is_const else '',
 */
      }
    }
    __pyx_L5:;

    /* "cupy/core/elementwise.pxi":137
 *             if is_array:
 *                 t = 'CArray<%s, %d>' % (t, ndim)
 *         ret.append('%s%s %s%s' % ('const ' if p.is_const else '',             # <<<<<<<<<<<<<<
 *                                   t,
 *                                   '_raw_' if is_array and not p.raw else '',
 */
    if ((__pyx_v_p->is_const != 0)) {
      __Pyx_INCREF(__pyx_kp_s_const);
      __pyx_t_6 = __pyx_kp_s_const;
    } else {
      __Pyx_INCREF(__pyx_kp_s__4);
      __pyx_t_6 = __pyx_kp_s__4;
    }

    /* "cupy/core/elementwise.pxi":139
 *         ret.append('%s%s %s%s' % ('const ' if p.is_const else '',
 *                                   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(0, 139, __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_4 = __pyx_n_s_raw;
    } else {
      __Pyx_INCREF(__pyx_kp_s__4);
      __pyx_t_4 = __pyx_kp_s__4;
    }

    /* "cupy/core/elementwise.pxi":137
 *             if is_array:
 *                 t = 'CArray<%s, %d>' % (t, ndim)
 *         ret.append('%s%s %s%s' % ('const ' if p.is_const else '',             # <<<<<<<<<<<<<<
 *                                   t,
 *                                   '_raw_' if is_array and not p.raw else '',
 */
    __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 137, __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_t);
    __Pyx_GIVEREF(__pyx_v_t);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_t);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
    __Pyx_INCREF(__pyx_v_p->name);
    __Pyx_GIVEREF(__pyx_v_p->name);
    PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_p->name);
    __pyx_t_6 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_s_s_s, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 137, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_t_4); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 137, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }

  /* "cupy/core/elementwise.pxi":141
 *                                   '_raw_' if is_array and not p.raw else '',
 *                                   p.name))
 *     return ', '.join(ret)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_PyString_Join(__pyx_kp_s__33, __pyx_v_ret); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 141, __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(0, 141, __pyx_L1_error)
  __pyx_r = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":124
 * 
 * 
 * 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_17_get_kernel_params(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17_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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(0, 124, __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(0, 124, __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(0, 124, __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(0, 124, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args_info), (&PyTuple_Type), 1, "args_info", 1))) __PYX_ERR(0, 124, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_16_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_16_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(0, 124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":144
 * 
 * 
 * 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_19_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":153
 *     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(0, 153, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 153, __pyx_L1_error)
  __pyx_v_ndim = __pyx_t_1;

  /* "cupy/core/elementwise.pxi":154
 * 
 *     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":155
 *     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(0, 155, __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":154
 * 
 *     ndim = len(shape)
 *     if ndim <= 1:             # <<<<<<<<<<<<<<
 *         return args, shape
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":157
 *         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(0, 157, __pyx_L1_error)
  }
  __pyx_t_1 = PyList_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 157, __pyx_L1_error)
  __pyx_v_n = __pyx_t_1;

  /* "cupy/core/elementwise.pxi":158
 * 
 *     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":159
 *     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(0, 159, __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(0, 159, __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(0, 159, __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":160
 *     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(0, 160, __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(0, 160, __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":161
 *         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":162
 *         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(0, 162, __pyx_L1_error)
    }

    /* "cupy/core/elementwise.pxi":163
 *         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":164
 *         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(0, 164, __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":165
 *         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(0, 165, __pyx_L1_error)
      }

      /* "cupy/core/elementwise.pxi":163
 *         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":167
 *             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(0, 167, __pyx_L1_error)
  __pyx_v_vecshape = __pyx_t_7;

  /* "cupy/core/elementwise.pxi":168
 * 
 *     vecshape = shape
 *     axis = -1             # <<<<<<<<<<<<<<
 *     cnt = 0
 *     for i in range(1, ndim):
 */
  __pyx_v_axis = -1L;

  /* "cupy/core/elementwise.pxi":169
 *     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":170
 *     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":171
 *     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":172
 *     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":171
 *     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":173
 *         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":174
 *             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":175
 *         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":176
 *             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":177
 *                 cnt += 1
 *                 axis = i - 1
 *                 break             # <<<<<<<<<<<<<<
 *         else:
 *             vecshape[i] *= vecshape[i - 1]
 */
        goto __pyx_L13_break;

        /* "cupy/core/elementwise.pxi":174
 *             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":179
 *                 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":180
 *         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":181
 *             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":182
 *             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":183
 *     if vecshape[ndim - 1] != 1:
 *         cnt += 1
 *         axis = ndim - 1             # <<<<<<<<<<<<<<
 * 
 *     if cnt == ndim:
 */
    __pyx_v_axis = (__pyx_v_ndim - 1);

    /* "cupy/core/elementwise.pxi":181
 *             vecshape[i] *= vecshape[i - 1]
 *             vecshape[i - 1] = 1
 *     if vecshape[ndim - 1] != 1:             # <<<<<<<<<<<<<<
 *         cnt += 1
 *         axis = ndim - 1
 */
  }

  /* "cupy/core/elementwise.pxi":185
 *         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":186
 * 
 *     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(0, 186, __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":185
 *         axis = ndim - 1
 * 
 *     if cnt == ndim:             # <<<<<<<<<<<<<<
 *         return args, shape
 *     if cnt == 1:
 */
  }

  /* "cupy/core/elementwise.pxi":187
 *     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":188
 *         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(0, 188, __pyx_L1_error)
    }

    /* "cupy/core/elementwise.pxi":189
 *     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(0, 189, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_ret = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":190
 *         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_COMPILING_IN_CPYTHON
      __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(0, 190, __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(0, 190, __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":191
 *         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":192
 *         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(0, 192, __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":193
 *             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(0, 193, __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":194
 *                 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(0, 194, __pyx_L1_error)
        }

        /* "cupy/core/elementwise.pxi":196
 *                 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(0, 196, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

        /* "cupy/core/elementwise.pxi":197
 *                     <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":191
 *         ret = []
 *         for i, a in enumerate(args):
 *             if is_array_flags[i]:             # <<<<<<<<<<<<<<
 *                 arr = a
 *                 arr = arr.view()
 */
      }

      /* "cupy/core/elementwise.pxi":198
 *                 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(0, 198, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":190
 *         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":199
 *                 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(0, 199, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 199, __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(0, 199, __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":187
 *     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":201
 *         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":202
 * 
 *     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":203
 *     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(0, 203, __pyx_L1_error)
      }

      /* "cupy/core/elementwise.pxi":202
 * 
 *     for i in range(ndim):
 *         if vecshape[i] != 1:             # <<<<<<<<<<<<<<
 *             newshape.push_back(vecshape[i])
 *     ret = []
 */
    }
  }

  /* "cupy/core/elementwise.pxi":204
 *         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(0, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ret = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":205
 *             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_COMPILING_IN_CPYTHON
    __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(0, 205, __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(0, 205, __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":206
 *     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":207
 *     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(0, 207, __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":208
 *         if is_array_flags[i]:
 *             arr = a
 *             arr = arr.view()             # <<<<<<<<<<<<<<
 *             newstrides.clear()
 *             for i 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(0, 208, __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":209
 *             arr = a
 *             arr = arr.view()
 *             newstrides.clear()             # <<<<<<<<<<<<<<
 *             for i in range(ndim):
 *                 if vecshape[i] != 1:
 */
      __pyx_v_newstrides.clear();

      /* "cupy/core/elementwise.pxi":210
 *             arr = arr.view()
 *             newstrides.clear()
 *             for i in range(ndim):             # <<<<<<<<<<<<<<
 *                 if vecshape[i] != 1:
 *                     newstrides.push_back(arr._strides[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/elementwise.pxi":211
 *             newstrides.clear()
 *             for i in range(ndim):
 *                 if vecshape[i] != 1:             # <<<<<<<<<<<<<<
 *                     newstrides.push_back(arr._strides[i])
 *             arr._set_shape_and_strides(newshape, newstrides, False)
 */
        __pyx_t_2 = (((__pyx_v_vecshape[__pyx_v_i]) != 1) != 0);
        if (__pyx_t_2) {

          /* "cupy/core/elementwise.pxi":212
 *             for i in range(ndim):
 *                 if vecshape[i] != 1:
 *                     newstrides.push_back(arr._strides[i])             # <<<<<<<<<<<<<<
 *             arr._set_shape_and_strides(newshape, newstrides, False)
 *             a = arr
 */
          try {
            __pyx_v_newstrides.push_back((__pyx_v_arr->_strides[__pyx_v_i]));
          } catch(...) {
            __Pyx_CppExn2PyErr();
            __PYX_ERR(0, 212, __pyx_L1_error)
          }

          /* "cupy/core/elementwise.pxi":211
 *             newstrides.clear()
 *             for i in range(ndim):
 *                 if vecshape[i] != 1:             # <<<<<<<<<<<<<<
 *                     newstrides.push_back(arr._strides[i])
 *             arr._set_shape_and_strides(newshape, newstrides, False)
 */
        }
      }

      /* "cupy/core/elementwise.pxi":213
 *                 if vecshape[i] != 1:
 *                     newstrides.push_back(arr._strides[i])
 *             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(0, 213, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

      /* "cupy/core/elementwise.pxi":214
 *                     newstrides.push_back(arr._strides[i])
 *             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":206
 *     ret = []
 *     for i, a in enumerate(args):
 *         if is_array_flags[i]:             # <<<<<<<<<<<<<<
 *             arr = a
 *             arr = arr.view()
 */
    }

    /* "cupy/core/elementwise.pxi":215
 *             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(0, 215, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":205
 *             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":216
 *             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(0, 216, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_10 = PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 216, __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(0, 216, __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":144
 * 
 * 
 * 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_19_reduce_dims(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_19_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);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(0, 144, __pyx_L3_error)
        }
        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(0, 144, __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(0, 144, __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(0, 144, __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(0, 144, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_params), (&PyTuple_Type), 1, "params", 1))) __PYX_ERR(0, 144, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(0, 144, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_18_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_18_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(0, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":227
 *         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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(0, 227, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 227, __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(0, 227, __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(0, 227, __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(0, 227, __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":228
 * 
 *     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":229
 *     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":230
 *         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":231
 *         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":232
 *         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":233
 *         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(0, 233, __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(0, 233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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, 233, __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, 233, __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(0, 233, __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, 233, __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_COMPILING_IN_CPYTHON
        __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(0, 233, __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(0, 233, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(0, 233, __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(0, 233, __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(0, 233, __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(0, 233, __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(0, 233, __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(0, 233, __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":234
 *         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(0, 234, __pyx_L1_error)
  __pyx_t_8 = ((__pyx_t_5 < 2) != 0);
  if (__pyx_t_8) {

    /* "cupy/core/elementwise.pxi":235
 *         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(0, 235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 235, __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(__pyx_builtin_Exception, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 235, __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, 235, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":234
 *         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":237
 *             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(0, 237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (1) {
    PyObject* sequence = __pyx_t_3;
    #if CYTHON_COMPILING_IN_CPYTHON
    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, 237, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __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(0, 237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 237, __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(0, 237, __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":238
 * 
 *         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(0, 238, __pyx_L1_error)
  if (__pyx_t_8) {
    goto __pyx_L7;
  }

  /* "cupy/core/elementwise.pxi":240
 *         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(0, 240, __pyx_L1_error)
  __pyx_t_8 = ((__pyx_t_5 == 1) != 0);
  if (__pyx_t_8) {

    /* "cupy/core/elementwise.pxi":241
 *             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(0, 241, __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":240
 *         if t == 'CIndexer':
 *             pass
 *         elif len(t) == 1:             # <<<<<<<<<<<<<<
 *             self.ctype = t
 *         else:
 */
    goto __pyx_L7;
  }

  /* "cupy/core/elementwise.pxi":243
 *             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(0, 243, __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(0, 243, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(0, 243, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 243, __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(0, 243, __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":244
 *         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(0, 244, __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":245
 *             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(0, 245, __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(0, 245, __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(0, 245, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_8) {

      /* "cupy/core/elementwise.pxi":246
 *             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(0, 246, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 246, __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(0, 246, __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, 246, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":245
 *             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":247
 *             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(0, 247, __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":249
 *             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(0, 249, __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_COMPILING_IN_CPYTHON
    __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(0, 249, __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(0, 249, __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":250
 * 
 *         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(0, 250, __pyx_L1_error)
    if (__pyx_t_8) {

      /* "cupy/core/elementwise.pxi":251
 *         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":250
 * 
 *         for i in s[:-2]:
 *             if i == 'raw':             # <<<<<<<<<<<<<<
 *                 self.raw = True
 *             else:
 */
      goto __pyx_L11;
    }

    /* "cupy/core/elementwise.pxi":253
 *                 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(0, 253, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 253, __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_Exception, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 253, __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, 253, __pyx_L1_error)
    }
    __pyx_L11:;

    /* "cupy/core/elementwise.pxi":249
 *             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":227
 *         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":221
 * 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":222
 *     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":223
 *         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":224
 *         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(0, 224, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":225
 *         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(0, 225, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
}

/* "cupy/core/elementwise.pxi":257
 * 
 * @util.memoize()
 * def _get_param_info(s, is_const):             # <<<<<<<<<<<<<<
 *     if len(s) == 0:
 *         return ()
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_21_get_param_info(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4cupy_4core_4core_21_get_param_info = {"_get_param_info", (PyCFunction)__pyx_pw_4cupy_4core_4core_21_get_param_info, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4cupy_4core_4core_21_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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(0, 257, __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(0, 257, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_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(0, 257, __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_20_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_20_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":258
 * @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(0, 258, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_1 == 0) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":259
 * 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":258
 * @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":260
 *     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(0, 260, __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(0, 260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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(0, 260, __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(0, 260, __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(0, 260, __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__35, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 260, __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(0, 260, __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, 260, __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_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 260, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 260, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(0, 260, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 260, __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(0, 260, __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(0, 260, __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(0, 260, __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(0, 260, __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(0, 260, __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":257
 * 
 * @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":264
 * 
 * @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_23_decide_params_type(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4cupy_4core_4core_23_decide_params_type = {"_decide_params_type", (PyCFunction)__pyx_pw_4cupy_4core_4core_23_decide_params_type, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4cupy_4core_4core_23_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);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(0, 264, __pyx_L3_error)
        }
        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(0, 264, __pyx_L3_error)
        }
        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(0, 264, __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(0, 264, __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(0, 264, __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_22_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_22_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 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  int __pyx_t_11;
  int __pyx_t_12;
  __Pyx_RefNannySetupContext("_decide_params_type", 0);

  /* "cupy/core/elementwise.pxi":265
 * @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(0, 265, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_type_dict = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":266
 * 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 six.moves.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(0, 266, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":267
 *     type_dict = {}
 *     if out_args_dtype:
 *         assert len(out_params) == len(out_args_dtype)             # <<<<<<<<<<<<<<
 *         for p, a in six.moves.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(0, 267, __pyx_L1_error)
      __pyx_t_4 = PyObject_Length(__pyx_v_out_args_dtype); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 267, __pyx_L1_error)
      if (unlikely(!((__pyx_t_3 == __pyx_t_4) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        __PYX_ERR(0, 267, __pyx_L1_error)
      }
    }
    #endif

    /* "cupy/core/elementwise.pxi":268
 *     if out_args_dtype:
 *         assert len(out_params) == len(out_args_dtype)
 *         for p, a in six.moves.zip(out_params, out_args_dtype):             # <<<<<<<<<<<<<<
 *             if a is None:
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_moves); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zip); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    __pyx_t_4 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_4 = 1;
      }
    }
    __pyx_t_7 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_INCREF(__pyx_v_out_params);
    __Pyx_GIVEREF(__pyx_v_out_params);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_4, __pyx_v_out_params);
    __Pyx_INCREF(__pyx_v_out_args_dtype);
    __Pyx_GIVEREF(__pyx_v_out_args_dtype);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_4, __pyx_v_out_args_dtype);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 268, __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;
    if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_5 = __pyx_t_1; __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_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 268, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 268, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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_COMPILING_IN_CPYTHON
          __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(0, 268, __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(0, 268, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 268, __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(0, 268, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_8(__pyx_t_5);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 268, __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_CPYTHON
        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, 268, __pyx_L1_error)
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_6);
        #else
        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 268, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 268, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 268, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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_6 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 268, __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(0, 268, __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_6);
      __pyx_t_6 = 0;

      /* "cupy/core/elementwise.pxi":269
 *         assert len(out_params) == len(out_args_dtype)
 *         for p, a in six.moves.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":270
 *         for p, a in six.moves.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 a != p.dtype:
 */
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __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, 270, __pyx_L1_error)

        /* "cupy/core/elementwise.pxi":269
 *         assert len(out_params) == len(out_args_dtype)
 *         for p, a in six.moves.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":271
 *             if a is None:
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 *             if p.dtype is not None:             # <<<<<<<<<<<<<<
 *                 if a != p.dtype:
 *                     raise TypeError(
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = (__pyx_t_1 != Py_None);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_2 = (__pyx_t_11 != 0);
      if (__pyx_t_2) {

        /* "cupy/core/elementwise.pxi":272
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 *             if p.dtype is not None:
 *                 if a != p.dtype:             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = PyObject_RichCompare(__pyx_v_a, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 272, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 272, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (__pyx_t_2) {

          /* "cupy/core/elementwise.pxi":274
 *                 if a != 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_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 274, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 274, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
          __Pyx_INCREF(__pyx_v_a);
          __Pyx_GIVEREF(__pyx_v_a);
          PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_a);
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_1);
          __pyx_t_6 = 0;
          __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Type_is_mismatched_s_s_s, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "cupy/core/elementwise.pxi":273
 *             if p.dtype is not None:
 *                 if a != p.dtype:
 *                     raise TypeError(             # <<<<<<<<<<<<<<
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:
 */
          __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 273, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
          __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 273, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_Raise(__pyx_t_1, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __PYX_ERR(0, 273, __pyx_L1_error)

          /* "cupy/core/elementwise.pxi":272
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 *             if p.dtype is not None:
 *                 if a != p.dtype:             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 */
        }

        /* "cupy/core/elementwise.pxi":271
 *             if a is None:
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 *             if p.dtype is not None:             # <<<<<<<<<<<<<<
 *                 if a != p.dtype:
 *                     raise TypeError(
 */
        goto __pyx_L9;
      }

      /* "cupy/core/elementwise.pxi":275
 *                     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 t != a:
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_t_1, __pyx_v_type_dict, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 275, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_11 = (__pyx_t_2 != 0);
      if (__pyx_t_11) {

        /* "cupy/core/elementwise.pxi":276
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]             # <<<<<<<<<<<<<<
 *                 if t != a:
 *                     raise TypeError(
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_type_dict, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 276, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_7);
        __pyx_t_7 = 0;

        /* "cupy/core/elementwise.pxi":277
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]
 *                 if t != a:             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (
 */
        __pyx_t_7 = PyObject_RichCompare(__pyx_v_t, __pyx_v_a, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 277, __pyx_L1_error)
        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 277, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (__pyx_t_11) {

          /* "cupy/core/elementwise.pxi":280
 *                     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(0, 280, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 280, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7);
          __Pyx_INCREF(__pyx_v_a);
          __Pyx_GIVEREF(__pyx_v_a);
          PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_a);
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_t);
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_1);
          __pyx_t_7 = 0;
          __pyx_t_1 = 0;

          /* "cupy/core/elementwise.pxi":279
 *                 if t != a:
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (             # <<<<<<<<<<<<<<
 *                             p.name, a, t, p.ctype))
 *             else:
 */
          __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Type_is_mismatched_s_s_s_s, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 279, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "cupy/core/elementwise.pxi":278
 *                 t = type_dict[p.ctype]
 *                 if t != a:
 *                     raise TypeError(             # <<<<<<<<<<<<<<
 *                         'Type is mismatched. %s %s %s %s' % (
 *                             p.name, a, t, p.ctype))
 */
          __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 278, __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(0, 278, __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(0, 278, __pyx_L1_error)

          /* "cupy/core/elementwise.pxi":277
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]
 *                 if t != a:             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (
 */
        }

        /* "cupy/core/elementwise.pxi":275
 *                     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 t != a:
 */
        goto __pyx_L9;
      }

      /* "cupy/core/elementwise.pxi":282
 *                             p.name, a, t, p.ctype))
 *             else:
 *                 type_dict[p.ctype] = a             # <<<<<<<<<<<<<<
 * 
 *     assert len(in_params) == len(in_args_dtype)
 */
      /*else*/ {
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (unlikely(PyDict_SetItem(__pyx_v_type_dict, __pyx_t_1, __pyx_v_a) < 0)) __PYX_ERR(0, 282, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __pyx_L9:;

      /* "cupy/core/elementwise.pxi":268
 *     if out_args_dtype:
 *         assert len(out_params) == len(out_args_dtype)
 *         for p, a in six.moves.zip(out_params, out_args_dtype):             # <<<<<<<<<<<<<<
 *             if a is None:
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 */
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":266
 * 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 six.moves.zip(out_params, out_args_dtype):
 */
  }

  /* "cupy/core/elementwise.pxi":284
 *                 type_dict[p.ctype] = a
 * 
 *     assert len(in_params) == len(in_args_dtype)             # <<<<<<<<<<<<<<
 *     unknown_ctype = []
 *     for p, a in six.moves.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(0, 284, __pyx_L1_error)
    __pyx_t_3 = PyObject_Length(__pyx_v_in_args_dtype); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 284, __pyx_L1_error)
    if (unlikely(!((__pyx_t_4 == __pyx_t_3) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 284, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/core/elementwise.pxi":285
 * 
 *     assert len(in_params) == len(in_args_dtype)
 *     unknown_ctype = []             # <<<<<<<<<<<<<<
 *     for p, a in six.moves.zip(in_params, in_args_dtype):
 *         if a is None:
 */
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_unknown_ctype = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/elementwise.pxi":286
 *     assert len(in_params) == len(in_args_dtype)
 *     unknown_ctype = []
 *     for p, a in six.moves.zip(in_params, in_args_dtype):             # <<<<<<<<<<<<<<
 *         if a is None:
 *             if p.dtype is None:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_moves); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zip); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_3 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_3 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_6) {
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
  }
  __Pyx_INCREF(__pyx_v_in_params);
  __Pyx_GIVEREF(__pyx_v_in_params);
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_3, __pyx_v_in_params);
  __Pyx_INCREF(__pyx_v_in_args_dtype);
  __Pyx_GIVEREF(__pyx_v_in_args_dtype);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_3, __pyx_v_in_args_dtype);
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __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_3 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 286, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(0, 286, __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(0, 286, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(0, 286, __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(0, 286, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_8(__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(0, 286, __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_CPYTHON
      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, 286, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 286, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #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(0, 286, __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_L14_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      index = 1; __pyx_t_6 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_6)) goto __pyx_L14_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 286, __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(0, 286, __pyx_L1_error)
      __pyx_L15_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":287
 *     unknown_ctype = []
 *     for p, a in six.moves.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":288
 *     for p, a in six.moves.zip(in_params, in_args_dtype):
 *         if a is None:
 *             if p.dtype is None:             # <<<<<<<<<<<<<<
 *                 unknown_ctype.append(p.ctype)
 *         else:
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 288, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = (__pyx_t_5 == Py_None);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_11 = (__pyx_t_2 != 0);
      if (__pyx_t_11) {

        /* "cupy/core/elementwise.pxi":289
 *         if a is None:
 *             if p.dtype is None:
 *                 unknown_ctype.append(p.ctype)             # <<<<<<<<<<<<<<
 *         else:
 *             if p.dtype is not None:
 */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 289, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_unknown_ctype, __pyx_t_5); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 289, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "cupy/core/elementwise.pxi":288
 *     for p, a in six.moves.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":287
 *     unknown_ctype = []
 *     for p, a in six.moves.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":291
 *                 unknown_ctype.append(p.ctype)
 *         else:
 *             if p.dtype is not None:             # <<<<<<<<<<<<<<
 *                 if a != p.dtype:
 *                     raise TypeError(
 */
    /*else*/ {
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 291, __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":292
 *         else:
 *             if p.dtype is not None:
 *                 if a != p.dtype:             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 292, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = PyObject_RichCompare(__pyx_v_a, __pyx_t_5, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 292, __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, 292, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (__pyx_t_2) {

          /* "cupy/core/elementwise.pxi":294
 *                 if a != 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_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 294, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 294, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 294, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
          __Pyx_INCREF(__pyx_v_a);
          __Pyx_GIVEREF(__pyx_v_a);
          PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_a);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_5);
          __pyx_t_6 = 0;
          __pyx_t_5 = 0;
          __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Type_is_mismatched_s_s_s, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 294, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "cupy/core/elementwise.pxi":293
 *             if p.dtype is not None:
 *                 if a != p.dtype:
 *                     raise TypeError(             # <<<<<<<<<<<<<<
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:
 */
          __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 293, __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 = 0;
          __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 293, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_Raise(__pyx_t_5, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __PYX_ERR(0, 293, __pyx_L1_error)

          /* "cupy/core/elementwise.pxi":292
 *         else:
 *             if p.dtype is not None:
 *                 if a != p.dtype:             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 */
        }

        /* "cupy/core/elementwise.pxi":291
 *                 unknown_ctype.append(p.ctype)
 *         else:
 *             if p.dtype is not None:             # <<<<<<<<<<<<<<
 *                 if a != p.dtype:
 *                     raise TypeError(
 */
        goto __pyx_L18;
      }

      /* "cupy/core/elementwise.pxi":295
 *                     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 t != a:
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 295, __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(0, 295, __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":296
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]             # <<<<<<<<<<<<<<
 *                 if t != a:
 *                     raise TypeError(
 */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 296, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_type_dict, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 296, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_7);
        __pyx_t_7 = 0;

        /* "cupy/core/elementwise.pxi":297
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]
 *                 if t != a:             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (
 */
        __pyx_t_7 = PyObject_RichCompare(__pyx_v_t, __pyx_v_a, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 297, __pyx_L1_error)
        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 297, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (__pyx_t_11) {

          /* "cupy/core/elementwise.pxi":300
 *                     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(0, 300, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 300, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 300, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7);
          __Pyx_INCREF(__pyx_v_a);
          __Pyx_GIVEREF(__pyx_v_a);
          PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_a);
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_t);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5);
          __pyx_t_7 = 0;
          __pyx_t_5 = 0;

          /* "cupy/core/elementwise.pxi":299
 *                 if t != a:
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (             # <<<<<<<<<<<<<<
 *                             p.name, a, t, p.ctype))
 *             else:
 */
          __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Type_is_mismatched_s_s_s_s, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 299, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "cupy/core/elementwise.pxi":298
 *                 t = type_dict[p.ctype]
 *                 if t != a:
 *                     raise TypeError(             # <<<<<<<<<<<<<<
 *                         'Type is mismatched. %s %s %s %s' % (
 *                             p.name, a, t, p.ctype))
 */
          __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 298, __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 = 0;
          __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 298, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_Raise(__pyx_t_5, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __PYX_ERR(0, 298, __pyx_L1_error)

          /* "cupy/core/elementwise.pxi":297
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]
 *                 if t != a:             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (
 */
        }

        /* "cupy/core/elementwise.pxi":295
 *                     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 t != a:
 */
        goto __pyx_L18;
      }

      /* "cupy/core/elementwise.pxi":302
 *                             p.name, a, t, p.ctype))
 *             else:
 *                 type_dict[p.ctype] = a             # <<<<<<<<<<<<<<
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 */
      /*else*/ {
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 302, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (unlikely(PyDict_SetItem(__pyx_v_type_dict, __pyx_t_5, __pyx_v_a) < 0)) __PYX_ERR(0, 302, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __pyx_L18:;
    }
    __pyx_L16:;

    /* "cupy/core/elementwise.pxi":286
 *     assert len(in_params) == len(in_args_dtype)
 *     unknown_ctype = []
 *     for p, a in six.moves.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":304
 *                 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(0, 304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":305
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                       for p in in_params])             # <<<<<<<<<<<<<<
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                        for p in out_params])
 */
  if (likely(PyList_CheckExact(__pyx_v_in_params)) || PyTuple_CheckExact(__pyx_v_in_params)) {
    __pyx_t_5 = __pyx_v_in_params; __Pyx_INCREF(__pyx_t_5); __pyx_t_3 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_in_params); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 305, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 305, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 305, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 305, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 305, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 305, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_8(__pyx_t_5);
      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, 305, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":304
 *                 type_dict[p.ctype] = a
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype             # <<<<<<<<<<<<<<
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 304, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_11 = (__pyx_t_7 == Py_None);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if ((__pyx_t_11 != 0)) {
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 304, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_9 = __Pyx_PyDict_GetItem(__pyx_v_type_dict, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 304, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_6 = __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(0, 304, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_6 = __pyx_t_9;
      __pyx_t_9 = 0;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 304, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":305
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                       for p in in_params])             # <<<<<<<<<<<<<<
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                        for p in out_params])
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/elementwise.pxi":304
 *                 type_dict[p.ctype] = a
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype             # <<<<<<<<<<<<<<
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 */
  __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_in_types = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/elementwise.pxi":306
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype             # <<<<<<<<<<<<<<
 *                        for p in out_params])
 *     return in_types, out_types, tuple(type_dict.items())
 */
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/elementwise.pxi":307
 *                       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_8 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_out_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 307, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 307, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 307, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 307, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 307, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_8(__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, 307, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":306
 *     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(0, 306, __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(0, 306, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_type_dict, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 306, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_6 = __pyx_t_7;
      __pyx_t_7 = 0;
    } else {
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 306, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __pyx_t_7;
      __pyx_t_7 = 0;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 306, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":307
 *                       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":306
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype             # <<<<<<<<<<<<<<
 *                        for p in out_params])
 *     return in_types, out_types, tuple(type_dict.items())
 */
  __pyx_t_1 = PyList_AsTuple(((PyObject*)__pyx_t_5)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_out_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":308
 *     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(0, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_in_types);
  __Pyx_GIVEREF(__pyx_v_in_types);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_in_types);
  __Pyx_INCREF(__pyx_v_out_types);
  __Pyx_GIVEREF(__pyx_v_out_types);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_out_types);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":264
 * 
 * @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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __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":311
 * 
 * 
 * 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":315
 *     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(0, 315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_value = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":316
 *     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":317
 *     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":318
 *     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(0, 318, __pyx_L1_error)
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 318, __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":319
 *     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(0, 319, __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(0, 319, __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(0, 319, __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":320
 *     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(0, 320, __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(0, 320, __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":321
 *         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":322
 *         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":323
 *         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(0, 323, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":321
 *         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":325
 *             value.append(a)
 *         else:
 *             is_none = True             # <<<<<<<<<<<<<<
 *             value.append(None)
 * 
 */
    /*else*/ {
      __pyx_v_is_none = 1;

      /* "cupy/core/elementwise.pxi":326
 *         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(0, 326, __pyx_L1_error)
    }
    __pyx_L5:;
  }

  /* "cupy/core/elementwise.pxi":328
 *             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":329
 * 
 *     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":330
 *     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__37, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(0, 330, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":329
 * 
 *     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":328
 *             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":333
 *                              "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":334
 *     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__38, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 334, __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, 334, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":333
 *                              "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":335
 *         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(0, 335, __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(0, 335, __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":336
 *             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(0, 336, __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":337
 *     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(0, 337, __pyx_L1_error)
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 337, __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":338
 *     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(0, 338, __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(0, 338, __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":339
 *     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":340
 *         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(0, 340, __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(0, 340, __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":339
 *     for i in range(len(args)):
 *         a = brod.values[i]
 *         if a is None:             # <<<<<<<<<<<<<<
 *             a = args[i]
 *         value.append(a)
 */
    }

    /* "cupy/core/elementwise.pxi":341
 *         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(0, 341, __pyx_L1_error)
  }

  /* "cupy/core/elementwise.pxi":342
 *             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(0, 342, __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":311
 * 
 * 
 * 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":345
 * 
 * 
 * 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;
  Py_ssize_t __pyx_t_12;
  __Pyx_RefNannySetupContext("_get_out_args", 0);

  /* "cupy/core/elementwise.pxi":347
 * 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":348
 *                         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(0, 348, __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(0, 348, __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_COMPILING_IN_CPYTHON
      __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(0, 348, __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(0, 348, __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(0, 348, __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(0, 348, __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(0, 348, __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":347
 * 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":350
 *         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_COMPILING_IN_CPYTHON
    __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, 350, __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, 350, __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":351
 * 
 *     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":352
 *     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__39, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 352, __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, 352, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":351
 * 
 *     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":354
 *             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(0, 354, __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(0, 354, __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(0, 354, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_1) {

      /* "cupy/core/elementwise.pxi":355
 *                 '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__40, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 355, __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, 355, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":354
 *             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":356
 *         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(0, 356, __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(0, 356, __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":357
 *             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(0, 357, __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(0, 357, __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(0, 357, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 357, __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(0, 357, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_casting, __pyx_v_casting) < 0) __PYX_ERR(0, 357, __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(0, 357, __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(0, 357, __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":360
 *             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(0, 360, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);

      /* "cupy/core/elementwise.pxi":361
 *                   '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(0, 361, __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(0, 361, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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(0, 361, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 361, __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(0, 361, __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(0, 361, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/elementwise.pxi":362
 *                   '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(0, 362, __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(0, 362, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/elementwise.pxi":363
 *                       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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_4 = PyTuple_New(3+__pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 360, __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(0, 360, __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":364
 *                       a.dtype.char,
 *                       casting)
 *             raise TypeError(msg)             # <<<<<<<<<<<<<<
 *     return out_args
 * 
 */
      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 364, __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(0, 364, __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(0, 364, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":357
 *             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":350
 *         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":365
 *                       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":345
 * 
 * 
 * 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":368
 * 
 * 
 * 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":370
 * 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":372
 *         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":373
 *     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(0, 373, __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_COMPILING_IN_CPYTHON
      __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(0, 373, __pyx_L1_error)
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 373, __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(0, 373, __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":374
 *     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":375
 *         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__41, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 375, __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, 375, __pyx_L1_error)

        /* "cupy/core/elementwise.pxi":374
 *     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":373
 *     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":376
 *             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(0, 376, __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(0, 376, __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_COMPILING_IN_CPYTHON
      __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(0, 376, __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(0, 376, __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(0, 376, __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(0, 376, __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(0, 376, __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":372
 *         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":378
 *         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(0, 378, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v_out_params); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 378, __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":379
 * 
 *     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(0, 379, __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(0, 379, __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":380
 *     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(0, 380, __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(0, 380, __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(0, 380, __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":381
 *         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":382
 *         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__42, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 382, __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, 382, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":381
 *         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":384
 *             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(0, 384, __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(0, 384, __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(0, 384, __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":385
 *                 '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__43, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 385, __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, 385, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":384
 *             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":386
 *         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":368
 * 
 * 
 * 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":390
 * 
 * @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_25_get_elementwise_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4cupy_4core_4core_25_get_elementwise_kernel = {"_get_elementwise_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_25_get_elementwise_kernel, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4cupy_4core_4core_25_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);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(0, 390, __pyx_L3_error)
        }
        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(0, 390, __pyx_L3_error)
        }
        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(0, 390, __pyx_L3_error)
        }
        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(0, 390, __pyx_L3_error)
        }
        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(0, 390, __pyx_L3_error)
        }
        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(0, 390, __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(0, 390, __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(0, 390, __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_24_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":394
 *     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_RefNannyFinishContext();
    return NULL;
  }
  __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); if (unlikely(!gen)) __PYX_ERR(0, 394, __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(0, 394, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types)) { __Pyx_RaiseClosureNameError("types"); __PYX_ERR(0, 394, __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(0, 394, __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, 394, __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_COMPILING_IN_CPYTHON
        __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, 394, __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, 394, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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, 394, __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, 394, __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, 394, __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_CPYTHON
      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, 394, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      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(0, 394, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 394, __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(0, 394, __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(0, 394, __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(0, 394, __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(0, 394, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 394, __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(0, 394, __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(0, 394, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* 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":390
 * 
 * @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_24_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;
  PyObject *__pyx_t_3 = NULL;
  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)(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_RefNannyFinishContext();
    return NULL;
  }
  __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":392
 * 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(0, 392, __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(0, 392, __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(0, 392, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_kernel_params = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":394
 *     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(0, 394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":393
 *                             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__44, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 393, __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":395
 *     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__44); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __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(0, 395, __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":397
 *     preamble = types_preamble + '\n' + preamble
 * 
 *     op = []             # <<<<<<<<<<<<<<
 *     for p, a in six.moves.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(0, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_op = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":398
 * 
 *     op = []
 *     for p, a in six.moves.zip(params, args_info):             # <<<<<<<<<<<<<<
 *         if not p.raw and a[0] == ndarray:
 *             if p.is_const:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 398, __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, 398, __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_zip); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_3) {
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  }
  __Pyx_INCREF(__pyx_v_params);
  __Pyx_GIVEREF(__pyx_v_params);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_params);
  __Pyx_INCREF(__pyx_v_args_info);
  __Pyx_GIVEREF(__pyx_v_args_info);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_args_info);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __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 (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 398, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 398, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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, 398, __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, 398, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(0, 398, __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, 398, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_6(__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, 398, __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_CPYTHON
      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, 398, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyList_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(0, 398, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 398, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 398, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 398, __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(0, 398, __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_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":399
 *     op = []
 *     for p, a in six.moves.zip(params, args_info):
 *         if not p.raw and a[0] == ndarray:             # <<<<<<<<<<<<<<
 *             if p.is_const:
 *                 fmt = 'const {t} {n} = _raw_{n}[_ind.get()];'
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_raw_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 399, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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_1 = __Pyx_GetItemInt(__pyx_v_a, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 399, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 399, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_9 = __pyx_t_11;
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_9) {

      /* "cupy/core/elementwise.pxi":400
 *     for p, a in six.moves.zip(params, args_info):
 *         if not p.raw and a[0] == ndarray:
 *             if p.is_const:             # <<<<<<<<<<<<<<
 *                 fmt = 'const {t} {n} = _raw_{n}[_ind.get()];'
 *             else:
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_is_const); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 400, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 400, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_9) {

        /* "cupy/core/elementwise.pxi":401
 *         if not p.raw and a[0] == ndarray:
 *             if p.is_const:
 *                 fmt = 'const {t} {n} = _raw_{n}[_ind.get()];'             # <<<<<<<<<<<<<<
 *             else:
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 */
        __Pyx_INCREF(__pyx_kp_s_const_t_n__raw__n__ind_get);
        __Pyx_XDECREF_SET(__pyx_v_fmt, __pyx_kp_s_const_t_n__raw__n__ind_get);

        /* "cupy/core/elementwise.pxi":400
 *     for p, a in six.moves.zip(params, args_info):
 *         if not p.raw and a[0] == ndarray:
 *             if p.is_const:             # <<<<<<<<<<<<<<
 *                 fmt = 'const {t} {n} = _raw_{n}[_ind.get()];'
 *             else:
 */
        goto __pyx_L10;
      }

      /* "cupy/core/elementwise.pxi":403
 *                 fmt = 'const {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":404
 *             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_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_fmt, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 404, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 404, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 404, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_t, __pyx_t_5) < 0) __PYX_ERR(0, 404, __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(0, 404, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_n, __pyx_t_5) < 0) __PYX_ERR(0, 404, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 404, __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_t_12 = __Pyx_PyList_Append(__pyx_v_op, __pyx_t_5); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 404, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cupy/core/elementwise.pxi":399
 *     op = []
 *     for p, a in six.moves.zip(params, args_info):
 *         if not p.raw and a[0] == ndarray:             # <<<<<<<<<<<<<<
 *             if p.is_const:
 *                 fmt = 'const {t} {n} = _raw_{n}[_ind.get()];'
 */
    }

    /* "cupy/core/elementwise.pxi":398
 * 
 *     op = []
 *     for p, a in six.moves.zip(params, args_info):             # <<<<<<<<<<<<<<
 *         if not p.raw and a[0] == ndarray:
 *             if p.is_const:
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":405
 *                 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(0, 405, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":406
 *             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_2 = __Pyx_PyString_Join(__pyx_kp_s__44, __pyx_v_op); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_operation, __pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":407
 *     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_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_simple_elementwise_kernel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/elementwise.pxi":409
 *     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(0, 407, __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_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_kwargs);
  __Pyx_GIVEREF(__pyx_v_kwargs);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_kwargs);
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&PyDict_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":407
 *     op.append(operation)
 *     operation = '\n'.join(op)
 *     return _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         kernel_params, operation, name,
 *         preamble, **dict(kwargs))
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __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/elementwise.pxi":390
 * 
 * @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_3);
  __Pyx_XDECREF(__pyx_t_5);
  __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":461
 *         readonly object kwargs
 * 
 *     def __init__(self, in_params, out_params, operation,             # <<<<<<<<<<<<<<
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         self.in_params = _get_param_info(in_params, True)
 */

/* 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":462
 * 
 *     def __init__(self, in_params, out_params, operation,
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):             # <<<<<<<<<<<<<<
 *         self.in_params = _get_param_info(in_params, True)
 *         self.out_params = _get_param_info(out_params, False)
 */
    values[4] = ((PyObject *)Py_True);
    values[5] = ((PyObject *)__pyx_kp_s__4);
    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);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(0, 461, __pyx_L3_error)
        }
        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(0, 461, __pyx_L3_error)
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_reduce_dims);
          if (value) { values[4] = value; kw_args--; }
        }
        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(0, 461, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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(0, 461, __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":461
 *         readonly object kwargs
 * 
 *     def __init__(self, in_params, out_params, operation,             # <<<<<<<<<<<<<<
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         self.in_params = _get_param_info(in_params, True)
 */

  /* 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;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/elementwise.pxi":463
 *     def __init__(self, in_params, out_params, operation,
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         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_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_3) {
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  }
  __Pyx_INCREF(__pyx_v_in_params);
  __Pyx_GIVEREF(__pyx_v_in_params);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_in_params);
  __Pyx_INCREF(Py_True);
  __Pyx_GIVEREF(Py_True);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, Py_True);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 463, __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 (!(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, 463, __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":464
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         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_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_3 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__pyx_t_5) {
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = NULL;
  }
  __Pyx_INCREF(__pyx_v_out_params);
  __Pyx_GIVEREF(__pyx_v_out_params);
  PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_4, __pyx_v_out_params);
  __Pyx_INCREF(Py_False);
  __Pyx_GIVEREF(Py_False);
  PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_4, Py_False);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(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, 464, __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":465
 *         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(0, 465, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 465, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->nin = __pyx_t_4;

  /* "cupy/core/elementwise.pxi":466
 *         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(0, 466, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 466, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->nout = __pyx_t_4;

  /* "cupy/core/elementwise.pxi":467
 *         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":468
 *         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(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_param_rest = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":469
 *         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_2 = PyNumber_Add(__pyx_v_self->in_params, __pyx_v_self->out_params); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 469, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Add(__pyx_t_2, __pyx_v_param_rest); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 469, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 469, __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":470
 *         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(0, 470, __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":471
 *         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(0, 471, __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":472
 *         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(0, 472, __pyx_L1_error)
  __pyx_v_self->reduce_dims = __pyx_t_6;

  /* "cupy/core/elementwise.pxi":473
 *         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(0, 473, __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":474
 *         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(0, 474, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyFrozenSet_New(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 474, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->kwargs);
  __Pyx_DECREF(__pyx_v_self->kwargs);
  __pyx_v_self->kwargs = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":475
 *         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_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 475, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Add(__pyx_v_self->in_params, __pyx_v_self->out_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 475, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 475, __pyx_L1_error)
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 475, __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(0, 475, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 475, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_names = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":476
 *         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(0, 476, __pyx_L1_error)
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/elementwise.pxi":477
 *         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_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 477, __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, 477, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":476
 *         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":461
 *         readonly object kwargs
 * 
 *     def __init__(self, in_params, out_params, operation,             # <<<<<<<<<<<<<<
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         self.in_params = _get_param_info(in_params, True)
 */

  /* 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_5);
  __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":479
 *             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. If specified, the variable\n                ``n`` is set to this value. Otherwise, the result of\n                broadcasting is used to determine the value of ``n``.\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;
  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;
  PyObject *(*__pyx_t_10)(PyObject *);
  struct __pyx_opt_args_4cupy_4core_4core__get_out_args_with_params __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  __Pyx_RefNannySetupContext("__call__", 0);
  __Pyx_INCREF(__pyx_v_args);

  /* "cupy/core/elementwise.pxi":501
 *         cdef function.Function kern
 * 
 *         size = kwargs.pop('size', None)             # <<<<<<<<<<<<<<
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 501, __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":502
 * 
 *         size = kwargs.pop('size', 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(0, 502, __pyx_L1_error)
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":503
 *         size = kwargs.pop('size', None)
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)             # <<<<<<<<<<<<<<
 * 
 *         n_args = len(args)
 */
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_arguments_s, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 503, __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(0, 503, __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, 503, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":502
 * 
 *         size = kwargs.pop('size', None)
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":505
 *             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(0, 505, __pyx_L1_error)
  __pyx_v_n_args = __pyx_t_4;

  /* "cupy/core/elementwise.pxi":506
 * 
 *         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":507
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:
 *             raise TypeError('Wrong number of arguments for %s' % self.name)             # <<<<<<<<<<<<<<
 *         args = _preprocess_args(args)
 * 
 */
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_number_of_arguments_for_s, __pyx_v_self->name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 507, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 507, __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(0, 507, __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, 507, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":506
 * 
 *         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":508
 *         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_2 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_v_args, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":510
 *         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(0, 510, __pyx_L1_error)
  __pyx_t_2 = __pyx_v_self->params;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = (__pyx_v_size != Py_None);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__broadcast(((PyObject*)__pyx_v_args), ((PyObject*)__pyx_t_2), __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 510, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    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, 510, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_6);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 510, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 510, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 510, __pyx_L1_error)
  }
  __pyx_v_values = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_shape = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":511
 * 
 *         values, shape = _broadcast(args, self.params, size is not None)
 *         in_args = values[:self.nin]             # <<<<<<<<<<<<<<
 *         out_args = values[self.nin:]
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_values, 0, __pyx_v_self->nin, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 511, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_in_args = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":512
 *         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_1 = __Pyx_PyObject_GetSlice(__pyx_v_values, __pyx_v_self->nin, 0, NULL, NULL, NULL, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 512, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_out_args = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":515
 * 
 *         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_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":516
 *         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(0, 516, __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, 516, __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_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 516, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 516, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 516, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 516, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_7(__pyx_t_6);
      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, 516, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":515
 * 
 *         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(0, 515, __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(0, 515, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_2 = __pyx_t_9;
      __pyx_t_9 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_t_2 = Py_None;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 515, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":516
 *         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":514
 *         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_1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_in_ndarray_types = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":517
 *             [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(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (likely(PyList_CheckExact(__pyx_v_out_args)) || PyTuple_CheckExact(__pyx_v_out_args)) {
    __pyx_t_1 = __pyx_v_out_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_out_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __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, 517, __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_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 517, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 517, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 517, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 517, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_7(__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, 517, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyList_AsTuple(((PyObject*)__pyx_t_6)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_out_ndarray_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":519
 *         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(0, 519, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "cupy/core/elementwise.pxi":521
 *         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_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_4 = 1;
    }
  }
  __pyx_t_2 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 519, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__pyx_t_9) {
    __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_2, 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_2, 0+__pyx_t_4, __pyx_v_self->in_params);
  __Pyx_INCREF(__pyx_v_self->out_params);
  __Pyx_GIVEREF(__pyx_v_self->out_params);
  PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_4, __pyx_v_self->out_params);
  __Pyx_INCREF(__pyx_v_in_ndarray_types);
  __Pyx_GIVEREF(__pyx_v_in_ndarray_types);
  PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_4, __pyx_v_in_ndarray_types);
  __Pyx_INCREF(__pyx_v_out_ndarray_types);
  __Pyx_GIVEREF(__pyx_v_out_ndarray_types);
  PyTuple_SET_ITEM(__pyx_t_2, 3+__pyx_t_4, __pyx_v_out_ndarray_types);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 519, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    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, 519, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_9 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_9);
    #else
    __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    #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(0, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_10 = Py_TYPE(__pyx_t_8)->tp_iternext;
    index = 0; __pyx_t_6 = __pyx_t_10(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L11_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_6);
    index = 1; __pyx_t_2 = __pyx_t_10(__pyx_t_8); if (unlikely(!__pyx_t_2)) goto __pyx_L11_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 2; __pyx_t_9 = __pyx_t_10(__pyx_t_8); if (unlikely(!__pyx_t_9)) goto __pyx_L11_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_9);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_8), 3) < 0) __PYX_ERR(0, 519, __pyx_L1_error)
    __pyx_t_10 = 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_10 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 519, __pyx_L1_error)
    __pyx_L12_unpacking_done:;
  }

  /* "cupy/core/elementwise.pxi":519
 *         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_2;
  __pyx_t_2 = 0;
  __pyx_v_types = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":523
 *             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":524
 * 
 *         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":525
 *         is_size_specified = False
 *         if size is not None:
 *             shape = size,             # <<<<<<<<<<<<<<
 *             is_size_specified = True
 * 
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_size);
    __Pyx_GIVEREF(__pyx_v_size);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_size);
    __Pyx_DECREF_SET(__pyx_v_shape, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":526
 *         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":524
 * 
 *         is_size_specified = False
 *         if size is not None:             # <<<<<<<<<<<<<<
 *             shape = size,
 *             is_size_specified = True
 */
  }

  /* "cupy/core/elementwise.pxi":529
 * 
 *         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(0, 529, __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(0, 529, __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(0, 529, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_self->out_params;
  __Pyx_INCREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":528
 *             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_11.__pyx_n = 1;
  __pyx_t_11.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_1), &__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_out_args, __pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":530
 *         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":531
 *             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(0, 531, __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(0, 531, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_v_ret = __pyx_t_9;
    __pyx_t_9 = 0;

    /* "cupy/core/elementwise.pxi":530
 *         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":533
 *             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(0, 533, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_v_ret = __pyx_t_9;
    __pyx_t_9 = 0;
  }
  __pyx_L14:;

  /* "cupy/core/elementwise.pxi":535
 *             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(0, 535, __pyx_L1_error)
  __pyx_t_3 = (__pyx_t_5 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":536
 * 
 *         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":535
 *             ret = tuple(out_args)
 * 
 *         if 0 in shape:             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":538
 *             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(0, 538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;

  /* "cupy/core/elementwise.pxi":539
 * 
 *         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_2 = __pyx_v_in_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_in_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 539, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 539, __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_COMPILING_IN_CPYTHON
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 539, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 539, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 539, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 539, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_7(__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(0, 539, __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(0, 539, __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":538
 *             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_12 = PyObject_GetItem(__pyx_v_in_types, __pyx_v_i); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 538, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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_8 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_x); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 538, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 538, __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_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_v_x);
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_14, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 538, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 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(0, 538, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":539
 * 
 *         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_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_inout_args = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":540
 *         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(0, 540, __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":542
 *         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":544
 *         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(0, 544, __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(0, 544, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":543
 * 
 *         if self.reduce_dims:
 *             inout_args, shape = _reduce_dims(             # <<<<<<<<<<<<<<
 *                 inout_args, self.params, shape)
 *         indexer = Indexer(shape)
 */
    __pyx_t_1 = __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_1)) __PYX_ERR(0, 543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (likely(__pyx_t_1 != Py_None)) {
      PyObject* sequence = __pyx_t_1;
      #if CYTHON_COMPILING_IN_CPYTHON
      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, 543, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_2);
      #else
      __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 543, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 543, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 543, __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_2);
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":542
 *         inout_args += out_args
 * 
 *         if self.reduce_dims:             # <<<<<<<<<<<<<<
 *             inout_args, shape = _reduce_dims(
 *                 inout_args, self.params, shape)
 */
  }

  /* "cupy/core/elementwise.pxi":545
 *             inout_args, shape = _reduce_dims(
 *                 inout_args, self.params, shape)
 *         indexer = Indexer(shape)             # <<<<<<<<<<<<<<
 *         inout_args.append(indexer)
 * 
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 545, __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 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 545, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":546
 *                 inout_args, self.params, shape)
 *         indexer = Indexer(shape)
 *         inout_args.append(indexer)             # <<<<<<<<<<<<<<
 * 
 *         args_info = _get_args_info(inout_args)
 */
  __pyx_t_15 = __Pyx_PyObject_Append(__pyx_v_inout_args, ((PyObject *)__pyx_v_indexer)); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(0, 546, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":548
 *         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(0, 548, __pyx_L1_error)
  __pyx_t_2 = __pyx_f_4cupy_4core_4core__get_args_info(((PyObject*)__pyx_v_inout_args), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 548, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_args_info = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":549
 * 
 *         args_info = _get_args_info(inout_args)
 *         kern = _get_elementwise_kernel(             # <<<<<<<<<<<<<<
 *             args_info, types, self.params, self.operation,
 *             self.name, self.preamble, self.kwargs)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_elementwise_kernel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 549, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":551
 *         kern = _get_elementwise_kernel(
 *             args_info, types, self.params, self.operation,
 *             self.name, self.preamble, self.kwargs)             # <<<<<<<<<<<<<<
 *         kern.linear_launch(indexer.size, inout_args)
 *         return ret
 */
  __pyx_t_9 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(7+__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 549, __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_4, __pyx_v_args_info);
  __Pyx_INCREF(__pyx_v_types);
  __Pyx_GIVEREF(__pyx_v_types);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_4, __pyx_v_types);
  __Pyx_INCREF(__pyx_v_self->params);
  __Pyx_GIVEREF(__pyx_v_self->params);
  PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_4, __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_4, __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_4, __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_4, __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_4, __pyx_v_self->kwargs);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 549, __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;

  /* "cupy/core/elementwise.pxi":549
 * 
 *         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_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4cuda_8function_Function))))) __PYX_ERR(0, 549, __pyx_L1_error)
  __pyx_v_kern = ((struct __pyx_obj_4cupy_4cuda_8function_Function *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":552
 *             args_info, types, self.params, self.operation,
 *             self.name, self.preamble, self.kwargs)
 *         kern.linear_launch(indexer.size, inout_args)             # <<<<<<<<<<<<<<
 *         return ret
 * 
 */
  __pyx_t_2 = ((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_2)) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":553
 *             self.name, self.preamble, self.kwargs)
 *         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":479
 *             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_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __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_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":449
 * 
 *     cdef:
 *         readonly tuple in_params             # <<<<<<<<<<<<<<
 *         readonly tuple out_params
 *         readonly int 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":450
 *     cdef:
 *         readonly tuple in_params
 *         readonly tuple out_params             # <<<<<<<<<<<<<<
 *         readonly int nin
 *         readonly int 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":451
 *         readonly tuple in_params
 *         readonly tuple out_params
 *         readonly int nin             # <<<<<<<<<<<<<<
 *         readonly int nout
 *         readonly int 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 = __Pyx_PyInt_From_int(__pyx_v_self->nin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":452
 *         readonly tuple out_params
 *         readonly int nin
 *         readonly int nout             # <<<<<<<<<<<<<<
 *         readonly int 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 = __Pyx_PyInt_From_int(__pyx_v_self->nout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 452, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":453
 *         readonly int nin
 *         readonly int nout
 *         readonly int 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 = __Pyx_PyInt_From_int(__pyx_v_self->nargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 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.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":454
 *         readonly int nout
 *         readonly int 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":455
 *         readonly int 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":456
 *         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":457
 *         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(0, 457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":458
 *         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":459
 *         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;
}

/* "cupy/core/elementwise.pxi":557
 * 
 * @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_27_get_ufunc_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4cupy_4core_4core_27_get_ufunc_kernel = {"_get_ufunc_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_27_get_ufunc_kernel, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4cupy_4core_4core_27_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);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(0, 557, __pyx_L3_error)
        }
        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(0, 557, __pyx_L3_error)
        }
        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(0, 557, __pyx_L3_error)
        }
        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(0, 557, __pyx_L3_error)
        }
        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(0, 557, __pyx_L3_error)
        }
        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(0, 557, __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(0, 557, __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(0, 557, __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_26_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_26_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;
  PyObject *__pyx_t_13 = NULL;
  __Pyx_RefNannySetupContext("_get_ufunc_kernel", 0);
  __Pyx_INCREF(__pyx_v_preamble);

  /* "cupy/core/elementwise.pxi":559
 * 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(0, 559, __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(0, 559, __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(0, 559, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_kernel_params = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":561
 *     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(0, 561, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":562
 * 
 *     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(0, 562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_op = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":563
 *     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(0, 563, __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(0, 563, __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_COMPILING_IN_CPYTHON
        __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(0, 563, __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(0, 563, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(0, 563, __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(0, 563, __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(0, 563, __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(0, 563, __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":564
 *     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(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 564, __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(0, 564, __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(0, 564, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":565
 *     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()];'.format(i))
 */
    __pyx_t_5 = PyObject_GetItem(__pyx_v_args_info, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 565, __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(0, 565, __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":567
 *         if args_info[i][0] is ndarray:
 *             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(0, 567, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_10 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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(0, 567, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 567, __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(0, 567, __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":566
 *         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(0, 566, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/elementwise.pxi":565
 *     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()];'.format(i))
 */
    }

    /* "cupy/core/elementwise.pxi":563
 *     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":569
 *                 'const in{0}_type in{0} = _raw_in{0}[_ind.get()];'.format(i))
 * 
 *     for i, x in enumerate(out_types):             # <<<<<<<<<<<<<<
 *         types.append('typedef %s out%d_type;' % (_get_typename(x), i))
 *         op.append('{1} &out{0} = _raw_out{0}[_ind.get()];'.format(
 */
  __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(0, 569, __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(0, 569, __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_COMPILING_IN_CPYTHON
        __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(0, 569, __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(0, 569, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(0, 569, __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(0, 569, __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(0, 569, __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(0, 569, __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":570
 * 
 *     for i, x in enumerate(out_types):
 *         types.append('typedef %s out%d_type;' % (_get_typename(x), i))             # <<<<<<<<<<<<<<
 *         op.append('{1} &out{0} = _raw_out{0}[_ind.get()];'.format(
 *             i, _get_typename(args_info[i + len(in_types)][1])))
 */
    __pyx_t_6 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_x, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 570, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 570, __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;
    __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_typedef_s_out_d_type, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 570, __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(0, 570, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":571
 *     for i, x in enumerate(out_types):
 *         types.append('typedef %s out%d_type;' % (_get_typename(x), i))
 *         op.append('{1} &out{0} = _raw_out{0}[_ind.get()];'.format(             # <<<<<<<<<<<<<<
 *             i, _get_typename(args_info[i + len(in_types)][1])))
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_1_out_0__raw_out_0__ind_get, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 571, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);

    /* "cupy/core/elementwise.pxi":572
 *         types.append('typedef %s out%d_type;' % (_get_typename(x), i))
 *         op.append('{1} &out{0} = _raw_out{0}[_ind.get()];'.format(
 *             i, _get_typename(args_info[i + len(in_types)][1])))             # <<<<<<<<<<<<<<
 * 
 *     op.append(routine)
 */
    __pyx_t_12 = PyObject_Length(__pyx_v_in_types); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 572, __pyx_L1_error)
    __pyx_t_11 = PyInt_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_10 = PyNumber_Add(__pyx_v_i, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = PyObject_GetItem(__pyx_v_args_info, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_11, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_t_10, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = NULL;
    __pyx_t_12 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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_12 = 1;
      }
    }
    __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 571, __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_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_v_i);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_11);
    __pyx_t_11 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_13, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 571, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":571
 *     for i, x in enumerate(out_types):
 *         types.append('typedef %s out%d_type;' % (_get_typename(x), i))
 *         op.append('{1} &out{0} = _raw_out{0}[_ind.get()];'.format(             # <<<<<<<<<<<<<<
 *             i, _get_typename(args_info[i + len(in_types)][1])))
 * 
 */
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_op, __pyx_t_6); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 571, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":569
 *                 'const in{0}_type in{0} = _raw_in{0}[_ind.get()];'.format(i))
 * 
 *     for i, x in enumerate(out_types):             # <<<<<<<<<<<<<<
 *         types.append('typedef %s out%d_type;' % (_get_typename(x), i))
 *         op.append('{1} &out{0} = _raw_out{0}[_ind.get()];'.format(
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":574
 *             i, _get_typename(args_info[i + len(in_types)][1])))
 * 
 *     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(0, 574, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":575
 * 
 *     op.append(routine)
 *     operation = '\n'.join(op)             # <<<<<<<<<<<<<<
 * 
 *     types.append(preamble)
 */
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__44, __pyx_v_op); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 575, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_operation = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":577
 *     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(0, 577, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":578
 * 
 *     types.append(preamble)
 *     preamble = '\n'.join(types)             # <<<<<<<<<<<<<<
 * 
 *     return _get_simple_elementwise_kernel(
 */
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__44, __pyx_v_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 578, __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":580
 *     preamble = '\n'.join(types)
 * 
 *     return _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         kernel_params, operation, name, preamble)
 * 
 */
  __Pyx_XDECREF(__pyx_r);

  /* "cupy/core/elementwise.pxi":581
 * 
 *     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(0, 580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":557
 * 
 * @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_XDECREF(__pyx_t_13);
  __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":584
 * 
 * 
 * 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;
  Py_ssize_t __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":587
 *     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(0, 587, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_in_types); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 587, __pyx_L1_error)
  __pyx_v_n = __pyx_t_1;

  /* "cupy/core/elementwise.pxi":588
 *     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(0, 588, __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(0, 588, __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":589
 *     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(0, 589, __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_COMPILING_IN_CPYTHON
    __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(0, 589, __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(0, 589, __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(0, 589, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_op, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":590
 *     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(0, 590, __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(0, 590, __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(0, 590, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_op_types, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":591
 *     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":592
 *         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(0, 592, __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(0, 592, __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(0, 592, __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(0, 592, __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_COMPILING_IN_CPYTHON && 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;
        }
      }
      __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 592, __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(0, 592, __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(0, 592, __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":593
 *         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":592
 *         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":595
 *                 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":589
 *     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":596
 *         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":584
 * 
 * 
 * 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":599
 * 
 * 
 * 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":601
 * 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(0, 601, __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_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 601, __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, 601, __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(0, 601, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_op, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":602
 *     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(0, 602, __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(0, 602, __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(0, 602, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_op_types, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":603
 *     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(0, 603, __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_COMPILING_IN_CPYTHON
      __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(0, 603, __pyx_L1_error)
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 603, __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":604
 *         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(0, 604, __pyx_L1_error)
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 604, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {

        /* "cupy/core/elementwise.pxi":605
 *         for t in op_types:
 *             if t != dtype:
 *                 break             # <<<<<<<<<<<<<<
 *         else:
 *             return op
 */
        goto __pyx_L6_break;

        /* "cupy/core/elementwise.pxi":604
 *         op_types = op[1]
 *         for t in op_types:
 *             if t != dtype:             # <<<<<<<<<<<<<<
 *                 break
 *         else:
 */
      }

      /* "cupy/core/elementwise.pxi":603
 *     for op in ops:
 *         op_types = op[1]
 *         for t in op_types:             # <<<<<<<<<<<<<<
 *             if t != dtype:
 *                 break
 */
    }
    /*else*/ {

      /* "cupy/core/elementwise.pxi":607
 *                 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":603
 *     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":601
 * 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":608
 *         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":599
 * 
 * 
 * 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":611
 * 
 * 
 * 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":614
 *     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":615
 *     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":616
 *     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":617
 *     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(0, 617, __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_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 617, __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, 617, __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":618
 *     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(0, 618, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_i, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 618, __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(0, 618, __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(0, 618, __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(0, 618, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_kind = __pyx_t_5;

    /* "cupy/core/elementwise.pxi":619
 *     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":620
 *         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":621
 *         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":619
 *     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":623
 *             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":617
 *     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":624
 *         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":625
 *             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":626
 *     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":611
 * 
 * 
 * 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":629
 * 
 * 
 * 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);

  /* "cupy/core/elementwise.pxi":630
 * 
 * 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":631
 * 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(0, 631, __pyx_L1_error)
    __pyx_v_use_raw_value = __pyx_t_2;

    /* "cupy/core/elementwise.pxi":632
 *     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":633
 *         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(0, 633, __pyx_L1_error)
      }
      __pyx_t_3 = PyList_AsTuple(__pyx_v_in_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 633, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_v_in_types = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/elementwise.pxi":634
 *         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":632
 *     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":636
 *             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(0, 636, __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(0, 636, __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_COMPILING_IN_CPYTHON
        __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(0, 636, __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(0, 636, __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(0, 636, __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(0, 636, __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(0, 636, __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(0, 636, __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":637
 *         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(0, 637, __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(0, 637, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_op = __pyx_t_4;
      __pyx_t_4 = 0;
    }
    __pyx_L4:;

    /* "cupy/core/elementwise.pxi":639
 *             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":640
 * 
 *         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(0, 640, __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":641
 *         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":642
 *             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(0, 642, __pyx_L1_error)
        }
        if (unlikely(PyDict_SetItem(__pyx_v_cache, __pyx_v_in_types, __pyx_v_op) < 0)) __PYX_ERR(0, 642, __pyx_L1_error)

        /* "cupy/core/elementwise.pxi":641
 *         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":639
 *             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":630
 * 
 * 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":644
 *                 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(0, 644, __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(0, 644, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_op = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/core/elementwise.pxi":645
 *     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":646
 *         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(0, 646, __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":647
 *         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(0, 647, __pyx_L1_error)
      }
      if (unlikely(PyDict_SetItem(__pyx_v_cache, __pyx_v_dtype, __pyx_v_op) < 0)) __PYX_ERR(0, 647, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":645
 *     else:
 *         op = cache.get(dtype, ())
 *         if op is ():             # <<<<<<<<<<<<<<
 *             op = _guess_routine_from_dtype(ops, dtype)
 *             cache[dtype] = op
 */
    }
  }
  __pyx_L3:;

  /* "cupy/core/elementwise.pxi":649
 *             cache[dtype] = op
 * 
 *     if op:             # <<<<<<<<<<<<<<
 *         return op
 *     raise TypeError('Wrong type of arguments for %s' % name)
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_op); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 649, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":650
 * 
 *     if op:
 *         return op             # <<<<<<<<<<<<<<
 *     raise TypeError('Wrong type of arguments for %s' % name)
 * 
 */
    __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(0, 650, __pyx_L1_error)
    __Pyx_INCREF(__pyx_v_op);
    __pyx_r = ((PyObject*)__pyx_v_op);
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":649
 *             cache[dtype] = op
 * 
 *     if op:             # <<<<<<<<<<<<<<
 *         return op
 *     raise TypeError('Wrong type of arguments for %s' % name)
 */
  }

  /* "cupy/core/elementwise.pxi":651
 *     if op:
 *         return op
 *     raise TypeError('Wrong type of arguments for %s' % name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_type_of_arguments_for_s, __pyx_v_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 651, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 651, __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(0, 651, __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, 651, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":629
 * 
 * 
 * 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_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":665
 * 
 *     """
 *     def __init__(self, name, nin, nout, ops, preamble='', doc=''):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self.nin = nin
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4cupy_4core_4core_5ufunc_1__init__ = {"__init__", (PyCFunction)__pyx_pw_4cupy_4core_4core_5ufunc_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
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_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,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    values[5] = ((PyObject *)((PyObject*)__pyx_kp_s__4));
    values[6] = ((PyObject *)((PyObject*)__pyx_kp_s__4));
    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);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 7, 1); __PYX_ERR(0, 665, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nin)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 7, 2); __PYX_ERR(0, 665, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nout)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 7, 3); __PYX_ERR(0, 665, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ops)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 7, 4); __PYX_ERR(0, 665, __pyx_L3_error)
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_preamble);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_doc);
          if (value) { values[6] = 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, 665, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        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];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 665, __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);

  /* 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":674
 *         self.__doc__ = doc
 *         _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_RefNannyFinishContext();
    return NULL;
  }
  __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); if (unlikely(!gen)) __PYX_ERR(0, 674, __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(0, 674, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":675
 *         _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(0, 675, __pyx_L1_error) }
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 675, __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(0, 675, __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(0, 675, __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(0, 675, __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_COMPILING_IN_CPYTHON
        __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(0, 675, __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(0, 675, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(0, 675, __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(0, 675, __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(0, 675, __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":674
 *         self.__doc__ = doc
 *         _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(0, 674, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 674, __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(0, 674, __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(0, 674, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":675
 *         _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;

  /* "cupy/core/elementwise.pxi":674
 *         self.__doc__ = doc
 *         _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":677
 *             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_RefNannyFinishContext();
    return NULL;
  }
  __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); if (unlikely(!gen)) __PYX_ERR(0, 677, __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(0, 677, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":678
 *         _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(0, 678, __pyx_L1_error) }
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 678, __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(0, 678, __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(0, 678, __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(0, 678, __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_COMPILING_IN_CPYTHON
        __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(0, 678, __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(0, 678, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(0, 678, __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(0, 678, __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(0, 678, __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":677
 *             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(0, 677, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 677, __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(0, 677, __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(0, 677, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":678
 *         _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;

  /* "cupy/core/elementwise.pxi":677
 *             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":665
 * 
 *     """
 *     def __init__(self, name, nin, nout, ops, preamble='', doc=''):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self.nin = nin
 */

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) {
  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;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = 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_RefNannyFinishContext();
    return NULL;
  }
  __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":666
 *     """
 *     def __init__(self, name, nin, nout, ops, preamble='', doc=''):
 *         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(0, 666, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":667
 *     def __init__(self, name, nin, nout, ops, preamble='', doc=''):
 *         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(0, 667, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":668
 *         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(0, 668, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":669
 *         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(0, 669, __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(0, 669, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":670
 *         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(0, 670, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":671
 *         self.nargs = nin + nout
 *         self._ops = ops
 *         self._preamble = preamble             # <<<<<<<<<<<<<<
 *         self.__doc__ = doc
 *         _in_params = tuple(
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_preamble_2, __pyx_v_preamble) < 0) __PYX_ERR(0, 671, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":672
 *         self._ops = ops
 *         self._preamble = preamble
 *         self.__doc__ = doc             # <<<<<<<<<<<<<<
 *         _in_params = tuple(
 *             ParameterInfo('T in%d' % i, True)
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_doc_2, __pyx_v_doc) < 0) __PYX_ERR(0, 672, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":674
 *         self.__doc__ = doc
 *         _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(0, 674, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":673
 *         self._preamble = preamble
 *         self.__doc__ = doc
 *         _in_params = tuple(             # <<<<<<<<<<<<<<
 *             ParameterInfo('T in%d' % i, True)
 *             for i in range(nin))
 */
  __pyx_t_2 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 673, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v__in_params = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":677
 *             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_pf_4cupy_4core_4core_5ufunc_8__init___3genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 677, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/elementwise.pxi":676
 *             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_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 676, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v__out_params = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":679
 *             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(0, 679, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":680
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (
 *             ParameterInfo('CIndexer _ind', False),)             # <<<<<<<<<<<<<<
 *         self._routine_cache = {}
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ParameterInfo), __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 680, __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;

  /* "cupy/core/elementwise.pxi":679
 *             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_2 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 679, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_params_2, __pyx_t_2) < 0) __PYX_ERR(0, 679, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":681
 *         self._params = _in_params + _out_params + (
 *             ParameterInfo('CIndexer _ind', False),)
 *         self._routine_cache = {}             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_routine_cache, __pyx_t_2) < 0) __PYX_ERR(0, 681, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":665
 * 
 *     """
 *     def __init__(self, name, nin, nout, ops, preamble='', doc=''):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self.nin = nin
 */

  /* 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.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":683
 *         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 PyMethodDef __pyx_mdef_4cupy_4core_4core_5ufunc_3__repr__ = {"__repr__", (PyCFunction)__pyx_pw_4cupy_4core_4core_5ufunc_3__repr__, METH_O, 0};
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":684
 * 
 *     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(0, 684, __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(0, 684, __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":683
 *         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":687
 * 
 *     @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[] = "A 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":694
 * 
 *         """
 *         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(0, 694, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":695
 *         """
 *         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(0, 695, __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(0, 695, __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(0, 695, __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_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 695, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 695, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 695, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 695, __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(0, 695, __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_CPYTHON
      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, 695, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      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(0, 695, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 695, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 695, __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(0, 695, __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(0, 695, __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(0, 695, __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":696
 *         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(0, 696, __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(0, 696, __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(0, 696, __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_COMPILING_IN_CPYTHON
          __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(0, 696, __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(0, 696, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __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(0, 696, __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(0, 696, __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(0, 696, __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(0, 696, __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(0, 696, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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(0, 696, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 696, __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(0, 696, __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(0, 696, __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(0, 696, __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__4, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 696, __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":697
 *         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(0, 697, __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(0, 697, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 697, __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_COMPILING_IN_CPYTHON
          __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(0, 697, __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(0, 697, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __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(0, 697, __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(0, 697, __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(0, 697, __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(0, 697, __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(0, 697, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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(0, 697, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 697, __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(0, 697, __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(0, 697, __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(0, 697, __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__4, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 697, __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":698
 *             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(0, 698, __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(0, 698, __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(0, 698, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":695
 *         """
 *         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":699
 *             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":687
 * 
 *     @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":701
 *         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__[] = "Applies 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);
        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(0, 701, __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(0, 701, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("cupy.core.core.ufunc.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_5ufunc_6__call__(__pyx_self, __pyx_v_self, __pyx_v_args, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc_6__call__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_4cupy_4cuda_8function_Function *__pyx_v_kern = 0;
  PyObject *__pyx_v_out = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_casting = NULL;
  Py_ssize_t __pyx_v_n_args;
  PyObject *__pyx_v_in_args = NULL;
  PyObject *__pyx_v_out_args = NULL;
  struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_broad = NULL;
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  PyObject *__pyx_v_routine = NULL;
  PyObject *__pyx_v_ret = NULL;
  PyObject *__pyx_v_inout_args = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_x = NULL;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_indexer = NULL;
  PyObject *__pyx_v_args_info = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  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;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  __Pyx_RefNannySetupContext("__call__", 0);
  __Pyx_INCREF(__pyx_v_args);

  /* "cupy/core/elementwise.pxi":719
 *         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(0, 719, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 719, __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":720
 * 
 *         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', 'same_kind')
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 720, __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":722
 *         dtype = kwargs.pop('dtype', None)
 *         # Note default behavior of casting is 'same_kind' on numpy>=1.10
 *         casting = kwargs.pop('casting', 'same_kind')             # <<<<<<<<<<<<<<
 *         if dtype is not None:
 *             dtype = numpy.dtype(dtype).type
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 722, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 722, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_casting = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":723
 *         # Note default behavior of casting is 'same_kind' on numpy>=1.10
 *         casting = kwargs.pop('casting', 'same_kind')
 *         if dtype is not None:             # <<<<<<<<<<<<<<
 *             dtype = numpy.dtype(dtype).type
 *         if kwargs:
 */
  __pyx_t_3 = (__pyx_v_dtype != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "cupy/core/elementwise.pxi":724
 *         casting = kwargs.pop('casting', 'same_kind')
 *         if dtype is not None:
 *             dtype = numpy.dtype(dtype).type             # <<<<<<<<<<<<<<
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_1) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 724, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 724, __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_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_dtype);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 724, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __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_2, __pyx_n_s_type); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":723
 *         # Note default behavior of casting is 'same_kind' on numpy>=1.10
 *         casting = kwargs.pop('casting', 'same_kind')
 *         if dtype is not None:             # <<<<<<<<<<<<<<
 *             dtype = numpy.dtype(dtype).type
 *         if kwargs:
 */
  }

  /* "cupy/core/elementwise.pxi":725
 *         if dtype is not None:
 *             dtype = numpy.dtype(dtype).type
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 725, __pyx_L1_error)
  if (__pyx_t_4) {

    /* "cupy/core/elementwise.pxi":726
 *             dtype = numpy.dtype(dtype).type
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)             # <<<<<<<<<<<<<<
 * 
 *         n_args = len(args)
 */
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_arguments_s, __pyx_v_kwargs); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 726, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 726, __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_TypeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 726, __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(0, 726, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":725
 *         if dtype is not None:
 *             dtype = numpy.dtype(dtype).type
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":728
 *             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_7 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 728, __pyx_L1_error)
  __pyx_v_n_args = __pyx_t_7;

  /* "cupy/core/elementwise.pxi":729
 * 
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 * 
 */
  __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_n_args); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyObject_RichCompare(__pyx_t_5, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 729, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 729, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_3) {
  } else {
    __pyx_t_4 = __pyx_t_3;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_n_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_6, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 729, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __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(0, 729, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_4 = __pyx_t_3;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_4) {

    /* "cupy/core/elementwise.pxi":730
 *         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_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 730, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_number_of_arguments_for_s, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 730, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 730, __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 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 730, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 730, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":729
 * 
 *         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":732
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 * 
 *         args = _preprocess_args(args)             # <<<<<<<<<<<<<<
 *         if out is None:
 *             in_args = args[:self.nin]
 */
  __pyx_t_2 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_v_args, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 732, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":733
 * 
 *         args = _preprocess_args(args)
 *         if out is None:             # <<<<<<<<<<<<<<
 *             in_args = args[:self.nin]
 *             out_args = args[self.nin:]
 */
  __pyx_t_4 = (__pyx_v_out == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":734
 *         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(0, 734, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 734, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 734, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyList_GetSlice(__pyx_v_args, 0, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 734, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_in_args = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":735
 *         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(0, 735, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 735, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 735, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyList_GetSlice(__pyx_v_args, __pyx_t_7, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 735, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_out_args = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":733
 * 
 *         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":737
 *             out_args = args[self.nin:]
 *         else:
 *             if self.nout != 1:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Cannot use 'out' in %s" % self.name)
 *             if n_args != self.nin:
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 737, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_int_1, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 737, __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(0, 737, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_3) {

      /* "cupy/core/elementwise.pxi":738
 *         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_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 738, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Cannot_use_out_in_s, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 738, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 738, __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 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 738, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(0, 738, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":737
 *             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":739
 *             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_2 = PyInt_FromSsize_t(__pyx_v_n_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, __pyx_t_5, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_3) {

      /* "cupy/core/elementwise.pxi":740
 *                 raise ValueError("Cannot use 'out' in %s" % self.name)
 *             if n_args != self.nin:
 *                 raise ValueError("Cannot specify 'out' as both "             # <<<<<<<<<<<<<<
 *                                  "a positional and keyword argument")
 * 
 */
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 740, __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, 740, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":739
 *             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":743
 *                                  "a positional and keyword argument")
 * 
 *             in_args = list(args)             # <<<<<<<<<<<<<<
 *             out_args = _preprocess_args((out,))
 *             args += out_args
 */
    __pyx_t_6 = PySequence_List(__pyx_v_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_in_args = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":744
 * 
 *             in_args = list(args)
 *             out_args = _preprocess_args((out,))             # <<<<<<<<<<<<<<
 *             args += out_args
 * 
 */
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 744, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_out);
    __Pyx_GIVEREF(__pyx_v_out);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_out);
    __pyx_t_5 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_t_6, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 744, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_out_args = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":745
 *             in_args = list(args)
 *             out_args = _preprocess_args((out,))
 *             args += out_args             # <<<<<<<<<<<<<<
 * 
 *         broad = broadcast(*args)
 */
    __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_args, __pyx_v_out_args); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 745, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_5);
    __pyx_t_5 = 0;
  }
  __pyx_L8:;

  /* "cupy/core/elementwise.pxi":747
 *             args += out_args
 * 
 *         broad = broadcast(*args)             # <<<<<<<<<<<<<<
 *         shape = broad.shape
 * 
 */
  __pyx_t_5 = PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_broadcast), __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_broad = ((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":748
 * 
 *         broad = broadcast(*args)
 *         shape = broad.shape             # <<<<<<<<<<<<<<
 * 
 *         in_types, out_types, routine = _guess_routine(
 */
  __pyx_t_6 = __pyx_v_broad->shape;
  __Pyx_INCREF(__pyx_t_6);
  __pyx_v_shape = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":751
 * 
 *         in_types, out_types, routine = _guess_routine(
 *             self.name, self._routine_cache, self._ops, in_args, dtype)             # <<<<<<<<<<<<<<
 * 
 *         out_args = _get_out_args(out_args, out_types, shape, casting)
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 751, __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(0, 751, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_routine_cache); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 751, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (!(likely(PyDict_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(0, 751, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ops_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 751, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 751, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":750
 *         shape = broad.shape
 * 
 *         in_types, out_types, routine = _guess_routine(             # <<<<<<<<<<<<<<
 *             self.name, self._routine_cache, self._ops, in_args, dtype)
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__guess_routine(((PyObject*)__pyx_t_6), ((PyObject*)__pyx_t_5), ((PyObject*)__pyx_t_2), __pyx_v_in_args, __pyx_v_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    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, 750, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = 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_2);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_6);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 750, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 750, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 750, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 750, __pyx_L1_error)
  }
  __pyx_v_in_types = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_out_types = __pyx_t_5;
  __pyx_t_5 = 0;
  __pyx_v_routine = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":753
 *             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(0, 753, __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(0, 753, __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(0, 753, __pyx_L1_error)
  __pyx_t_1 = __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_1)) __PYX_ERR(0, 753, __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/elementwise.pxi":754
 * 
 *         out_args = _get_out_args(out_args, out_types, shape, casting)
 *         if self.nout == 1:             # <<<<<<<<<<<<<<
 *             ret = out_args[0]
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 754, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 754, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __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, 754, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":755
 *         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(0, 755, __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(0, 755, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_ret = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":754
 * 
 *         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":757
 *             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(0, 757, __pyx_L1_error)
    }
    __pyx_t_6 = PyList_AsTuple(__pyx_v_out_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 757, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_ret = __pyx_t_6;
    __pyx_t_6 = 0;
  }
  __pyx_L11:;

  /* "cupy/core/elementwise.pxi":759
 *             ret = tuple(out_args)
 * 
 *         if 0 in shape:             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
  __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_int_0, __pyx_v_shape, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 759, __pyx_L1_error)
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "cupy/core/elementwise.pxi":760
 * 
 *         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":759
 *             ret = tuple(out_args)
 * 
 *         if 0 in shape:             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":762
 *             return ret
 * 
 *         inout_args = []             # <<<<<<<<<<<<<<
 *         for i, t in enumerate(in_types):
 *             x = broad.values[i]
 */
  __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_inout_args = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":763
 * 
 *         inout_args = []
 *         for i, t in enumerate(in_types):             # <<<<<<<<<<<<<<
 *             x = broad.values[i]
 *             inout_args.append(x if isinstance(x, ndarray) else t(x))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_6 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_in_types)) || PyTuple_CheckExact(__pyx_v_in_types)) {
    __pyx_t_1 = __pyx_v_in_types; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_in_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 763, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 763, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 763, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 763, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 763, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 763, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_8(__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(0, 763, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_6);
    __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_6, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 763, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6);
    __pyx_t_6 = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":764
 *         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(0, 764, __pyx_L1_error)
    }
    __pyx_t_5 = PyObject_GetItem(__pyx_v_broad->values, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":765
 *         for i, t in enumerate(in_types):
 *             x = broad.values[i]
 *             inout_args.append(x if isinstance(x, ndarray) else t(x))             # <<<<<<<<<<<<<<
 *         inout_args.extend(out_args)
 *         inout_args, shape = _reduce_dims(inout_args, self._params, shape)
 */
    __pyx_t_4 = __Pyx_TypeCheck(__pyx_v_x, __pyx_ptype_4cupy_4core_4core_ndarray); 
    if ((__pyx_t_4 != 0)) {
      __Pyx_INCREF(__pyx_v_x);
      __pyx_t_5 = __pyx_v_x;
    } else {
      __Pyx_INCREF(__pyx_v_t);
      __pyx_t_9 = __pyx_v_t; __pyx_t_10 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_x); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 765, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 765, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_x);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 765, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_5 = __pyx_t_2;
      __pyx_t_2 = 0;
    }
    __pyx_t_12 = __Pyx_PyObject_Append(__pyx_v_inout_args, __pyx_t_5); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 765, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":763
 * 
 *         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_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":766
 *             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_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_inout_args, __pyx_n_s_extend); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 766, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_out_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 766, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 766, __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 = NULL;
    __Pyx_INCREF(__pyx_v_out_args);
    __Pyx_GIVEREF(__pyx_v_out_args);
    PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_out_args);
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 766, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":767
 *             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(0, 767, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (!(likely(PyTuple_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_6)->tp_name), 0))) __PYX_ERR(0, 767, __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(0, 767, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__reduce_dims(((PyObject*)__pyx_v_inout_args), ((PyObject*)__pyx_t_6), ((PyObject*)__pyx_v_shape), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    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, 767, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 767, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 767, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 767, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_inout_args, __pyx_t_6);
  __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v_shape, __pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":768
 *         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_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 768, __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 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 768, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":769
 *         inout_args, shape = _reduce_dims(inout_args, self._params, shape)
 *         indexer = Indexer(shape)
 *         inout_args.append(indexer)             # <<<<<<<<<<<<<<
 *         args_info = _get_args_info(inout_args)
 * 
 */
  __pyx_t_12 = __Pyx_PyObject_Append(__pyx_v_inout_args, ((PyObject *)__pyx_v_indexer)); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 769, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":770
 *         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(0, 770, __pyx_L1_error)
  __pyx_t_2 = __pyx_f_4cupy_4core_4core__get_args_info(((PyObject*)__pyx_v_inout_args), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_args_info = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":772
 *         args_info = _get_args_info(inout_args)
 * 
 *         kern = _get_ufunc_kernel(             # <<<<<<<<<<<<<<
 *             in_types, out_types, routine, args_info,
 *             self._params, self.name, self._preamble)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_ufunc_kernel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 772, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":774
 *         kern = _get_ufunc_kernel(
 *             in_types, out_types, routine, args_info,
 *             self._params, self.name, self._preamble)             # <<<<<<<<<<<<<<
 * 
 *         kern.linear_launch(indexer.size, inout_args)
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 774, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 774, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_preamble_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 774, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_11 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_7 = 1;
    }
  }
  __pyx_t_10 = PyTuple_New(7+__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 772, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (__pyx_t_11) {
    __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = NULL;
  }
  __Pyx_INCREF(__pyx_v_in_types);
  __Pyx_GIVEREF(__pyx_v_in_types);
  PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_7, __pyx_v_in_types);
  __Pyx_INCREF(__pyx_v_out_types);
  __Pyx_GIVEREF(__pyx_v_out_types);
  PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_7, __pyx_v_out_types);
  __Pyx_INCREF(__pyx_v_routine);
  __Pyx_GIVEREF(__pyx_v_routine);
  PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_7, __pyx_v_routine);
  __Pyx_INCREF(__pyx_v_args_info);
  __Pyx_GIVEREF(__pyx_v_args_info);
  PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_7, __pyx_v_args_info);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_10, 4+__pyx_t_7, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_10, 5+__pyx_t_7, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_10, 6+__pyx_t_7, __pyx_t_9);
  __pyx_t_6 = 0;
  __pyx_t_5 = 0;
  __pyx_t_9 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 772, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":772
 *         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_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4cuda_8function_Function))))) __PYX_ERR(0, 772, __pyx_L1_error)
  __pyx_v_kern = ((struct __pyx_obj_4cupy_4cuda_8function_Function *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":776
 *             self._params, self.name, self._preamble)
 * 
 *         kern.linear_launch(indexer.size, inout_args)             # <<<<<<<<<<<<<<
 *         return ret
 * 
 */
  __pyx_t_2 = ((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_2)) __PYX_ERR(0, 776, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":777
 * 
 *         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":701
 *         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_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core.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":780
 * 
 * 
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc=''):             # <<<<<<<<<<<<<<
 *     _ops = []
 *     for t in ops:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_29create_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__4);
  PyObject *__pyx_v_doc = ((PyObject *)__pyx_kp_s__4);
  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_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;
        }
      }
    }
  }

  /* "cupy/core/elementwise.pxi":781
 * 
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc=''):
 *     _ops = []             # <<<<<<<<<<<<<<
 *     for t in ops:
 *         if not isinstance(t, tuple):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 781, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__ops = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":782
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc=''):
 *     _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(0, 782, __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, 782, __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_COMPILING_IN_CPYTHON
        __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, 782, __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, 782, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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, 782, __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, 782, __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, 782, __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":783
 *     _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":784
 *     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":785
 *         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":783
 *     _ops = []
 *     for t in ops:
 *         if not isinstance(t, tuple):             # <<<<<<<<<<<<<<
 *             typ = t
 *             rt = routine
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":787
 *             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_CPYTHON
        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, 787, __pyx_L1_error)
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        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(0, 787, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 787, __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(0, 787, __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(0, 787, __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(0, 787, __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":789
 *             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(0, 789, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__54, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 789, __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":790
 * 
 *         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(0, 790, __pyx_L1_error)
    __pyx_t_6 = ((__pyx_t_10 == 1) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/elementwise.pxi":791
 *         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(0, 791, __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":790
 * 
 *         types = typ.split('->')
 *         if len(types) == 1:             # <<<<<<<<<<<<<<
 *             in_types = out_types = tuple(types)
 *         else:
 */
      goto __pyx_L8;
    }

    /* "cupy/core/elementwise.pxi":793
 *             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(0, 793, __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(0, 793, __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_CPYTHON
        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, 793, __pyx_L1_error)
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_8);
        #else
        __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 793, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 793, __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(0, 793, __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(0, 793, __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(0, 793, __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":794
 *         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(0, 794, __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(0, 794, __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(0, 794, __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_COMPILING_IN_CPYTHON
          __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(0, 794, __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(0, 794, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __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(0, 794, __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(0, 794, __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(0, 794, __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(0, 794, __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(0, 794, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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(0, 794, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
      } else {
        __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 794, __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(0, 794, __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(0, 794, __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(0, 794, __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(0, 794, __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":795
 *             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(0, 795, __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(0, 795, __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(0, 795, __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_COMPILING_IN_CPYTHON
          __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(0, 795, __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(0, 795, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __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(0, 795, __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(0, 795, __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(0, 795, __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(0, 795, __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(0, 795, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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(0, 795, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
      } else {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 795, __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(0, 795, __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(0, 795, __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(0, 795, __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(0, 795, __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":796
 *         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 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(0, 796, __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(0, 796, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":782
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc=''):
 *     _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":798
 *         _ops.append((in_types, out_types, rt))
 * 
 *     return ufunc(name, len(_ops[0][0]), len(_ops[0][1]), _ops, preamble, doc)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_ufunc); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_GetItemInt_List(__pyx_v__ops, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_14 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_2 = PyObject_Length(__pyx_t_14); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 798, __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(0, 798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_8 = __Pyx_GetItemInt_List(__pyx_v__ops, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_13 = __Pyx_GetItemInt(__pyx_t_8, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_2 = PyObject_Length(__pyx_t_13); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 798, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_8 = NULL;
  __pyx_t_2 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_2 = 1;
    }
  }
  __pyx_t_11 = PyTuple_New(6+__pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  if (__pyx_t_8) {
    __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_8); __pyx_t_8 = NULL;
  }
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_2, __pyx_v_name);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_2, __pyx_t_14);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_2, __pyx_t_13);
  __Pyx_INCREF(__pyx_v__ops);
  __Pyx_GIVEREF(__pyx_v__ops);
  PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_2, __pyx_v__ops);
  __Pyx_INCREF(__pyx_v_preamble);
  __Pyx_GIVEREF(__pyx_v_preamble);
  PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_2, __pyx_v_preamble);
  __Pyx_INCREF(__pyx_v_doc);
  __Pyx_GIVEREF(__pyx_v_doc);
  PyTuple_SET_ITEM(__pyx_t_11, 5+__pyx_t_2, __pyx_v_doc);
  __pyx_t_14 = 0;
  __pyx_t_13 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":780
 * 
 * 
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc=''):             # <<<<<<<<<<<<<<
 *     _ops = []
 *     for t in 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_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_29create_ufunc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_29create_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_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,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)__pyx_kp_s__4);
    values[4] = ((PyObject *)__pyx_kp_s__4);
    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);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ops)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_ufunc", 0, 2, 5, 1); __PYX_ERR(0, 780, __pyx_L3_error)
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_routine);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_preamble);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_doc);
          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_ufunc") < 0)) __PYX_ERR(0, 780, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        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];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_ufunc", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 780, __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_28create_ufunc(__pyx_self, __pyx_v_name, __pyx_v_ops, __pyx_v_routine, __pyx_v_preamble, __pyx_v_doc);

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

static PyObject *__pyx_pf_4cupy_4core_4core_28create_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_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 = 3;
  __pyx_t_2.routine = __pyx_v_routine;
  __pyx_t_2.preamble = __pyx_v_preamble;
  __pyx_t_2.doc = __pyx_v_doc;
  __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(0, 780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":13
 * 
 * 
 * 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_31_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":17
 *         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":18
 *         type_preamble, input_expr, output_expr, preamble, options):
 *     if identity is None:
 *         identity = ''             # <<<<<<<<<<<<<<
 *     module_code = string.Template('''
 *     ${type_preamble}
 */
    __Pyx_INCREF(__pyx_kp_s__4);
    __Pyx_DECREF_SET(__pyx_v_identity, __pyx_kp_s__4);

    /* "cupy/core/reduction.pxi":17
 *         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":19
 *     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(3, 19, __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(3, 19, __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__55, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":95
 *         }
 *       }
 *     }''').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(3, 95, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":96
 *       }
 *     }''').substitute(
 *         name=name,             # <<<<<<<<<<<<<<
 *         block_size=block_size,
 *         reduce_type=reduce_type,
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 96, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(3, 96, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":97
 *     }''').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(3, 96, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":98
 *         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(3, 96, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":99
 *         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(3, 96, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":100
 *         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(3, 96, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":101
 *         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(3, 96, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":102
 *         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(3, 96, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":103
 *         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(3, 96, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":104
 *         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(3, 96, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":105
 *         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(3, 96, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":106
 *         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(3, 96, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":107
 *         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(3, 96, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":95
 *         }
 *       }
 *     }''').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(3, 95, __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":108
 *         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(3, 108, __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(3, 108, __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(3, 108, __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":109
 *         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(3, 109, __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(3, 109, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":13
 * 
 * 
 * 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_31_get_simple_reduction_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_31_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);
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(3, 13, __pyx_L3_error)
        }
        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(3, 13, __pyx_L3_error)
        }
        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(3, 13, __pyx_L3_error)
        }
        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(3, 13, __pyx_L3_error)
        }
        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(3, 13, __pyx_L3_error)
        }
        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(3, 13, __pyx_L3_error)
        }
        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(3, 13, __pyx_L3_error)
        }
        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(3, 13, __pyx_L3_error)
        }
        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(3, 13, __pyx_L3_error)
        }
        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(3, 13, __pyx_L3_error)
        }
        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(3, 13, __pyx_L3_error)
        }
        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(3, 13, __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(3, 13, __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(3, 13, __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_30_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_30_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(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._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":112
 * 
 * 
 * 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_33_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":114
 * 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":115
 *     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(3, 115, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 115, __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(3, 115, __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(3, 115, __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":114
 * 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":116
 *     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(3, 116, __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(3, 116, __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(3, 116, __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":117
 *         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(3, 117, __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":116
 *     if axis is None:
 *         axis = tuple(range(ndim))
 *     elif isinstance(axis, collections.Sequence):             # <<<<<<<<<<<<<<
 *         axis = tuple(axis)
 *     else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/reduction.pxi":119
 *         axis = tuple(axis)
 *     else:
 *         axis = axis,             # <<<<<<<<<<<<<<
 * 
 *     for dim in axis:
 */
  /*else*/ {
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 119, __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":121
 *         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(3, 121, __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(3, 121, __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_COMPILING_IN_CPYTHON
        __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(3, 121, __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(3, 121, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(3, 121, __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(3, 121, __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(3, 121, __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(3, 121, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_dim = __pyx_t_7;

    /* "cupy/core/reduction.pxi":122
 * 
 *     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":123
 *     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__56, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 123, __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(3, 123, __pyx_L1_error)

      /* "cupy/core/reduction.pxi":122
 * 
 *     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":121
 *         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":124
 *         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(3, 124, __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(3, 124, __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(3, 124, __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_COMPILING_IN_CPYTHON
        __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(3, 124, __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(3, 124, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(3, 124, __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(3, 124, __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(3, 124, __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(3, 124, __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(3, 124, __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(3, 124, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_9))) __PYX_ERR(3, 124, __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(3, 124, __pyx_L1_error)
  if (unlikely(__pyx_t_3 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(3, 124, __pyx_L1_error)
  }
  __pyx_t_4 = PyList_AsTuple(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 124, __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":125
 *             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(3, 125, __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(3, 125, __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(3, 125, __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(3, 125, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_3))) __PYX_ERR(3, 125, __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(3, 125, __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":126
 *     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(3, 126, __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":112
 * 
 * 
 * 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_33_get_axis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_33_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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(3, 112, __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(3, 112, __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(3, 112, __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(3, 112, __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_32_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_32_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(3, 112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._get_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":129
 * 
 * 
 * cpdef tuple _get_out_shape(             # <<<<<<<<<<<<<<
 *         tuple shape, tuple axis, tuple raxis, bint keepdims):
 *     if keepdims:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_35_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":131
 * 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":132
 *         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(3, 132, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_out_shape = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":133
 *     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(3, 133, __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_COMPILING_IN_CPYTHON
      __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(3, 133, __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(3, 133, __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":134
 *         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(3, 134, __pyx_L1_error)

      /* "cupy/core/reduction.pxi":133
 *     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":135
 *         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(3, 135, __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":131
 * 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":136
 *             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(3, 136, __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(3, 136, __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_COMPILING_IN_CPYTHON
    __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(3, 136, __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(3, 136, __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(3, 136, __pyx_L1_error)
    }
    __pyx_t_5 = PyObject_GetItem(__pyx_v_shape, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 136, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) __PYX_ERR(3, 136, __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(3, 136, __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":129
 * 
 * 
 * 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_35_get_out_shape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_35_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);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(3, 129, __pyx_L3_error)
        }
        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(3, 129, __pyx_L3_error)
        }
        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(3, 129, __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(3, 129, __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(3, 130, __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(3, 129, __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(3, 130, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_axis), (&PyTuple_Type), 1, "axis", 1))) __PYX_ERR(3, 130, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_raxis), (&PyTuple_Type), 1, "raxis", 1))) __PYX_ERR(3, 130, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_34_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_34_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(3, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":139
 * 
 * 
 * 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_37_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":141
 * 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(3, 141, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(3, 141, __pyx_L1_error)
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 141, __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(3, 141, __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(3, 141, __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(3, 141, __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(3, 141, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "cupy/core/reduction.pxi":142
 *     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(3, 142, __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":141
 * 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":143
 *     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":144
 *         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(3, 144, __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_COMPILING_IN_CPYTHON
      __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(3, 144, __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(3, 144, __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(3, 144, __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":145
 *     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":146
 *         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__57, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 146, __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(3, 146, __pyx_L1_error)

        /* "cupy/core/reduction.pxi":145
 *     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":144
 *         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":143
 *     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":147
 *             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(3, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/reduction.pxi":148
 *                 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(3, 148, __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_COMPILING_IN_CPYTHON
    __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(3, 148, __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(3, 148, __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":147
 *             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(3, 147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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(3, 147, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
      } else {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 147, __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(3, 147, __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":148
 *                 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(3, 147, __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":149
 *     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(3, 149, __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(3, 149, __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_COMPILING_IN_CPYTHON
    __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(3, 149, __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(3, 149, __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(3, 149, __pyx_L1_error)
    }
    __pyx_t_6 = PyObject_GetItem(__pyx_v_shape, __pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 149, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(3, 149, __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(3, 149, __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":150
 *             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(3, 150, __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":139
 * 
 * 
 * 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_37_get_trans_args(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_37_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);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(3, 139, __pyx_L3_error)
        }
        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(3, 139, __pyx_L3_error)
        }
        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(3, 139, __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(3, 139, __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(3, 139, __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(3, 139, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_trans), (&PyTuple_Type), 1, "trans", 1))) __PYX_ERR(3, 139, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(3, 139, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_params), (&PyTuple_Type), 1, "params", 1))) __PYX_ERR(3, 139, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_36_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_36_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(3, 139, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":153
 * 
 * 
 * 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_39_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":156
 *         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":158
 *     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":157
 *         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(3, 157, __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_CPYTHON
      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(3, 157, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __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(3, 157, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 157, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(3, 157, __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(3, 157, __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":160
 *             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(3, 160, __pyx_L1_error)
    }
    if (unlikely(__pyx_v_in_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(3, 160, __pyx_L1_error)
    }
    __pyx_t_5 = PyList_GET_SIZE(__pyx_v_in_args); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(3, 160, __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(3, 160, __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":159
 *         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(3, 159, __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_CPYTHON
      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(3, 159, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __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(3, 159, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 159, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(3, 159, __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(3, 159, __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":161
 *         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(3, 161, __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":162
 *             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(3, 162, __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":156
 *         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":163
 *         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(3, 163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/reduction.pxi":164
 *         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(3, 164, __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(3, 164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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(3, 164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 164, __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(3, 164, __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":163
 *         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(3, 163, __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(3, 163, __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":165
 *     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":153
 * 
 * 
 * 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_39_get_inout_args(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_39_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);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(3, 153, __pyx_L3_error)
        }
        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(3, 153, __pyx_L3_error)
        }
        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(3, 153, __pyx_L3_error)
        }
        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(3, 153, __pyx_L3_error)
        }
        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(3, 153, __pyx_L3_error)
        }
        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(3, 153, __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(3, 153, __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(3, 155, __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(3, 153, __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(3, 154, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out_args), (&PyList_Type), 1, "out_args", 1))) __PYX_ERR(3, 154, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_in_indexer), __pyx_ptype_4cupy_4core_4core_Indexer, 1, "in_indexer", 0))) __PYX_ERR(3, 154, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out_indexer), __pyx_ptype_4cupy_4core_4core_Indexer, 1, "out_indexer", 0))) __PYX_ERR(3, 154, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_params), (&PyTuple_Type), 1, "params", 1))) __PYX_ERR(3, 155, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_38_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_38_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(3, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":169
 * 
 * @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_41_get_simple_reduction_function(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4cupy_4core_4core_41_get_simple_reduction_function = {"_get_simple_reduction_function", (PyCFunction)__pyx_pw_4cupy_4core_4core_41_get_simple_reduction_function, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4cupy_4core_4core_41_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);
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(3, 169, __pyx_L3_error)
        }
        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(3, 169, __pyx_L3_error)
        }
        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(3, 169, __pyx_L3_error)
        }
        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(3, 169, __pyx_L3_error)
        }
        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(3, 169, __pyx_L3_error)
        }
        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(3, 169, __pyx_L3_error)
        }
        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(3, 169, __pyx_L3_error)
        }
        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(3, 169, __pyx_L3_error)
        }
        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(3, 169, __pyx_L3_error)
        }
        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(3, 169, __pyx_L3_error)
        }
        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(3, 169, __pyx_L3_error)
        }
        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(3, 169, __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(3, 169, __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(3, 169, __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_40_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_40_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":173
 *         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(3, 173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_reduce_type = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":174
 *         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":175
 *     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(3, 175, __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(3, 175, __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":174
 *         options):
 *     reduce_type = routine[3]
 *     if reduce_type is None:             # <<<<<<<<<<<<<<
 *         reduce_type = _get_typename(out_types[0])
 * 
 */
  }

  /* "cupy/core/reduction.pxi":177
 *         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(3, 177, __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(3, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 177, __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":178
 * 
 *     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(3, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_type_preamble = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":180
 *     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(3, 180, __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(3, 180, __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(3, 180, __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":181
 * 
 *     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":183
 *     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(3, 183, __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(3, 183, __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(3, 183, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/reduction.pxi":181
 * 
 *     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(3, 181, __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":169
 * 
 * @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":191
 *     _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 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, 0};
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);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(3, 191, __pyx_L3_error)
        }
        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(3, 191, __pyx_L3_error)
        }
        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(3, 191, __pyx_L3_error)
        }
        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(3, 191, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(3, 191, __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(3, 191, __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":192
 * 
 *     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(3, 192, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":193
 *     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(3, 193, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":194
 *         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(3, 194, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":195
 *         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(3, 195, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":196
 *         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(3, 196, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":197
 *         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(3, 197, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":198
 *         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(3, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__58, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 198, __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":199
 *         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(3, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 199, __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":201
 *         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(3, 201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/reduction.pxi":202
 *         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(3, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/reduction.pxi":203
 *             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__60, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":201
 *         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(3, 201, __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":204
 *             _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(3, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__61, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":203
 *             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(3, 203, __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":200
 *         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(3, 200, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":205
 *                 '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(3, 205, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":206
 *             _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(3, 206, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":207
 *         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, a, axis=None, dtype=None, out=None, keepdims=False):
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 207, __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(3, 207, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":191
 *     _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":209
 *         self._routine_cache = {}
 * 
 *     def __call__(self, a, axis=None, dtype=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         if not isinstance(a, ndarray):
 *             raise TypeError('Input type must be cupy.ndarray')
 */

/* 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 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, 0};
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;
  PyObject *__pyx_v_a = 0;
  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("__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 *)((PyObject *)Py_None));
    values[5] = ((PyObject *)((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);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(3, 209, __pyx_L3_error)
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[4] = value; kw_args--; }
        }
        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(3, 209, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        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 = values[1];
    __pyx_v_axis = values[2];
    __pyx_v_dtype = values[3];
    __pyx_v_out = values[4];
    __pyx_v_keepdims = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 0, 2, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 209, __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:;
  __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);

  /* function exit code */
  __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, PyObject *__pyx_v_a, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_v_in_args = NULL;
  PyObject *__pyx_v_out_args = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  PyObject *__pyx_v_routine = 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_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __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;
  PyObject *__pyx_t_17 = NULL;
  __Pyx_RefNannySetupContext("__call__", 0);
  __Pyx_INCREF(__pyx_v_a);
  __Pyx_INCREF(__pyx_v_axis);
  __Pyx_INCREF(__pyx_v_dtype);
  __Pyx_INCREF(__pyx_v_out);

  /* "cupy/core/reduction.pxi":210
 * 
 *     def __call__(self, a, axis=None, dtype=None, out=None, keepdims=False):
 *         if not isinstance(a, ndarray):             # <<<<<<<<<<<<<<
 *             raise TypeError('Input type must be cupy.ndarray')
 *         if self.identity is None and 0 in a.shape:
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/reduction.pxi":211
 *     def __call__(self, a, axis=None, dtype=None, out=None, keepdims=False):
 *         if not isinstance(a, ndarray):
 *             raise TypeError('Input type must be cupy.ndarray')             # <<<<<<<<<<<<<<
 *         if self.identity is None and 0 in a.shape:
 *             raise ValueError(('zero-size array to reduction operation'
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__62, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 211, __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(3, 211, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":210
 * 
 *     def __call__(self, a, axis=None, dtype=None, out=None, keepdims=False):
 *         if not isinstance(a, ndarray):             # <<<<<<<<<<<<<<
 *             raise TypeError('Input type must be cupy.ndarray')
 *         if self.identity is None and 0 in a.shape:
 */
  }

  /* "cupy/core/reduction.pxi":212
 *         if not isinstance(a, ndarray):
 *             raise TypeError('Input type must be cupy.ndarray')
 *         if self.identity is None and 0 in a.shape:             # <<<<<<<<<<<<<<
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_identity); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = (__pyx_t_3 == Py_None);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = (__pyx_t_1 != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_int_0, __pyx_t_3, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(3, 212, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/reduction.pxi":214
 *         if self.identity is None and 0 in a.shape:
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)             # <<<<<<<<<<<<<<
 *         if dtype is not None:
 *             dtype = numpy.dtype(dtype).type
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 214, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_zero_size_array_to_reduction_ope, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 214, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/reduction.pxi":213
 *             raise TypeError('Input type must be cupy.ndarray')
 *         if self.identity is None and 0 in a.shape:
 *             raise ValueError(('zero-size array to reduction operation'             # <<<<<<<<<<<<<<
 *                               ' %s which has no identity') % self.name)
 *         if dtype is not None:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 213, __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 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 213, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(3, 213, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":212
 *         if not isinstance(a, ndarray):
 *             raise TypeError('Input type must be cupy.ndarray')
 *         if self.identity is None and 0 in a.shape:             # <<<<<<<<<<<<<<
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)
 */
  }

  /* "cupy/core/reduction.pxi":215
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)
 *         if dtype is not None:             # <<<<<<<<<<<<<<
 *             dtype = numpy.dtype(dtype).type
 * 
 */
  __pyx_t_2 = (__pyx_v_dtype != Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":216
 *                               ' %s which has no identity') % self.name)
 *         if dtype is not None:
 *             dtype = numpy.dtype(dtype).type             # <<<<<<<<<<<<<<
 * 
 *         in_args = [a]
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 216, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 216, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 216, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 216, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_dtype);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 216, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 216, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/reduction.pxi":215
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)
 *         if dtype is not None:             # <<<<<<<<<<<<<<
 *             dtype = numpy.dtype(dtype).type
 * 
 */
  }

  /* "cupy/core/reduction.pxi":218
 *             dtype = numpy.dtype(dtype).type
 * 
 *         in_args = [a]             # <<<<<<<<<<<<<<
 *         if out is None:
 *             a = _preprocess_args((a,))[0]
 */
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_a);
  __Pyx_GIVEREF(__pyx_v_a);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_v_a);
  __pyx_v_in_args = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/reduction.pxi":219
 * 
 *         in_args = [a]
 *         if out is None:             # <<<<<<<<<<<<<<
 *             a = _preprocess_args((a,))[0]
 *             out_args = []
 */
  __pyx_t_1 = (__pyx_v_out == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/reduction.pxi":220
 *         in_args = [a]
 *         if out is None:
 *             a = _preprocess_args((a,))[0]             # <<<<<<<<<<<<<<
 *             out_args = []
 *         else:
 */
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 220, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_a);
    __Pyx_GIVEREF(__pyx_v_a);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_a);
    __pyx_t_5 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_t_6, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 220, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_t_5 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(3, 220, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 220, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_a, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/reduction.pxi":221
 *         if out is None:
 *             a = _preprocess_args((a,))[0]
 *             out_args = []             # <<<<<<<<<<<<<<
 *         else:
 *             a, out = _preprocess_args((a, out))
 */
    __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 221, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_out_args = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/reduction.pxi":219
 * 
 *         in_args = [a]
 *         if out is None:             # <<<<<<<<<<<<<<
 *             a = _preprocess_args((a,))[0]
 *             out_args = []
 */
    goto __pyx_L8;
  }

  /* "cupy/core/reduction.pxi":223
 *             out_args = []
 *         else:
 *             a, out = _preprocess_args((a, out))             # <<<<<<<<<<<<<<
 *             out_args = [out]
 * 
 */
  /*else*/ {
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 223, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_a);
    __Pyx_GIVEREF(__pyx_v_a);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_a);
    __Pyx_INCREF(__pyx_v_out);
    __Pyx_GIVEREF(__pyx_v_out);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_out);
    __pyx_t_5 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_t_6, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 223, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (likely(__pyx_t_5 != Py_None)) {
      PyObject* sequence = __pyx_t_5;
      #if CYTHON_COMPILING_IN_CPYTHON
      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(3, 223, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __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(3, 223, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 223, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(3, 223, __pyx_L1_error)
    }
    __Pyx_DECREF_SET(__pyx_v_a, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_out, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/reduction.pxi":224
 *         else:
 *             a, out = _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(3, 224, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_out);
    __Pyx_GIVEREF(__pyx_v_out);
    PyList_SET_ITEM(__pyx_t_5, 0, __pyx_v_out);
    __pyx_v_out_args = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;
  }
  __pyx_L8:;

  /* "cupy/core/reduction.pxi":227
 * 
 *         in_types, out_types, routine = _guess_routine(
 *             self.name, self._routine_cache, self._ops, in_args, dtype)             # <<<<<<<<<<<<<<
 * 
 *         axis, raxis = _get_axis(axis, a.ndim)
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 227, __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(3, 227, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_routine_cache); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 227, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (!(likely(PyDict_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_7)->tp_name), 0))) __PYX_ERR(3, 227, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ops_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 227, __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(3, 227, __pyx_L1_error)
  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(3, 227, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":226
 *             out_args = [out]
 * 
 *         in_types, out_types, routine = _guess_routine(             # <<<<<<<<<<<<<<
 *             self.name, self._routine_cache, self._ops, in_args, dtype)
 * 
 */
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__guess_routine(((PyObject*)__pyx_t_5), ((PyObject*)__pyx_t_7), ((PyObject*)__pyx_t_6), ((PyObject*)__pyx_v_in_args), __pyx_v_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 226, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (likely(__pyx_t_3 != Py_None)) {
    PyObject* sequence = __pyx_t_3;
    #if CYTHON_COMPILING_IN_CPYTHON
    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(3, 226, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 226, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 226, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 226, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(3, 226, __pyx_L1_error)
  }
  __pyx_v_in_types = __pyx_t_6;
  __pyx_t_6 = 0;
  __pyx_v_out_types = __pyx_t_7;
  __pyx_t_7 = 0;
  __pyx_v_routine = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":229
 *             self.name, self._routine_cache, self._ops, in_args, dtype)
 * 
 *         axis, raxis = _get_axis(axis, a.ndim)             # <<<<<<<<<<<<<<
 *         out_shape = _get_out_shape(a.shape, axis, raxis, keepdims)
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 229, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(3, 229, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__get_axis(__pyx_v_axis, __pyx_t_8, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 229, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (likely(__pyx_t_3 != Py_None)) {
    PyObject* sequence = __pyx_t_3;
    #if CYTHON_COMPILING_IN_CPYTHON
    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(3, 229, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_7 = PyTuple_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(3, 229, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 229, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(3, 229, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_v_raxis = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "cupy/core/reduction.pxi":230
 * 
 *         axis, raxis = _get_axis(axis, a.ndim)
 *         out_shape = _get_out_shape(a.shape, axis, raxis, keepdims)             # <<<<<<<<<<<<<<
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 *         if 0 in out_shape:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 230, __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(3, 230, __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(3, 230, __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(3, 230, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_keepdims); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 230, __pyx_L1_error)
  __pyx_t_7 = __pyx_f_4cupy_4core_4core__get_out_shape(((PyObject*)__pyx_t_3), ((PyObject*)__pyx_v_axis), ((PyObject*)__pyx_v_raxis), __pyx_t_2, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_out_shape = ((PyObject*)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/reduction.pxi":231
 *         axis, raxis = _get_axis(axis, a.ndim)
 *         out_shape = _get_out_shape(a.shape, axis, raxis, keepdims)
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')             # <<<<<<<<<<<<<<
 *         if 0 in out_shape:
 *             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(3, 231, __pyx_L1_error)
  __pyx_t_7 = __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_7)) __PYX_ERR(3, 231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF_SET(__pyx_v_out_args, ((PyObject*)__pyx_t_7));
  __pyx_t_7 = 0;

  /* "cupy/core/reduction.pxi":232
 *         out_shape = _get_out_shape(a.shape, axis, raxis, keepdims)
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 *         if 0 in out_shape:             # <<<<<<<<<<<<<<
 *             if len(out_args) == 1:
 *                 return out_args[0]
 */
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_int_0, __pyx_v_out_shape, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(3, 232, __pyx_L1_error)
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":233
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 *         if 0 in out_shape:
 *             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(3, 233, __pyx_L1_error)
    }
    __pyx_t_8 = PyList_GET_SIZE(__pyx_v_out_args); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(3, 233, __pyx_L1_error)
    __pyx_t_1 = ((__pyx_t_8 == 1) != 0);
    if (__pyx_t_1) {

      /* "cupy/core/reduction.pxi":234
 *         if 0 in out_shape:
 *             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(3, 234, __pyx_L1_error)
      }
      __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 234, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_r = __pyx_t_7;
      __pyx_t_7 = 0;
      goto __pyx_L0;

      /* "cupy/core/reduction.pxi":233
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 *         if 0 in out_shape:
 *             if len(out_args) == 1:             # <<<<<<<<<<<<<<
 *                 return out_args[0]
 *             return tuple(out_args)
 */
    }

    /* "cupy/core/reduction.pxi":235
 *             if len(out_args) == 1:
 *                 return out_args[0]
 *             return tuple(out_args)             # <<<<<<<<<<<<<<
 * 
 *         in_args, in_shape = _get_trans_args(
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(3, 235, __pyx_L1_error)
    }
    __pyx_t_7 = PyList_AsTuple(__pyx_v_out_args); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_r = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L0;

    /* "cupy/core/reduction.pxi":232
 *         out_shape = _get_out_shape(a.shape, axis, raxis, keepdims)
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 *         if 0 in out_shape:             # <<<<<<<<<<<<<<
 *             if len(out_args) == 1:
 *                 return out_args[0]
 */
  }

  /* "cupy/core/reduction.pxi":238
 * 
 *         in_args, in_shape = _get_trans_args(
 *             in_args, axis + raxis, in_args[0].shape, None)             # <<<<<<<<<<<<<<
 * 
 *         block_size = self._block_size
 */
  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(3, 238, __pyx_L1_error)
  __pyx_t_7 = PyNumber_Add(__pyx_v_axis, __pyx_v_raxis); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (!(likely(PyTuple_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_7)->tp_name), 0))) __PYX_ERR(3, 238, __pyx_L1_error)
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_in_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  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(3, 238, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":237
 *             return tuple(out_args)
 * 
 *         in_args, in_shape = _get_trans_args(             # <<<<<<<<<<<<<<
 *             in_args, axis + raxis, in_args[0].shape, None)
 * 
 */
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__get_trans_args(((PyObject*)__pyx_v_in_args), ((PyObject*)__pyx_t_7), ((PyObject*)__pyx_t_5), ((PyObject*)Py_None), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 237, __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(__pyx_t_3 != Py_None)) {
    PyObject* sequence = __pyx_t_3;
    #if CYTHON_COMPILING_IN_CPYTHON
    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(3, 237, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_7 = PyTuple_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(3, 237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(3, 237, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_in_args, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_v_in_shape = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "cupy/core/reduction.pxi":240
 *             in_args, axis + raxis, in_args[0].shape, None)
 * 
 *         block_size = self._block_size             # <<<<<<<<<<<<<<
 *         in_indexer = Indexer(in_shape)
 *         out_indexer = Indexer(out_shape)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_block_size_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 240, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_block_size = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":241
 * 
 *         block_size = self._block_size
 *         in_indexer = Indexer(in_shape)             # <<<<<<<<<<<<<<
 *         out_indexer = Indexer(out_shape)
 *         # Rounding Up to the Next Power of 2
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_in_shape);
  __Pyx_GIVEREF(__pyx_v_in_shape);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_in_shape);
  __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_in_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_7);
  __pyx_t_7 = 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_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_v_out_shape);
  __Pyx_GIVEREF(__pyx_v_out_shape);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_out_shape);
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_out_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":245
 *         # Rounding Up to the Next Power of 2
 *         # clp2_count >= in_indexer.size // out_indexer.size
 *         clp2_count = 1 << int.bit_length(             # <<<<<<<<<<<<<<
 *             int(in_indexer.size // out_indexer.size - 1))
 *         block_stride = max(1, block_size // clp2_count)
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyInt_Type)), __pyx_n_s_bit_length); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 245, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "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(3, 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(3, 246, __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(3, 246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 246, __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 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 245, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 245, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 245, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 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_7 = PyNumber_Lshift(__pyx_int_1, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 245, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_clp2_count = __pyx_t_7;
  __pyx_t_7 = 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_7 = PyNumber_FloorDivide(__pyx_v_block_size, __pyx_v_clp2_count); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_10 = 1;
  __pyx_t_9 = __Pyx_PyInt_From_long(__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_7, __pyx_t_9, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 247, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(3, 247, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_1) {
    __Pyx_INCREF(__pyx_t_7);
    __pyx_t_3 = __pyx_t_7;
  } else {
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 247, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __pyx_t_5;
    __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __pyx_t_3;
  __Pyx_INCREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_block_stride = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "cupy/core/reduction.pxi":250
 * 
 *         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)
 */
  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(3, 250, __pyx_L1_error)

  /* "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_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (!(likely(PyTuple_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_7)->tp_name), 0))) __PYX_ERR(3, 251, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":249
 *         block_stride = max(1, block_size // clp2_count)
 * 
 *         inout_args = _get_inout_args(             # <<<<<<<<<<<<<<
 *             in_args, out_args, in_indexer, out_indexer, block_stride,
 *             self._params, True)
 */
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__get_inout_args(((PyObject*)__pyx_v_in_args), __pyx_v_out_args, __pyx_v_in_indexer, __pyx_v_out_indexer, __pyx_v_block_stride, ((PyObject*)__pyx_t_7), 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_inout_args = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":252
 *             in_args, out_args, in_indexer, out_indexer, block_stride,
 *             self._params, True)
 *         args_info = _get_args_info(inout_args)             # <<<<<<<<<<<<<<
 * 
 *         kern = _get_simple_reduction_function(
 */
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__get_args_info(__pyx_v_inout_args, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_args_info = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":254
 *         args_info = _get_args_info(inout_args)
 * 
 *         kern = _get_simple_reduction_function(             # <<<<<<<<<<<<<<
 *             routine, self._params, args_info,
 *             in_args[0].dtype.type, out_args[0].dtype.type, out_types,
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_simple_reduction_function); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 254, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/reduction.pxi":255
 * 
 *         kern = _get_simple_reduction_function(
 *             routine, self._params, args_info,             # <<<<<<<<<<<<<<
 *             in_args[0].dtype.type, out_args[0].dtype.type, out_types,
 *             self.name, block_size, self.identity,
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/reduction.pxi":256
 *         kern = _get_simple_reduction_function(
 *             routine, self._params, args_info,
 *             in_args[0].dtype.type, out_args[0].dtype.type, out_types,             # <<<<<<<<<<<<<<
 *             self.name, block_size, self.identity,
 *             self._input_expr, self._output_expr, self._preamble, ())
 */
  __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_in_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 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(3, 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(3, 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(3, 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(3, 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(3, 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(3, 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(3, 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(3, 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(3, 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(3, 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(3, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_16 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_16)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_16);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
      __pyx_t_8 = 1;
    }
  }
  __pyx_t_17 = PyTuple_New(13+__pyx_t_8); if (unlikely(!__pyx_t_17)) __PYX_ERR(3, 254, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (__pyx_t_16) {
    __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_16); __pyx_t_16 = NULL;
  }
  __Pyx_INCREF(__pyx_v_routine);
  __Pyx_GIVEREF(__pyx_v_routine);
  PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_8, __pyx_v_routine);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_8, __pyx_t_5);
  __Pyx_INCREF(__pyx_v_args_info);
  __Pyx_GIVEREF(__pyx_v_args_info);
  PyTuple_SET_ITEM(__pyx_t_17, 2+__pyx_t_8, __pyx_v_args_info);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_17, 3+__pyx_t_8, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_17, 4+__pyx_t_8, __pyx_t_6);
  __Pyx_INCREF(__pyx_v_out_types);
  __Pyx_GIVEREF(__pyx_v_out_types);
  PyTuple_SET_ITEM(__pyx_t_17, 5+__pyx_t_8, __pyx_v_out_types);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_17, 6+__pyx_t_8, __pyx_t_11);
  __Pyx_INCREF(__pyx_v_block_size);
  __Pyx_GIVEREF(__pyx_v_block_size);
  PyTuple_SET_ITEM(__pyx_t_17, 7+__pyx_t_8, __pyx_v_block_size);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_17, 8+__pyx_t_8, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_17, 9+__pyx_t_8, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_17, 10+__pyx_t_8, __pyx_t_14);
  __Pyx_GIVEREF(__pyx_t_15);
  PyTuple_SET_ITEM(__pyx_t_17, 11+__pyx_t_8, __pyx_t_15);
  __Pyx_INCREF(__pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  PyTuple_SET_ITEM(__pyx_t_17, 12+__pyx_t_8, __pyx_empty_tuple);
  __pyx_t_5 = 0;
  __pyx_t_9 = 0;
  __pyx_t_6 = 0;
  __pyx_t_11 = 0;
  __pyx_t_12 = 0;
  __pyx_t_13 = 0;
  __pyx_t_14 = 0;
  __pyx_t_15 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_17, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 254, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_kern = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":261
 * 
 *         # TODO(okuta) set actual size
 *         shared_mem = 32 * block_size             # <<<<<<<<<<<<<<
 * 
 *         kern.linear_launch(
 */
  __pyx_t_3 = PyNumber_Multiply(__pyx_int_32, __pyx_v_block_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_shared_mem = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":263
 *         shared_mem = 32 * block_size
 * 
 *         kern.linear_launch(             # <<<<<<<<<<<<<<
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,
 *             inout_args, shared_mem, block_size)
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_kern, __pyx_n_s_linear_launch); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "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_17 = PyInt_FromSsize_t(__pyx_v_out_indexer->size); if (unlikely(!__pyx_t_17)) __PYX_ERR(3, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_15 = PyNumber_Add(__pyx_t_17, __pyx_v_block_stride); if (unlikely(!__pyx_t_15)) __PYX_ERR(3, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __pyx_t_17 = __Pyx_PyInt_SubtractObjC(__pyx_t_15, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_17)) __PYX_ERR(3, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_15 = PyNumber_FloorDivide(__pyx_t_17, __pyx_v_block_stride); if (unlikely(!__pyx_t_15)) __PYX_ERR(3, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __pyx_t_17 = PyNumber_Multiply(__pyx_t_15, __pyx_v_block_size); if (unlikely(!__pyx_t_17)) __PYX_ERR(3, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __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_8 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
      __pyx_t_8 = 1;
    }
  }
  __pyx_t_14 = PyTuple_New(4+__pyx_t_8); if (unlikely(!__pyx_t_14)) __PYX_ERR(3, 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_17);
  PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_8, __pyx_t_17);
  __Pyx_INCREF(__pyx_v_inout_args);
  __Pyx_GIVEREF(__pyx_v_inout_args);
  PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_8, __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_8, __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_8, __pyx_v_block_size);
  __pyx_t_17 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":267
 *             inout_args, shared_mem, block_size)
 * 
 *         if len(out_args) == 1:             # <<<<<<<<<<<<<<
 *             return out_args[0]
 *         return tuple(out_args)
 */
  if (unlikely(__pyx_v_out_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(3, 267, __pyx_L1_error)
  }
  __pyx_t_8 = PyList_GET_SIZE(__pyx_v_out_args); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(3, 267, __pyx_L1_error)
  __pyx_t_1 = ((__pyx_t_8 == 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(3, 268, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cupy/core/reduction.pxi":267
 *             inout_args, shared_mem, block_size)
 * 
 *         if len(out_args) == 1:             # <<<<<<<<<<<<<<
 *             return out_args[0]
 *         return tuple(out_args)
 */
  }

  /* "cupy/core/reduction.pxi":269
 *         if len(out_args) == 1:
 *             return out_args[0]
 *         return tuple(out_args)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_out_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(3, 269, __pyx_L1_error)
  }
  __pyx_t_3 = PyList_AsTuple(__pyx_v_out_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":209
 *         self._routine_cache = {}
 * 
 *     def __call__(self, a, axis=None, dtype=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         if not isinstance(a, ndarray):
 *             raise TypeError('Input type must be cupy.ndarray')
 */

  /* 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_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_17);
  __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_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XDECREF(__pyx_v_routine);
  __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_axis);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_out);
  __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_43_get_reduction_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4cupy_4core_4core_43_get_reduction_kernel = {"_get_reduction_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_43_get_reduction_kernel, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4cupy_4core_4core_43_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);
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(3, 273, __pyx_L3_error)
        }
        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(3, 273, __pyx_L3_error)
        }
        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(3, 273, __pyx_L3_error)
        }
        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(3, 273, __pyx_L3_error)
        }
        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(3, 273, __pyx_L3_error)
        }
        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(3, 273, __pyx_L3_error)
        }
        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(3, 273, __pyx_L3_error)
        }
        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(3, 273, __pyx_L3_error)
        }
        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(3, 273, __pyx_L3_error)
        }
        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(3, 273, __pyx_L3_error)
        }
        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(3, 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(3, 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(3, 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_42_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_RefNannyFinishContext();
    return NULL;
  }
  __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); if (unlikely(!gen)) __PYX_ERR(3, 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(3, 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(3, 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(3, 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(3, 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_COMPILING_IN_CPYTHON
        __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(3, 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(3, 282, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(3, 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(3, 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(3, 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_CPYTHON
      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(3, 282, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      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(3, 282, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 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(3, 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(3, 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(3, 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(3, 281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 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(3, 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(3, 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;

  /* "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_42_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;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  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;
  Py_ssize_t __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_RefNannyFinishContext();
    return NULL;
  }
  __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 six_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(3, 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(3, 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(3, 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 six_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(3, 278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_six_zip); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 278, __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_params);
  __Pyx_GIVEREF(__pyx_v_params);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_params);
  __Pyx_INCREF(__pyx_v_args_info);
  __Pyx_GIVEREF(__pyx_v_args_info);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_args_info);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 278, __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(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_7 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 278, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 278, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(3, 278, __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(3, 278, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(3, 278, __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(3, 278, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_7(__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(3, 278, __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_CPYTHON
      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(3, 278, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #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(3, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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_4 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(3, 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(3, 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_4);
    __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":279
 *     kernel_params = _get_kernel_params(params, args_info)
 *     arrays = [p for p, a in six_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_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_raw_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 279, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(3, 279, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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_2 = __Pyx_GetItemInt(__pyx_v_a, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 279, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_12 = (__pyx_t_2 == ((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray));
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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 six_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(3, 278, __pyx_L1_error)

      /* "cupy/core/reduction.pxi":279
 *     kernel_params = _get_kernel_params(params, args_info)
 *     arrays = [p for p, a in six_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 six_zip(params, args_info)             # <<<<<<<<<<<<<<
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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(3, 281, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/reduction.pxi":280
 *     arrays = [p for p, a in six_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_3 = __Pyx_PyString_Join(__pyx_kp_s__44, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_type_preamble = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 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_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "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_5 = 0;
  for (;;) {
    if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(3, 285, __pyx_L1_error)
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 285, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_is_const); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 285, __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(3, 285, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_const_0_1__raw__1__j, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 284, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 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(3, 284, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_13 = NULL;
      __pyx_t_14 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_14 = 1;
        }
      }
      __pyx_t_15 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(3, 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_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_15, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 284, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(3, 284, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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__44, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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(3, 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_3 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
  for (;;) {
    if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __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(3, 288, __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(3, 288, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_is_const); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 288, __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(3, 288, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_0_1__raw__1__i, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 287, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_15)) __PYX_ERR(3, 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(3, 287, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_6 = NULL;
      __pyx_t_14 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && 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_14 = 1;
        }
      }
      __pyx_t_13 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_13)) __PYX_ERR(3, 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_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 287, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) __PYX_ERR(3, 287, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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_3); __pyx_t_3 = 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_3 = __Pyx_PyString_Join(__pyx_kp_s__44, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_output_expr = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 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_3 = __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_3)) __PYX_ERR(3, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 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_4);
  __Pyx_XDECREF(__pyx_t_6);
  __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 PyMethodDef __pyx_mdef_4cupy_4core_4core_15ReductionKernel_1__init__ = {"__init__", (PyCFunction)__pyx_pw_4cupy_4core_4core_15ReductionKernel_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
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=()):
 *         self.in_params = _get_param_info(in_params, True)
 */
    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=()):             # <<<<<<<<<<<<<<
 *         self.in_params = _get_param_info(in_params, True)
 *         self.out_params = _get_param_info(out_params, False)
 */
    values[9] = ((PyObject *)((PyObject *)Py_True));
    values[10] = ((PyObject *)((PyObject*)__pyx_kp_s__4));
    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);
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(3, 327, __pyx_L3_error)
        }
        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(3, 327, __pyx_L3_error)
        }
        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(3, 327, __pyx_L3_error)
        }
        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(3, 327, __pyx_L3_error)
        }
        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(3, 327, __pyx_L3_error)
        }
        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(3, 327, __pyx_L3_error)
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_reduce_type);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_reduce_dims);
          if (value) { values[9] = value; kw_args--; }
        }
        case 10:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_preamble);
          if (value) { values[10] = value; kw_args--; }
        }
        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(3, 327, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        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(3, 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;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/reduction.pxi":331
 *                  identity, name='reduce_kernel', reduce_type=None,
 *                  reduce_dims=True, preamble='', options=()):
 *         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_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_3) {
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  }
  __Pyx_INCREF(__pyx_v_in_params);
  __Pyx_GIVEREF(__pyx_v_in_params);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_in_params);
  __Pyx_INCREF(Py_True);
  __Pyx_GIVEREF(Py_True);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, Py_True);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 331, __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 (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_in_params, __pyx_t_1) < 0) __PYX_ERR(3, 331, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":332
 *                  reduce_dims=True, preamble='', options=()):
 *         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_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_3 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__pyx_t_5) {
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = NULL;
  }
  __Pyx_INCREF(__pyx_v_out_params);
  __Pyx_GIVEREF(__pyx_v_out_params);
  PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_4, __pyx_v_out_params);
  __Pyx_INCREF(Py_False);
  __Pyx_GIVEREF(Py_False);
  PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_4, Py_False);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_out_params, __pyx_t_1) < 0) __PYX_ERR(3, 332, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":333
 *         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(3, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(3, 333, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 333, __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(3, 333, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":334
 *         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(3, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(3, 334, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 334, __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(3, 334, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":335
 *         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(3, 335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nout); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 335, __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 (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nargs, __pyx_t_3) < 0) __PYX_ERR(3, 335, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":337
 *         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 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_params); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_out_params); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 337, __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;

  /* "cupy/core/reduction.pxi":338
 *         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_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__63, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":337
 *         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_2 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 337, __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":339
 *             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_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":338
 *         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 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 338, __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":336
 *         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_3) < 0) __PYX_ERR(3, 336, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":340
 *             _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(3, 340, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":341
 *             _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(3, 341, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":342
 *         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(3, 342, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":343
 *         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(3, 343, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":344
 *         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(3, 344, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":345
 *         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(3, 345, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":346
 *         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(3, 346, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":347
 *         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_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/reduction.pxi":348
 *         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_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_out_params); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 348, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 348, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ctype); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 348, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_reduce_type, __pyx_t_3) < 0) __PYX_ERR(3, 348, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/reduction.pxi":347
 *         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_L3;
  }

  /* "cupy/core/reduction.pxi":350
 *             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(3, 350, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "cupy/core/reduction.pxi":351
 *         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(3, 351, __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_5);
  __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":353
 *         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__[] = "Compiles 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);
        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(3, 353, __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(3, 353, __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;
  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;
  PyObject *__pyx_t_11 = NULL;
  PyObject *(*__pyx_t_12)(PyObject *);
  struct __pyx_opt_args_4cupy_4core_4core__get_out_args_with_params __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  long __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  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;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "cupy/core/reduction.pxi":370
 *         """
 * 
 *         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(3, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__65, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 370, __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":371
 * 
 *         out = kwargs.pop('out', None)
 *         axis = kwargs.pop('axis', None)             # <<<<<<<<<<<<<<
 *         keepdims = kwargs.pop('keepdims', False)
 *         if kwargs:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__66, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 371, __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":372
 *         out = kwargs.pop('out', None)
 *         axis = kwargs.pop('axis', None)
 *         keepdims = kwargs.pop('keepdims', False)             # <<<<<<<<<<<<<<
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 372, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__67, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 372, __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":373
 *         axis = kwargs.pop('axis', None)
 *         keepdims = kwargs.pop('keepdims', False)
 *         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(3, 373, __pyx_L1_error)
  if (__pyx_t_3) {

    /* "cupy/core/reduction.pxi":374
 *         keepdims = kwargs.pop('keepdims', False)
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)             # <<<<<<<<<<<<<<
 * 
 *         n_args = len(args)
 */
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_arguments_s, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 374, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 374, __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(3, 374, __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(3, 374, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":373
 *         axis = kwargs.pop('axis', None)
 *         keepdims = kwargs.pop('keepdims', False)
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  }

  /* "cupy/core/reduction.pxi":376
 *             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(3, 376, __pyx_L1_error)
  __pyx_v_n_args = __pyx_t_4;

  /* "cupy/core/reduction.pxi":377
 * 
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 * 
 */
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_n_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 377, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 377, __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(3, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_5, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 377, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 377, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __pyx_t_6;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_3) {

    /* "cupy/core/reduction.pxi":378
 *         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_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 378, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_number_of_arguments_for_s, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 378, __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(3, 378, __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(3, 378, __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(3, 378, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":377
 * 
 *         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":380
 *             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_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(3, 380, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyTuple_GetSlice(__pyx_v_args, __pyx_t_4, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_out_args = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":381
 * 
 *         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":382
 *         out_args = list(args[self.nin:])
 *         if out is not None:
 *             if self.nout != 1:             # <<<<<<<<<<<<<<
 *                 raise NotImplementedError('')
 *             if len(out_args) != 0:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nout); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 382, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_1, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 382, __pyx_L1_error)
    __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(3, 382, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_6) {

      /* "cupy/core/reduction.pxi":383
 *         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_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__68, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 383, __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(3, 383, __pyx_L1_error)

      /* "cupy/core/reduction.pxi":382
 *         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":384
 *             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(3, 384, __pyx_L1_error)
    __pyx_t_6 = ((__pyx_t_4 != 0) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/reduction.pxi":385
 *                 raise NotImplementedError('')
 *             if len(out_args) != 0:
 *                 raise ValueError("cannot specify 'out' as both "             # <<<<<<<<<<<<<<
 *                                  "a positional and keyword argument")
 *             out_args = [out]
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__69, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 385, __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(3, 385, __pyx_L1_error)

      /* "cupy/core/reduction.pxi":384
 *             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":387
 *                 raise ValueError("cannot specify 'out' as both "
 *                                  "a positional and keyword argument")
 *             out_args = [out]             # <<<<<<<<<<<<<<
 * 
 *         in_args = _preprocess_args(args[:self.nin])
 */
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_out);
    __Pyx_GIVEREF(__pyx_v_out);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_out);
    __Pyx_DECREF_SET(__pyx_v_out_args, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/reduction.pxi":381
 * 
 *         out_args = list(args[self.nin:])
 *         if out is not None:             # <<<<<<<<<<<<<<
 *             if self.nout != 1:
 *                 raise NotImplementedError('')
 */
  }

  /* "cupy/core/reduction.pxi":389
 *             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_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(3, 389, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyTuple_GetSlice(__pyx_v_args, 0, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_in_args = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":390
 * 
 *         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_f_4cupy_4core_4core__preprocess_args(__pyx_v_out_args, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 390, __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/reduction.pxi":391
 *         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(3, 391, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_params); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 391, __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(3, 391, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__broadcast(((PyObject*)__pyx_v_in_args), ((PyObject*)__pyx_t_2), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    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(3, 391, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(3, 391, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_in_args, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_v_broad_shape = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":393
 *         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_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_identity); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 393, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = (__pyx_t_1 == Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_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(3, 393, __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":395
 *         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_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 395, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_zero_size_array_to_reduction_ope, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 395, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/reduction.pxi":394
 * 
 *         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_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 394, __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(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 394, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(3, 394, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":393
 *         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":398
 * 
 *         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(3, 398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/reduction.pxi":399
 *         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_1 = __pyx_v_in_args; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_in_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 399, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(3, 399, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 399, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(3, 399, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 399, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_8(__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(3, 399, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":398
 * 
 *         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(3, 398, __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(3, 398, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_2 = __pyx_t_10;
      __pyx_t_10 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_t_2 = Py_None;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_2))) __PYX_ERR(3, 398, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":399
 *         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_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":397
 *                               ' %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_1 = PyList_AsTuple(((PyObject*)__pyx_t_5)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_in_ndarray_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":401
 *              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_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/reduction.pxi":402
 *         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(3, 402, __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_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(3, 402, __pyx_L1_error)
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 402, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":401
 *              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(3, 401, __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(3, 401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_2 = __pyx_t_9;
      __pyx_t_9 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_t_2 = Py_None;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) __PYX_ERR(3, 401, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":402
 *         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":400
 *             [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_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_out_ndarray_types = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":403
 *             [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_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_decide_params_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/reduction.pxi":404
 *              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_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_params); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_out_params); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "cupy/core/reduction.pxi":405
 *         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_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_11 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 403, __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_2);
  PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_4, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_4, __pyx_t_9);
  __Pyx_INCREF(__pyx_v_in_ndarray_types);
  __Pyx_GIVEREF(__pyx_v_in_ndarray_types);
  PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_4, __pyx_v_in_ndarray_types);
  __Pyx_INCREF(__pyx_v_out_ndarray_types);
  __Pyx_GIVEREF(__pyx_v_out_ndarray_types);
  PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_4, __pyx_v_out_ndarray_types);
  __pyx_t_2 = 0;
  __pyx_t_9 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
    PyObject* sequence = __pyx_t_5;
    #if CYTHON_COMPILING_IN_CPYTHON
    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(3, 403, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_11 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_9 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_t_9);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_9 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 403, __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_2 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_12 = Py_TYPE(__pyx_t_2)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_12(__pyx_t_2); if (unlikely(!__pyx_t_1)) goto __pyx_L17_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_11 = __pyx_t_12(__pyx_t_2); if (unlikely(!__pyx_t_11)) goto __pyx_L17_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_11);
    index = 2; __pyx_t_9 = __pyx_t_12(__pyx_t_2); if (unlikely(!__pyx_t_9)) goto __pyx_L17_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_9);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_2), 3) < 0) __PYX_ERR(3, 403, __pyx_L1_error)
    __pyx_t_12 = NULL;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L18_unpacking_done;
    __pyx_L17_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_12 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(3, 403, __pyx_L1_error)
    __pyx_L18_unpacking_done:;
  }

  /* "cupy/core/reduction.pxi":403
 *             [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_1;
  __pyx_t_1 = 0;
  __pyx_v_out_types = __pyx_t_11;
  __pyx_t_11 = 0;
  __pyx_v_types = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":407
 *             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(3, 407, __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(3, 407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (likely(__pyx_t_5 != Py_None)) {
    PyObject* sequence = __pyx_t_5;
    #if CYTHON_COMPILING_IN_CPYTHON
    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(3, 407, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_t_11);
    #else
    __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(3, 407, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_9);
  __pyx_t_9 = 0;
  __pyx_v_raxis = __pyx_t_11;
  __pyx_t_11 = 0;

  /* "cupy/core/reduction.pxi":408
 * 
 *         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(3, 408, __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(3, 408, __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(3, 408, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_keepdims); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 408, __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(3, 408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_out_shape = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":410
 *         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(3, 410, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_out_params); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 410, __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(3, 410, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":409
 *         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_13.__pyx_n = 1;
  __pyx_t_13.is_size_specified = 0;
  __pyx_t_11 = __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_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF_SET(__pyx_v_out_args, ((PyObject*)__pyx_t_11));
  __pyx_t_11 = 0;

  /* "cupy/core/reduction.pxi":411
 *         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(3, 411, __pyx_L1_error)
  __pyx_t_3 = (__pyx_t_6 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/reduction.pxi":412
 *             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(3, 412, __pyx_L1_error)
    }
    __pyx_t_11 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_r = __pyx_t_11;
    __pyx_t_11 = 0;
    goto __pyx_L0;

    /* "cupy/core/reduction.pxi":411
 *         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":414
 *             return out_args[0]
 * 
 *         in_args = [x if isinstance(x, ndarray) else t(x)             # <<<<<<<<<<<<<<
 *                    for x, t in six_zip(in_args, in_types)]
 *         in_args, in_shape = _get_trans_args(
 */
  __pyx_t_11 = PyList_New(0); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);

  /* "cupy/core/reduction.pxi":415
 * 
 *         in_args = [x if isinstance(x, ndarray) else t(x)
 *                    for x, t in six_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_GetModuleGlobalName(__pyx_n_s_six_zip); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_2 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 415, __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(__pyx_v_in_args);
  __Pyx_GIVEREF(__pyx_v_in_args);
  PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_4, __pyx_v_in_args);
  __Pyx_INCREF(__pyx_v_in_types);
  __Pyx_GIVEREF(__pyx_v_in_types);
  PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_4, __pyx_v_in_types);
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
    __pyx_t_9 = __pyx_t_5; __Pyx_INCREF(__pyx_t_9); __pyx_t_4 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 415, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_8 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 415, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_9))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_9)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(3, 415, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_9, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 415, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(3, 415, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_9, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 415, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_8(__pyx_t_9);
      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(3, 415, __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_CPYTHON
      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(3, 415, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      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(3, 415, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 415, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_10 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 415, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_12 = Py_TYPE(__pyx_t_10)->tp_iternext;
      index = 0; __pyx_t_2 = __pyx_t_12(__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_12(__pyx_t_10); if (unlikely(!__pyx_t_1)) goto __pyx_L22_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_10), 2) < 0) __PYX_ERR(3, 415, __pyx_L1_error)
      __pyx_t_12 = 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_12 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(3, 415, __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":414
 *             return out_args[0]
 * 
 *         in_args = [x if isinstance(x, ndarray) else t(x)             # <<<<<<<<<<<<<<
 *                    for x, t in six_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_5 = __pyx_v_x;
    } else {
      __Pyx_INCREF(__pyx_v_t);
      __pyx_t_2 = __pyx_v_t; __pyx_t_10 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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(3, 414, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(3, 414, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 414, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_5 = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_11, (PyObject*)__pyx_t_5))) __PYX_ERR(3, 414, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/reduction.pxi":415
 * 
 *         in_args = [x if isinstance(x, ndarray) else t(x)
 *                    for x, t in six_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_9); __pyx_t_9 = 0;
  __Pyx_DECREF_SET(__pyx_v_in_args, __pyx_t_11);
  __pyx_t_11 = 0;

  /* "cupy/core/reduction.pxi":417
 *                    for x, t in six_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(3, 417, __pyx_L1_error)
  __pyx_t_11 = PyNumber_Add(__pyx_v_axis, __pyx_v_raxis); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  if (!(likely(PyTuple_CheckExact(__pyx_t_11))||((__pyx_t_11) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_11)->tp_name), 0))) __PYX_ERR(3, 417, __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(3, 417, __pyx_L1_error)
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_params); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (!(likely(PyTuple_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_9)->tp_name), 0))) __PYX_ERR(3, 417, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":416
 *         in_args = [x if isinstance(x, ndarray) else t(x)
 *                    for x, t in six_zip(in_args, in_types)]
 *         in_args, in_shape = _get_trans_args(             # <<<<<<<<<<<<<<
 *             in_args, axis + raxis, broad_shape, self.in_params)
 * 
 */
  __pyx_t_5 = __pyx_f_4cupy_4core_4core__get_trans_args(((PyObject*)__pyx_v_in_args), ((PyObject*)__pyx_t_11), ((PyObject*)__pyx_v_broad_shape), ((PyObject*)__pyx_t_9), 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (likely(__pyx_t_5 != Py_None)) {
    PyObject* sequence = __pyx_t_5;
    #if CYTHON_COMPILING_IN_CPYTHON
    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(3, 416, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_t_11);
    #else
    __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(3, 416, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_in_args, __pyx_t_9);
  __pyx_t_9 = 0;
  __pyx_v_in_shape = __pyx_t_11;
  __pyx_t_11 = 0;

  /* "cupy/core/reduction.pxi":419
 *             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":420
 * 
 *         block_size = 512
 *         in_indexer = Indexer(in_shape)             # <<<<<<<<<<<<<<
 *         out_indexer = Indexer(out_shape)
 *         # Rounding Up to the Next Power of 2
 */
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_in_shape);
  __Pyx_GIVEREF(__pyx_v_in_shape);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_in_shape);
  __pyx_t_11 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_t_5, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_in_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_11);
  __pyx_t_11 = 0;

  /* "cupy/core/reduction.pxi":421
 *         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_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_INCREF(__pyx_v_out_shape);
  __Pyx_GIVEREF(__pyx_v_out_shape);
  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_out_shape);
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_v_out_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":424
 *         # 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_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyInt_Type)), __pyx_n_s_bit_length); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);

  /* "cupy/core/reduction.pxi":425
 *         # 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(3, 425, __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(3, 425, __pyx_L1_error)
  }
  __pyx_t_9 = PyInt_FromSsize_t((__Pyx_div_Py_ssize_t(__pyx_v_in_indexer->size, __pyx_v_out_indexer->size) - 1)); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9);
  __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 424, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 424, __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_9);
    PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/reduction.pxi":424
 *         # 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_11 = PyNumber_Lshift(__pyx_int_1, __pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_clp2_count = __pyx_t_11;
  __pyx_t_11 = 0;

  /* "cupy/core/reduction.pxi":426
 *         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_11 = PyNumber_FloorDivide(__pyx_v_block_size, __pyx_v_clp2_count); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_15 = 1;
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_t_15); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_9 = PyObject_RichCompare(__pyx_t_11, __pyx_t_2, Py_GT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 426, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(3, 426, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (__pyx_t_3) {
    __Pyx_INCREF(__pyx_t_11);
    __pyx_t_5 = __pyx_t_11;
  } else {
    __pyx_t_9 = __Pyx_PyInt_From_long(__pyx_t_15); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 426, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_5 = __pyx_t_9;
    __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __pyx_t_5;
  __Pyx_INCREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_block_stride = __pyx_t_11;
  __pyx_t_11 = 0;

  /* "cupy/core/reduction.pxi":429
 * 
 *         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(3, 429, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":430
 *         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_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  if (!(likely(PyTuple_CheckExact(__pyx_t_11))||((__pyx_t_11) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_11)->tp_name), 0))) __PYX_ERR(3, 430, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reduce_dims); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 430, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":428
 *         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_5 = __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_11), __pyx_t_3, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_v_inout_args = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":431
 *             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_5 = __pyx_f_4cupy_4core_4core__get_args_info(__pyx_v_inout_args, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_args_info = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":433
 *         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_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_reduction_kernel); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);

  /* "cupy/core/reduction.pxi":434
 * 
 *         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_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "cupy/core/reduction.pxi":435
 *         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(3, 435, __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(3, 435, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_identity); if (unlikely(!__pyx_t_14)) __PYX_ERR(3, 435, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);

  /* "cupy/core/reduction.pxi":436
 *             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(3, 436, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reduce_expr); if (unlikely(!__pyx_t_16)) __PYX_ERR(3, 436, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_post_map_expr); if (unlikely(!__pyx_t_17)) __PYX_ERR(3, 436, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);

  /* "cupy/core/reduction.pxi":437
 *             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_18 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_preamble); if (unlikely(!__pyx_t_18)) __PYX_ERR(3, 437, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_options); if (unlikely(!__pyx_t_19)) __PYX_ERR(3, 437, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __pyx_t_20 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_20)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_20);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_21 = PyTuple_New(12+__pyx_t_4); if (unlikely(!__pyx_t_21)) __PYX_ERR(3, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_21);
  if (__pyx_t_20) {
    __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_20); __pyx_t_20 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_21, 0+__pyx_t_4, __pyx_t_9);
  __Pyx_INCREF(__pyx_v_args_info);
  __Pyx_GIVEREF(__pyx_v_args_info);
  PyTuple_SET_ITEM(__pyx_t_21, 1+__pyx_t_4, __pyx_v_args_info);
  __Pyx_INCREF(__pyx_v_types);
  __Pyx_GIVEREF(__pyx_v_types);
  PyTuple_SET_ITEM(__pyx_t_21, 2+__pyx_t_4, __pyx_v_types);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_21, 3+__pyx_t_4, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_block_size);
  __Pyx_GIVEREF(__pyx_v_block_size);
  PyTuple_SET_ITEM(__pyx_t_21, 4+__pyx_t_4, __pyx_v_block_size);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_21, 5+__pyx_t_4, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_21, 6+__pyx_t_4, __pyx_t_14);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_21, 7+__pyx_t_4, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_16);
  PyTuple_SET_ITEM(__pyx_t_21, 8+__pyx_t_4, __pyx_t_16);
  __Pyx_GIVEREF(__pyx_t_17);
  PyTuple_SET_ITEM(__pyx_t_21, 9+__pyx_t_4, __pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_18);
  PyTuple_SET_ITEM(__pyx_t_21, 10+__pyx_t_4, __pyx_t_18);
  __Pyx_GIVEREF(__pyx_t_19);
  PyTuple_SET_ITEM(__pyx_t_21, 11+__pyx_t_4, __pyx_t_19);
  __pyx_t_9 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_14 = 0;
  __pyx_t_10 = 0;
  __pyx_t_16 = 0;
  __pyx_t_17 = 0;
  __pyx_t_18 = 0;
  __pyx_t_19 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_21, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_v_kern = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":440
 * 
 *         # TODO(okuta) set actual size
 *         shared_mem = 32 * block_size             # <<<<<<<<<<<<<<
 * 
 *         kern.linear_launch(
 */
  __pyx_t_5 = PyNumber_Multiply(__pyx_int_32, __pyx_v_block_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_shared_mem = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":442
 *         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_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_kern, __pyx_n_s_linear_launch); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);

  /* "cupy/core/reduction.pxi":443
 * 
 *         kern.linear_launch(
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,             # <<<<<<<<<<<<<<
 *             inout_args, shared_mem, block_size)
 *         return out_args[0]
 */
  __pyx_t_21 = PyInt_FromSsize_t(__pyx_v_out_indexer->size); if (unlikely(!__pyx_t_21)) __PYX_ERR(3, 443, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_21);
  __pyx_t_19 = PyNumber_Add(__pyx_t_21, __pyx_v_block_stride); if (unlikely(!__pyx_t_19)) __PYX_ERR(3, 443, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  __pyx_t_21 = __Pyx_PyInt_SubtractObjC(__pyx_t_19, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_21)) __PYX_ERR(3, 443, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_21);
  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  __pyx_t_19 = PyNumber_FloorDivide(__pyx_t_21, __pyx_v_block_stride); if (unlikely(!__pyx_t_19)) __PYX_ERR(3, 443, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  __pyx_t_21 = PyNumber_Multiply(__pyx_t_19, __pyx_v_block_size); if (unlikely(!__pyx_t_21)) __PYX_ERR(3, 443, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_21);
  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

  /* "cupy/core/reduction.pxi":444
 *         kern.linear_launch(
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,
 *             inout_args, shared_mem, block_size)             # <<<<<<<<<<<<<<
 *         return out_args[0]
 * 
 */
  __pyx_t_19 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_19)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_19);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_18 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_18)) __PYX_ERR(3, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  if (__pyx_t_19) {
    __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_19); __pyx_t_19 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_21);
  PyTuple_SET_ITEM(__pyx_t_18, 0+__pyx_t_4, __pyx_t_21);
  __Pyx_INCREF(__pyx_v_inout_args);
  __Pyx_GIVEREF(__pyx_v_inout_args);
  PyTuple_SET_ITEM(__pyx_t_18, 1+__pyx_t_4, __pyx_v_inout_args);
  __Pyx_INCREF(__pyx_v_shared_mem);
  __Pyx_GIVEREF(__pyx_v_shared_mem);
  PyTuple_SET_ITEM(__pyx_t_18, 2+__pyx_t_4, __pyx_v_shared_mem);
  __Pyx_INCREF(__pyx_v_block_size);
  __Pyx_GIVEREF(__pyx_v_block_size);
  PyTuple_SET_ITEM(__pyx_t_18, 3+__pyx_t_4, __pyx_v_block_size);
  __pyx_t_21 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_18, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":445
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,
 *             inout_args, shared_mem, block_size)
 *         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(3, 445, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":353
 *         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_11);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_16);
  __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_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_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":448
 * 
 * 
 * cpdef create_reduction_func(name, ops, routine=None, identity=None,             # <<<<<<<<<<<<<<
 *                             preamble=''):
 *     _ops = []
 */

static PyObject *__pyx_pw_4cupy_4core_4core_45create_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__4);
  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 *);
  PyObject *__pyx_t_10 = NULL;
  Py_ssize_t __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  __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":450
 * 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(3, 450, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__ops = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":451
 *                             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(3, 451, __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(3, 451, __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_COMPILING_IN_CPYTHON
        __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(3, 451, __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(3, 451, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(3, 451, __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(3, 451, __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(3, 451, __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":452
 *     _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":453
 *     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":454
 *         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":452
 *     _ops = []
 *     for t in ops:
 *         if not isinstance(t, tuple):             # <<<<<<<<<<<<<<
 *             typ = t
 *             rt = routine
 */
      goto __pyx_L5;
    }

    /* "cupy/core/reduction.pxi":456
 *             rt = routine
 *         else:
 *             typ, rt = t             # <<<<<<<<<<<<<<
 *             rt = tuple([i or j for i, j in six_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_CPYTHON
        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(3, 456, __pyx_L1_error)
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        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(3, 456, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 456, __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(3, 456, __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(3, 456, __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(3, 456, __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":457
 *         else:
 *             typ, rt = t
 *             rt = tuple([i or j for i, j in six_zip(rt, routine)])             # <<<<<<<<<<<<<<
 * 
 *         types = typ.split('->')
 */
      __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 457, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_six_zip); if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 457, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_10 = NULL;
      __pyx_t_11 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(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);
          __pyx_t_11 = 1;
        }
      }
      __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 457, __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_rt);
      __Pyx_GIVEREF(__pyx_v_rt);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_v_rt);
      __Pyx_INCREF(__pyx_v_routine);
      __Pyx_GIVEREF(__pyx_v_routine);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_v_routine);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 457, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
        __pyx_t_8 = __pyx_t_4; __Pyx_INCREF(__pyx_t_8); __pyx_t_11 = 0;
        __pyx_t_13 = NULL;
      } else {
        __pyx_t_11 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 457, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_13 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(3, 457, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      for (;;) {
        if (likely(!__pyx_t_13)) {
          if (likely(PyList_CheckExact(__pyx_t_8))) {
            if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_8)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_4 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_11); __Pyx_INCREF(__pyx_t_4); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(3, 457, __pyx_L1_error)
            #else
            __pyx_t_4 = PySequence_ITEM(__pyx_t_8, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 457, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            #endif
          } else {
            if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_11); __Pyx_INCREF(__pyx_t_4); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(3, 457, __pyx_L1_error)
            #else
            __pyx_t_4 = PySequence_ITEM(__pyx_t_8, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 457, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            #endif
          }
        } else {
          __pyx_t_4 = __pyx_t_13(__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(3, 457, __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_CPYTHON
          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(3, 457, __pyx_L1_error)
          }
          #if CYTHON_COMPILING_IN_CPYTHON
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_12 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_12 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_10 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_10);
          #else
          __pyx_t_12 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 457, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 457, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          #endif
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_14 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_14)) __PYX_ERR(3, 457, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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_10 = __pyx_t_9(__pyx_t_14); if (unlikely(!__pyx_t_10)) goto __pyx_L10_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_10);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_14), 2) < 0) __PYX_ERR(3, 457, __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(3, 457, __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_10);
        __pyx_t_10 = 0;
        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_i); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 457, __pyx_L1_error)
        if (!__pyx_t_6) {
        } else {
          __Pyx_INCREF(__pyx_v_i);
          __pyx_t_4 = __pyx_v_i;
          goto __pyx_L12_bool_binop_done;
        }
        __Pyx_INCREF(__pyx_v_j);
        __pyx_t_4 = __pyx_v_j;
        __pyx_L12_bool_binop_done:;
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_7, (PyObject*)__pyx_t_4))) __PYX_ERR(3, 457, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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(3, 457, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF_SET(__pyx_v_rt, __pyx_t_8);
      __pyx_t_8 = 0;
    }
    __pyx_L5:;

    /* "cupy/core/reduction.pxi":459
 *             rt = tuple([i or j for i, j in six_zip(rt, routine)])
 * 
 *         types = typ.split('->')             # <<<<<<<<<<<<<<
 *         if len(types) == 1:
 *             in_types = out_types = tuple(types)
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_typ, __pyx_n_s_split); if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 459, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__70, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 459, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF_SET(__pyx_v_types, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/reduction.pxi":460
 * 
 *         types = typ.split('->')
 *         if len(types) == 1:             # <<<<<<<<<<<<<<
 *             in_types = out_types = tuple(types)
 *         else:
 */
    __pyx_t_11 = PyObject_Length(__pyx_v_types); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(3, 460, __pyx_L1_error)
    __pyx_t_6 = ((__pyx_t_11 == 1) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/reduction.pxi":461
 *         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(3, 461, __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":460
 * 
 *         types = typ.split('->')
 *         if len(types) == 1:             # <<<<<<<<<<<<<<
 *             in_types = out_types = tuple(types)
 *         else:
 */
      goto __pyx_L14;
    }

    /* "cupy/core/reduction.pxi":463
 *             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(3, 463, __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_8 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 463, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
        PyObject* sequence = __pyx_t_8;
        #if CYTHON_COMPILING_IN_CPYTHON
        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(3, 463, __pyx_L1_error)
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_4);
        #else
        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 463, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 463, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_10 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 463, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_10)->tp_iternext;
        index = 0; __pyx_t_7 = __pyx_t_9(__pyx_t_10); if (unlikely(!__pyx_t_7)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        index = 1; __pyx_t_4 = __pyx_t_9(__pyx_t_10); if (unlikely(!__pyx_t_4)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_10), 2) < 0) __PYX_ERR(3, 463, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L16_unpacking_done;
        __pyx_L15_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(3, 463, __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_4);
      __pyx_t_4 = 0;
    }
    __pyx_L14:;

    /* "cupy/core/reduction.pxi":464
 *         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_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (likely(PyList_CheckExact(__pyx_v_in_types)) || PyTuple_CheckExact(__pyx_v_in_types)) {
      __pyx_t_4 = __pyx_v_in_types; __Pyx_INCREF(__pyx_t_4); __pyx_t_11 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_11 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_in_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 464, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_13 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(3, 464, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_13)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_7); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(3, 464, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 464, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        } else {
          if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_7); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(3, 464, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 464, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        }
      } else {
        __pyx_t_7 = __pyx_t_13(__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(3, 464, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 464, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_dtype); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 464, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_t); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 464, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
      } else {
        __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(3, 464, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_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(3, 464, __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(3, 464, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_8, (PyObject*)__pyx_t_12))) __PYX_ERR(3, 464, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 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(3, 464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF_SET(__pyx_v_in_types, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":465
 *             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(3, 465, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (likely(PyList_CheckExact(__pyx_v_out_types)) || PyTuple_CheckExact(__pyx_v_out_types)) {
      __pyx_t_8 = __pyx_v_out_types; __Pyx_INCREF(__pyx_t_8); __pyx_t_11 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_11 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_out_types); if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 465, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_13 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(3, 465, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_13)) {
        if (likely(PyList_CheckExact(__pyx_t_8))) {
          if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_8)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_12 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_11); __Pyx_INCREF(__pyx_t_12); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(3, 465, __pyx_L1_error)
          #else
          __pyx_t_12 = PySequence_ITEM(__pyx_t_8, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 465, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          #endif
        } else {
          if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_11); __Pyx_INCREF(__pyx_t_12); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(3, 465, __pyx_L1_error)
          #else
          __pyx_t_12 = PySequence_ITEM(__pyx_t_8, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 465, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          #endif
        }
      } else {
        __pyx_t_12 = __pyx_t_13(__pyx_t_8);
        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(3, 465, __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(3, 465, __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(3, 465, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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(3, 465, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
      } else {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 465, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_INCREF(__pyx_v_t);
        __Pyx_GIVEREF(__pyx_v_t);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_t);
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_10, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 465, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 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(3, 465, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_14))) __PYX_ERR(3, 465, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 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(3, 465, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_out_types, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/reduction.pxi":466
 *         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_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 466, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v_in_types);
    __Pyx_GIVEREF(__pyx_v_in_types);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_in_types);
    __Pyx_INCREF(__pyx_v_out_types);
    __Pyx_GIVEREF(__pyx_v_out_types);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_out_types);
    __Pyx_INCREF(__pyx_v_rt);
    __Pyx_GIVEREF(__pyx_v_rt);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_v_rt);
    __pyx_t_15 = __Pyx_PyList_Append(__pyx_v__ops, __pyx_t_8); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(3, 466, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/reduction.pxi":451
 *                             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":468
 *         _ops.append((in_types, out_types, rt))
 * 
 *     return simple_reduction_function(name, _ops, identity, preamble)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_simple_reduction_function); if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_4 = NULL;
  __pyx_t_2 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
      __pyx_t_2 = 1;
    }
  }
  __pyx_t_14 = PyTuple_New(4+__pyx_t_2); if (unlikely(!__pyx_t_14)) __PYX_ERR(3, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  if (__pyx_t_4) {
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_4); __pyx_t_4 = NULL;
  }
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_2, __pyx_v_name);
  __Pyx_INCREF(__pyx_v__ops);
  __Pyx_GIVEREF(__pyx_v__ops);
  PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_2, __pyx_v__ops);
  __Pyx_INCREF(__pyx_v_identity);
  __Pyx_GIVEREF(__pyx_v_identity);
  PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_2, __pyx_v_identity);
  __Pyx_INCREF(__pyx_v_preamble);
  __Pyx_GIVEREF(__pyx_v_preamble);
  PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_2, __pyx_v_preamble);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":448
 * 
 * 
 * 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_10);
  __Pyx_XDECREF(__pyx_t_12);
  __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_45create_reduction_func(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_45create_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__4);
    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);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(3, 448, __pyx_L3_error)
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_routine);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_identity);
          if (value) { values[3] = value; kw_args--; }
        }
        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(3, 448, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        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(3, 448, __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_44create_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_44create_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(3, 448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1417
 * 
 * 
 * def elementwise_copy(*args, **kwargs):             # <<<<<<<<<<<<<<
 *     kwargs['casting'] = 'unsafe'
 *     return _elementwise_copy(*args, **kwargs)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_47elementwise_copy(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4cupy_4core_4core_47elementwise_copy = {"elementwise_copy", (PyCFunction)__pyx_pw_4cupy_4core_4core_47elementwise_copy, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4cupy_4core_4core_47elementwise_copy(PyObject *__pyx_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("elementwise_copy (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "elementwise_copy", 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_46elementwise_copy(__pyx_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_46elementwise_copy(CYTHON_UNUSED PyObject *__pyx_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("elementwise_copy", 0);

  /* "cupy/core/core.pyx":1418
 * 
 * def elementwise_copy(*args, **kwargs):
 *     kwargs['casting'] = 'unsafe'             # <<<<<<<<<<<<<<
 *     return _elementwise_copy(*args, **kwargs)
 * 
 */
  if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_n_s_casting, __pyx_n_s_unsafe) < 0)) __PYX_ERR(1, 1418, __pyx_L1_error)

  /* "cupy/core/core.pyx":1419
 * def elementwise_copy(*args, **kwargs):
 *     kwargs['casting'] = 'unsafe'
 *     return _elementwise_copy(*args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1419, __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":1417
 * 
 * 
 * def elementwise_copy(*args, **kwargs):             # <<<<<<<<<<<<<<
 *     kwargs['casting'] = 'unsafe'
 *     return _elementwise_copy(*args, **kwargs)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.elementwise_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":1429
 * 
 * 
 * def elementwise_copy_where(*args, **kwargs):             # <<<<<<<<<<<<<<
 *     kwargs['casting'] = 'unsafe'
 *     return _elementwise_copy_where(*args, **kwargs)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_49elementwise_copy_where(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4cupy_4core_4core_49elementwise_copy_where = {"elementwise_copy_where", (PyCFunction)__pyx_pw_4cupy_4core_4core_49elementwise_copy_where, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4cupy_4core_4core_49elementwise_copy_where(PyObject *__pyx_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("elementwise_copy_where (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "elementwise_copy_where", 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_48elementwise_copy_where(__pyx_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_48elementwise_copy_where(CYTHON_UNUSED PyObject *__pyx_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("elementwise_copy_where", 0);

  /* "cupy/core/core.pyx":1430
 * 
 * def elementwise_copy_where(*args, **kwargs):
 *     kwargs['casting'] = 'unsafe'             # <<<<<<<<<<<<<<
 *     return _elementwise_copy_where(*args, **kwargs)
 * 
 */
  if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_n_s_casting, __pyx_n_s_unsafe) < 0)) __PYX_ERR(1, 1430, __pyx_L1_error)

  /* "cupy/core/core.pyx":1431
 * def elementwise_copy_where(*args, **kwargs):
 *     kwargs['casting'] = 'unsafe'
 *     return _elementwise_copy_where(*args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy_where); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1431, __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":1429
 * 
 * 
 * def elementwise_copy_where(*args, **kwargs):             # <<<<<<<<<<<<<<
 *     kwargs['casting'] = 'unsafe'
 *     return _elementwise_copy_where(*args, **kwargs)
 */

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

/* "cupy/core/core.pyx":1621
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, Py_ssize_t ndmin=0):             # <<<<<<<<<<<<<<
 *     # TODO(beam2d): Support order and subok options
 *     cdef Py_ssize_t nvidem
 */

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);
  Py_ssize_t __pyx_v_ndmin = ((Py_ssize_t)0);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_ndim = NULL;
  PyObject *__pyx_v_a_cpu = 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 = NULL;
  size_t __pyx_t_9;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view __pyx_t_10;
  __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_ndmin = __pyx_optional_args->ndmin;
        }
      }
    }
  }
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/core.pyx":1625
 *     cdef Py_ssize_t nvidem
 *     cdef ndarray a
 *     if isinstance(obj, ndarray):             # <<<<<<<<<<<<<<
 *         if dtype is None:
 *             dtype = obj.dtype
 */
  __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":1626
 *     cdef ndarray a
 *     if isinstance(obj, ndarray):
 *         if dtype is None:             # <<<<<<<<<<<<<<
 *             dtype = obj.dtype
 *         a = obj.astype(dtype, copy)
 */
    __pyx_t_2 = (__pyx_v_dtype == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1627
 *     if isinstance(obj, ndarray):
 *         if dtype is None:
 *             dtype = obj.dtype             # <<<<<<<<<<<<<<
 *         a = obj.astype(dtype, copy)
 * 
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1627, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":1626
 *     cdef ndarray a
 *     if isinstance(obj, ndarray):
 *         if dtype is None:             # <<<<<<<<<<<<<<
 *             dtype = obj.dtype
 *         a = obj.astype(dtype, copy)
 */
    }

    /* "cupy/core/core.pyx":1628
 *         if dtype is None:
 *             dtype = obj.dtype
 *         a = obj.astype(dtype, copy)             # <<<<<<<<<<<<<<
 * 
 *         ndim = a._shape.size()
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_astype); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1628, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_copy); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1628, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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_7 = 1;
      }
    }
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1628, __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_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1628, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 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(1, 1628, __pyx_L1_error)
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1630
 *         a = obj.astype(dtype, copy)
 * 
 *         ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *         if ndmin > ndim:
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 */
    __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_a->_shape.size()); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1630, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_ndim = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1631
 * 
 *         ndim = a._shape.size()
 *         if ndmin > ndim:             # <<<<<<<<<<<<<<
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 *         return a
 */
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ndmin); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_ndim, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1631, __pyx_L1_error)
    __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(1, 1631, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1632
 *         ndim = a._shape.size()
 *         if ndmin > ndim:
 *             a.shape = (1,) * (ndmin - ndim) + a.shape             # <<<<<<<<<<<<<<
 *         return a
 *     else:
 */
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_ndmin); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1632, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_v_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1632, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyNumber_Multiply(__pyx_tuple__71, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1632, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __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(1, 1632, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = PyNumber_Add(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1632, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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(1, 1632, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":1631
 * 
 *         ndim = a._shape.size()
 *         if ndmin > ndim:             # <<<<<<<<<<<<<<
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 *         return a
 */
    }

    /* "cupy/core/core.pyx":1633
 *         if ndmin > ndim:
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 *         return a             # <<<<<<<<<<<<<<
 *     else:
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, ndmin=ndmin)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1625
 *     cdef Py_ssize_t nvidem
 *     cdef ndarray a
 *     if isinstance(obj, ndarray):             # <<<<<<<<<<<<<<
 *         if dtype is None:
 *             dtype = obj.dtype
 */
  }

  /* "cupy/core/core.pyx":1635
 *         return a
 *     else:
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, ndmin=ndmin)             # <<<<<<<<<<<<<<
 *         if a_cpu.dtype.char not in '?bhilqBHILQefd':
 *             raise ValueError('Unsupported dtype %s' % a_cpu.dtype)
 */
  /*else*/ {
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1635, __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(1, 1635, __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(1, 1635, __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_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1635, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 1635, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(1, 1635, __pyx_L1_error)
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_ndmin); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1635, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_ndmin, __pyx_t_5) < 0) __PYX_ERR(1, 1635, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1635, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_a_cpu = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1636
 *     else:
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, ndmin=ndmin)
 *         if a_cpu.dtype.char not in '?bhilqBHILQefd':             # <<<<<<<<<<<<<<
 *             raise ValueError('Unsupported dtype %s' % a_cpu.dtype)
 *         if a_cpu.ndim > 0:
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1636, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_char); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1636, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_t_4, __pyx_kp_s_bhilqBHILQefd, Py_NE)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 1636, __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":1637
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, ndmin=ndmin)
 *         if a_cpu.dtype.char not in '?bhilqBHILQefd':
 *             raise ValueError('Unsupported dtype %s' % a_cpu.dtype)             # <<<<<<<<<<<<<<
 *         if a_cpu.ndim > 0:
 *             a_cpu = numpy.ascontiguousarray(a_cpu)
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1637, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Unsupported_dtype_s, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1637, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1637, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1637, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(1, 1637, __pyx_L1_error)

      /* "cupy/core/core.pyx":1636
 *     else:
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, ndmin=ndmin)
 *         if a_cpu.dtype.char not in '?bhilqBHILQefd':             # <<<<<<<<<<<<<<
 *             raise ValueError('Unsupported dtype %s' % a_cpu.dtype)
 *         if a_cpu.ndim > 0:
 */
    }

    /* "cupy/core/core.pyx":1638
 *         if a_cpu.dtype.char not in '?bhilqBHILQefd':
 *             raise ValueError('Unsupported dtype %s' % a_cpu.dtype)
 *         if a_cpu.ndim > 0:             # <<<<<<<<<<<<<<
 *             a_cpu = numpy.ascontiguousarray(a_cpu)
 *         a = ndarray(a_cpu.shape, dtype=a_cpu.dtype)
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_ndim); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1638, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_5, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1638, __pyx_L1_error)
    __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(1, 1638, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1639
 *             raise ValueError('Unsupported dtype %s' % a_cpu.dtype)
 *         if a_cpu.ndim > 0:
 *             a_cpu = numpy.ascontiguousarray(a_cpu)             # <<<<<<<<<<<<<<
 *         a = ndarray(a_cpu.shape, dtype=a_cpu.dtype)
 *         a.data.copy_from_host(a_cpu.ctypes.data_as(ctypes.c_void_p), a.nbytes)
 */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1639, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ascontiguousarray); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1639, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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_4 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_a_cpu); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1639, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
      } else {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1639, __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 = NULL;
        __Pyx_INCREF(__pyx_v_a_cpu);
        __Pyx_GIVEREF(__pyx_v_a_cpu);
        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_a_cpu);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1639, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF_SET(__pyx_v_a_cpu, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":1638
 *         if a_cpu.dtype.char not in '?bhilqBHILQefd':
 *             raise ValueError('Unsupported dtype %s' % a_cpu.dtype)
 *         if a_cpu.ndim > 0:             # <<<<<<<<<<<<<<
 *             a_cpu = numpy.ascontiguousarray(a_cpu)
 *         a = ndarray(a_cpu.shape, dtype=a_cpu.dtype)
 */
    }

    /* "cupy/core/core.pyx":1640
 *         if a_cpu.ndim > 0:
 *             a_cpu = numpy.ascontiguousarray(a_cpu)
 *         a = ndarray(a_cpu.shape, dtype=a_cpu.dtype)             # <<<<<<<<<<<<<<
 *         a.data.copy_from_host(a_cpu.ctypes.data_as(ctypes.c_void_p), a.nbytes)
 *         if a_cpu.dtype == a.dtype:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1640, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1640, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1640, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1640, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_3) < 0) __PYX_ERR(1, 1640, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1640, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1641
 *             a_cpu = numpy.ascontiguousarray(a_cpu)
 *         a = ndarray(a_cpu.shape, dtype=a_cpu.dtype)
 *         a.data.copy_from_host(a_cpu.ctypes.data_as(ctypes.c_void_p), a.nbytes)             # <<<<<<<<<<<<<<
 *         if a_cpu.dtype == a.dtype:
 *             return a
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_ctypes); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_data_as); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_c_void_p); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1641, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1641, __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_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1641, __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 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_t_8); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1641, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_a->data->__pyx_vtab)->copy_from_host(__pyx_v_a->data, __pyx_t_3, __pyx_t_9, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":1642
 *         a = ndarray(a_cpu.shape, dtype=a_cpu.dtype)
 *         a.data.copy_from_host(a_cpu.ctypes.data_as(ctypes.c_void_p), a.nbytes)
 *         if a_cpu.dtype == a.dtype:             # <<<<<<<<<<<<<<
 *             return a
 *         else:
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1642, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_8, __pyx_v_a->dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1642, __pyx_L1_error)
    __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(1, 1642, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1643
 *         a.data.copy_from_host(a_cpu.ctypes.data_as(ctypes.c_void_p), a.nbytes)
 *         if a_cpu.dtype == a.dtype:
 *             return a             # <<<<<<<<<<<<<<
 *         else:
 *             return a.view(dtype=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":1642
 *         a = ndarray(a_cpu.shape, dtype=a_cpu.dtype)
 *         a.data.copy_from_host(a_cpu.ctypes.data_as(ctypes.c_void_p), a.nbytes)
 *         if a_cpu.dtype == a.dtype:             # <<<<<<<<<<<<<<
 *             return a
 *         else:
 */
    }

    /* "cupy/core/core.pyx":1645
 *             return a
 *         else:
 *             return a.view(dtype=a_cpu.dtype)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    /*else*/ {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1645, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10.__pyx_n = 1;
      __pyx_t_10.dtype = __pyx_t_3;
      __pyx_t_8 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->view(__pyx_v_a, 0, &__pyx_t_10)); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1645, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8);
      __pyx_t_8 = 0;
      goto __pyx_L0;
    }
  }

  /* "cupy/core/core.pyx":1621
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, Py_ssize_t ndmin=0):             # <<<<<<<<<<<<<<
 *     # TODO(beam2d): Support order and subok options
 *     cdef Py_ssize_t nvidem
 */

  /* 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_8);
  __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(__pyx_v_ndim);
  __Pyx_XDECREF(__pyx_v_a_cpu);
  __Pyx_XDECREF(__pyx_v_dtype);
  __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 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;
  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_ndmin,0};
    PyObject* values[4] = {0,0,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  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_copy);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ndmin);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "array") < 0)) __PYX_ERR(1, 1621, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        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(1, 1621, __pyx_L3_error)
    } else {
      __pyx_v_copy = ((int)1);
    }
    if (values[3]) {
      __pyx_v_ndmin = __Pyx_PyIndex_AsSsize_t(values[3]); if (unlikely((__pyx_v_ndmin == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1621, __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, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1621, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_50array(__pyx_self, __pyx_v_obj, __pyx_v_dtype, __pyx_v_copy, __pyx_v_ndmin);

  /* function exit code */
  __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, 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 = 3;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.copy = __pyx_v_copy;
  __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(1, 1621, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1648
 * 
 * 
 * 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;
  Py_ssize_t __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":1649
 * 
 * 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":1650
 * 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":1651
 *     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":1650
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):
 *     if dtype is None:
 *         if a._c_contiguous:             # <<<<<<<<<<<<<<
 *             return a
 *         dtype = a.dtype
 */
    }

    /* "cupy/core/core.pyx":1652
 *         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":1649
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         if a._c_contiguous:
 *             return a
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1654
 *         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(1, 1654, __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, 1654, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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, 1654, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1654, __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, 1654, __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":1655
 *     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(1, 1655, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 1655, __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":1656
 *         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":1655
 *     else:
 *         dtype = numpy.dtype(dtype)
 *         if a._c_contiguous and dtype == a.dtype:             # <<<<<<<<<<<<<<
 *             return a
 * 
 */
    }
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1658
 *             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(1, 1658, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1658, __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(1, 1658, __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":1659
 * 
 *     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(1, 1659, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1659, __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(1, 1659, __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":1660
 *     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":1648
 * 
 * 
 * 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 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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 1648, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        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(1, 1648, __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(1, 1648, __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(1, 1648, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.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":1666
 * # -----------------------------------------------------------------------------
 * 
 * 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_55rollaxis(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":1667
 * 
 * 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(1, 1667, __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(1, 1667, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_2;

  /* "cupy/core/core.pyx":1669
 *     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":1670
 *     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":1669
 *     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":1671
 *     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":1672
 *         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":1671
 *     if axis < 0:
 *         axis += ndim
 *     if start < 0:             # <<<<<<<<<<<<<<
 *         start += ndim
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 */
  }

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

    /* "cupy/core/core.pyx":1673
 *     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":1675
 *     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":1676
 *         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":1675
 *     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":1677
 *     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":1678
 *         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":1677
 *     if axis < start:
 *         start -= 1
 *     if axis == start:             # <<<<<<<<<<<<<<
 *         return a
 *     if ndim == 2:
 */
  }

  /* "cupy/core/core.pyx":1679
 *     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":1680
 *         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(1, 1680, __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":1679
 *     if axis == start:
 *         return a
 *     if ndim == 2:             # <<<<<<<<<<<<<<
 *         return a._transpose(axes)
 * 
 */
  }

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

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

  /* "cupy/core/core.pyx":1686
 *     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(1, 1686, __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":1666
 * # -----------------------------------------------------------------------------
 * 
 * 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_55rollaxis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_55rollaxis(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);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 1666, __pyx_L3_error)
        }
        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(1, 1666, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        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(1, 1666, __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(1, 1666, __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(1, 1666, __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(1, 1666, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_54rollaxis(__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_54rollaxis(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(1, 1666, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1714
 *         readonly Py_ssize_t nd
 * 
 *     def __init__(self, *arrays):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i, j, s, ss, 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_ss;
  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":1719
 *         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__73;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_rev = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1721
 *         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":1722
 * 
 *         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_COMPILING_IN_CPYTHON
    __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(1, 1722, __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, 1722, __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":1723
 *         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":1724
 *         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":1723
 *         self.nd = 0
 *         for x in arrays:
 *             if not isinstance(x, ndarray):             # <<<<<<<<<<<<<<
 *                 continue
 *             a = x
 */
    }

    /* "cupy/core/core.pyx":1725
 *             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(1, 1725, __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":1726
 *                 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":1727
 *             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(1, 1727, __pyx_L1_error)
    }

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

    /* "cupy/core/core.pyx":1722
 * 
 *         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":1730
 *             shape_arr.push_back(r_shape)
 * 
 *         r_shape.clear()             # <<<<<<<<<<<<<<
 *         for i in range(self.nd):
 *             ss = 0
 */
  __pyx_v_r_shape.clear();

  /* "cupy/core/core.pyx":1731
 * 
 *         r_shape.clear()
 *         for i in range(self.nd):             # <<<<<<<<<<<<<<
 *             ss = 0
 *             for j in range(<Py_ssize_t>shape_arr.size()):
 */
  __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":1732
 *         r_shape.clear()
 *         for i in range(self.nd):
 *             ss = 0             # <<<<<<<<<<<<<<
 *             for j in range(<Py_ssize_t>shape_arr.size()):
 *                 if i < <Py_ssize_t>shape_arr[j].size():
 */
    __pyx_v_ss = 0;

    /* "cupy/core/core.pyx":1733
 *         for i in range(self.nd):
 *             ss = 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":1734
 *             ss = 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]
 *                     ss = max(ss, 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":1735
 *             for j in range(<Py_ssize_t>shape_arr.size()):
 *                 if i < <Py_ssize_t>shape_arr[j].size():
 *                     s = shape_arr[j][i]             # <<<<<<<<<<<<<<
 *                     ss = max(ss, s)
 *             r_shape.push_back(ss)
 */
        __pyx_v_s = ((__pyx_v_shape_arr[__pyx_v_j])[__pyx_v_i]);

        /* "cupy/core/core.pyx":1736
 *                 if i < <Py_ssize_t>shape_arr[j].size():
 *                     s = shape_arr[j][i]
 *                     ss = max(ss, s)             # <<<<<<<<<<<<<<
 *             r_shape.push_back(ss)
 * 
 */
        __pyx_t_9 = __pyx_v_s;
        __pyx_t_10 = __pyx_v_ss;
        if (((__pyx_t_9 > __pyx_t_10) != 0)) {
          __pyx_t_11 = __pyx_t_9;
        } else {
          __pyx_t_11 = __pyx_t_10;
        }
        __pyx_v_ss = __pyx_t_11;

        /* "cupy/core/core.pyx":1734
 *             ss = 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]
 *                     ss = max(ss, s)
 */
      }
    }

    /* "cupy/core/core.pyx":1737
 *                     s = shape_arr[j][i]
 *                     ss = max(ss, s)
 *             r_shape.push_back(ss)             # <<<<<<<<<<<<<<
 * 
 *         shape.assign(r_shape.rbegin(), r_shape.rend())
 */
    try {
      __pyx_v_r_shape.push_back(__pyx_v_ss);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(1, 1737, __pyx_L1_error)
    }
  }

  /* "cupy/core/core.pyx":1739
 *             r_shape.push_back(ss)
 * 
 *         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(1, 1739, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":1740
 * 
 *         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(1, 1740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1740, __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":1741
 *         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":1743
 *         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(1, 1743, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_broadcasted = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1744
 * 
 *         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_COMPILING_IN_CPYTHON
    __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(1, 1744, __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(1, 1744, __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":1745
 *         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":1746
 *         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(1, 1746, __pyx_L1_error)

      /* "cupy/core/core.pyx":1747
 *             if not isinstance(x, ndarray):
 *                 broadcasted.append(x)
 *                 continue             # <<<<<<<<<<<<<<
 *             a = x
 *             if internal.vector_equal(a._shape, shape):
 */
      goto __pyx_L11_continue;

      /* "cupy/core/core.pyx":1745
 *         broadcasted = []
 *         for x in arrays:
 *             if not isinstance(x, ndarray):             # <<<<<<<<<<<<<<
 *                 broadcasted.append(x)
 *                 continue
 */
    }

    /* "cupy/core/core.pyx":1748
 *                 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(1, 1748, __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":1749
 *                 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":1750
 *             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(1, 1750, __pyx_L1_error)

      /* "cupy/core/core.pyx":1751
 *             if internal.vector_equal(a._shape, shape):
 *                 broadcasted.append(a)
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *             r_strides.assign(self.nd, <Py_ssize_t>0)
 */
      goto __pyx_L11_continue;

      /* "cupy/core/core.pyx":1749
 *                 continue
 *             a = x
 *             if internal.vector_equal(a._shape, shape):             # <<<<<<<<<<<<<<
 *                 broadcasted.append(a)
 *                 continue
 */
    }

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

    /* "cupy/core/core.pyx":1754
 * 
 *             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":1755
 *             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":1756
 *             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":1757
 *             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":1758
 *                 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":1757
 *             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_L17;
      }

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

        /* "cupy/core/core.pyx":1759
 *                 if a_sh == r_shape[i]:
 *                     r_strides[i] = a._strides[a_ndim - i - 1]
 *                 elif a_sh != 1:             # <<<<<<<<<<<<<<
 *                     raise ValueError('Broadcasting failed')
 * 
 */
      }
      __pyx_L17:;
    }

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

    /* "cupy/core/core.pyx":1763
 * 
 *             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(1, 1763, __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":1764
 *             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(1, 1764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1765
 *             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(1, 1765, __pyx_L1_error)

    /* "cupy/core/core.pyx":1744
 * 
 *         broadcasted = []
 *         for x in arrays:             # <<<<<<<<<<<<<<
 *             if not isinstance(x, ndarray):
 *                 broadcasted.append(x)
 */
    __pyx_L11_continue:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1767
 *             broadcasted.append(view)
 * 
 *         self.values = tuple(broadcasted)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = PyList_AsTuple(__pyx_v_broadcasted); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1767, __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":1714
 *         readonly Py_ssize_t nd
 * 
 *     def __init__(self, *arrays):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i, j, s, ss, 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":1709
 * 
 *     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":1710
 *     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":1711
 *         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(1, 1711, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1712
 *         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(1, 1712, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
}

/* "cupy/core/core.pyx":1770
 * 
 * 
 * cpdef ndarray broadcast_to(ndarray array, shape):             # <<<<<<<<<<<<<<
 *     """Broadcast an array to a given shape.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_57broadcast_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 *);
  size_t __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":1778
 * 
 *     """
 *     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(1, 1778, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_v_shape); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(1, 1778, __pyx_L1_error)
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1778, __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(1, 1778, __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(1, 1778, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":1779
 *     """
 *     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__75, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1779, __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, 1779, __pyx_L1_error)

    /* "cupy/core/core.pyx":1778
 * 
 *     """
 *     if array.ndim > len(shape):             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'input operand has more dimensions than allowed by the axis '
 */
  }

  /* "cupy/core/core.pyx":1783
 *             '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(1, 1783, __pyx_L1_error)
  __pyx_t_4 = PyList_New(1 * ((__pyx_t_2<0) ? 0:__pyx_t_2)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1783, __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":1784
 * 
 *     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(1, 1784, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1784, __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(1, 1784, __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(1, 1784, __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, 1784, __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_COMPILING_IN_CPYTHON
        __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(1, 1784, __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(1, 1784, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(1, 1784, __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(1, 1784, __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(1, 1784, __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":1785
 *     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(1, 1785, __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(1, 1785, __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":1786
 *     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(1, 1786, __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":1787
 *         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(1, 1787, __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(1, 1787, __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":1788
 *         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(1, 1788, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(1, 1788, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_5) {

      /* "cupy/core/core.pyx":1789
 *         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(1, 1789, __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(1, 1789, __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(1, 1789, __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(1, 1789, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(PyObject_SetItem(__pyx_v_strides, __pyx_v_j, __pyx_t_1) < 0)) __PYX_ERR(1, 1789, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":1788
 *         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":1790
 *         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(1, 1790, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(1, 1790, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_5) {

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

      /* "cupy/core/core.pyx":1790
 *         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":1784
 * 
 *     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":1793
 *             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(1, 1793, __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":1794
 * 
 *     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(1, 1794, __pyx_L1_error)
  __pyx_t_9 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_strides); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 1794, __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(1, 1794, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1795
 *     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":1770
 * 
 * 
 * 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_57broadcast_to(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_56broadcast_to[] = "Broadcast 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_57broadcast_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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 1770, __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(1, 1770, __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(1, 1770, __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(1, 1770, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_56broadcast_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_56broadcast_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(1, 1770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1798
 * 
 * 
 * cpdef ndarray _repeat(ndarray a, repeats, axis=None):             # <<<<<<<<<<<<<<
 *     """Repeat arrays along an axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_59_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;
  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;
  size_t __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __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":1813
 *     """
 *     cdef ndarray ret
 *     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":1814
 *     cdef ndarray ret
 *     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(1, 1814, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 1814, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1816
 *         if repeats < 0:
 *             raise ValueError(
 *                 "'repeats' should not be negative: {}".format(repeats))             # <<<<<<<<<<<<<<
 *         if axis is None:
 *             a = a.reshape((-1, 1))
 */
      __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(1, 1816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 1816, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1816, __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(1, 1816, __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":1815
 *     if isinstance(repeats, int):
 *         if repeats < 0:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 "'repeats' should not be negative: {}".format(repeats))
 *         if axis is None:
 */
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1815, __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(1, 1815, __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, 1815, __pyx_L1_error)

      /* "cupy/core/core.pyx":1814
 *     cdef ndarray ret
 *     if isinstance(repeats, int):
 *         if repeats < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 "'repeats' should not be negative: {}".format(repeats))
 */
    }

    /* "cupy/core/core.pyx":1817
 *             raise ValueError(
 *                 "'repeats' should not be negative: {}".format(repeats))
 *         if axis is None:             # <<<<<<<<<<<<<<
 *             a = a.reshape((-1, 1))
 *             ret = ndarray((a.size, repeats), dtype=a.dtype)
 */
    __pyx_t_2 = (__pyx_v_axis == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1818
 *                 "'repeats' should not be negative: {}".format(repeats))
 *         if axis is None:
 *             a = a.reshape((-1, 1))             # <<<<<<<<<<<<<<
 *             ret = ndarray((a.size, repeats), 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(1, 1818, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1818, __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(1, 1818, __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":1819
 *         if axis is None:
 *             a = a.reshape((-1, 1))
 *             ret = ndarray((a.size, repeats), 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(1, 1819, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1819, __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_v_repeats);
      __Pyx_GIVEREF(__pyx_v_repeats);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_repeats);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1819, __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 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1819, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) __PYX_ERR(1, 1819, __pyx_L1_error)
      __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1819, __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_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
      __pyx_t_6 = 0;

      /* "cupy/core/core.pyx":1820
 *             a = a.reshape((-1, 1))
 *             ret = ndarray((a.size, repeats), 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":1821
 *             ret = ndarray((a.size, repeats), dtype=a.dtype)
 *             if ret.size:
 *                 ret[...] = a             # <<<<<<<<<<<<<<
 *             return ret.ravel()
 * 
 */
        if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_ret), Py_Ellipsis, ((PyObject *)__pyx_v_a)) < 0)) __PYX_ERR(1, 1821, __pyx_L1_error)

        /* "cupy/core/core.pyx":1820
 *             a = a.reshape((-1, 1))
 *             ret = ndarray((a.size, repeats), dtype=a.dtype)
 *             if ret.size:             # <<<<<<<<<<<<<<
 *                 ret[...] = a
 *             return ret.ravel()
 */
      }

      /* "cupy/core/core.pyx":1822
 *             if ret.size:
 *                 ret[...] = a
 *             return ret.ravel()             # <<<<<<<<<<<<<<
 * 
 *         repeats = [repeats] * a._shape[axis % a._shape.size()]
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ret->__pyx_vtab)->ravel(__pyx_v_ret, 0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1822, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
      __pyx_t_6 = 0;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":1817
 *             raise ValueError(
 *                 "'repeats' should not be negative: {}".format(repeats))
 *         if axis is None:             # <<<<<<<<<<<<<<
 *             a = a.reshape((-1, 1))
 *             ret = ndarray((a.size, repeats), dtype=a.dtype)
 */
    }

    /* "cupy/core/core.pyx":1824
 *             return ret.ravel()
 * 
 *         repeats = [repeats] * a._shape[axis % a._shape.size()]             # <<<<<<<<<<<<<<
 *     elif cpython.PySequence_Check(repeats):
 *         for rep in repeats:
 */
    __pyx_t_6 = __Pyx_PyInt_FromSize_t(__pyx_v_a->_shape.size()); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1824, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyNumber_Remainder(__pyx_v_axis, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1824, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = __Pyx_PyInt_As_size_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1824, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyList_New(1 * (((__pyx_v_a->_shape[__pyx_t_7])<0) ? 0:(__pyx_v_a->_shape[__pyx_t_7]))); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1824, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    { Py_ssize_t __pyx_temp;
      for (__pyx_temp=0; __pyx_temp < (__pyx_v_a->_shape[__pyx_t_7]); __pyx_temp++) {
        __Pyx_INCREF(__pyx_v_repeats);
        __Pyx_GIVEREF(__pyx_v_repeats);
        PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_v_repeats);
      }
    }
    __Pyx_DECREF_SET(__pyx_v_repeats, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1813
 *     """
 *     cdef ndarray ret
 *     if isinstance(repeats, int):             # <<<<<<<<<<<<<<
 *         if repeats < 0:
 *             raise ValueError(
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1825
 * 
 *         repeats = [repeats] * a._shape[axis % a._shape.size()]
 *     elif cpython.PySequence_Check(repeats):             # <<<<<<<<<<<<<<
 *         for rep in repeats:
 *             if rep < 0:
 */
  __pyx_t_1 = (PySequence_Check(__pyx_v_repeats) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1826
 *         repeats = [repeats] * a._shape[axis % a._shape.size()]
 *     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_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_repeats); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1826, __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(1, 1826, __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_COMPILING_IN_CPYTHON
          __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 1826, __pyx_L1_error)
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1826, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 1826, __pyx_L1_error)
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1826, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        }
      } else {
        __pyx_t_6 = __pyx_t_9(__pyx_t_3);
        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, 1826, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_XDECREF_SET(__pyx_v_rep, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "cupy/core/core.pyx":1827
 *     elif cpython.PySequence_Check(repeats):
 *         for rep in repeats:
 *             if rep < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     "all elements of 'repeats' should not be negative: {}"
 */
      __pyx_t_6 = PyObject_RichCompare(__pyx_v_rep, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1827, __pyx_L1_error)
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 1827, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":1830
 *                 raise ValueError(
 *                     "all elements of 'repeats' should not be negative: {}"
 *                     .format(repeats))             # <<<<<<<<<<<<<<
 *         if axis is None:
 *             raise ValueError(
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_all_elements_of_repeats_should_n, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1830, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && 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_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_repeats); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1830, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
        } else {
          __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 1830, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); __pyx_t_5 = NULL;
          __Pyx_INCREF(__pyx_v_repeats);
          __Pyx_GIVEREF(__pyx_v_repeats);
          PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_repeats);
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1830, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "cupy/core/core.pyx":1828
 *         for rep in repeats:
 *             if rep < 0:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     "all elements of 'repeats' should not be negative: {}"
 *                     .format(repeats))
 */
        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1828, __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 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1828, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_Raise(__pyx_t_6, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __PYX_ERR(1, 1828, __pyx_L1_error)

        /* "cupy/core/core.pyx":1827
 *     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":1826
 *         repeats = [repeats] * a._shape[axis % a._shape.size()]
 *     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":1831
 *                     "all elements of 'repeats' should not be negative: {}"
 *                     .format(repeats))
 *         if axis is None:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 "'axis' should be specified if 'repeats' is sequence")
 */
    __pyx_t_1 = (__pyx_v_axis == Py_None);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1832
 *                     .format(repeats))
 *         if axis is None:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 "'axis' should be specified if 'repeats' is sequence")
 *         if a.shape[axis] != len(repeats):
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1832, __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, 1832, __pyx_L1_error)

      /* "cupy/core/core.pyx":1831
 *                     "all elements of 'repeats' should not be negative: {}"
 *                     .format(repeats))
 *         if axis is None:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 "'axis' should be specified if 'repeats' is sequence")
 */
    }

    /* "cupy/core/core.pyx":1834
 *             raise ValueError(
 *                 "'axis' should be specified if 'repeats' is sequence")
 *         if a.shape[axis] != len(repeats):             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 "'repeats' and 'axis' of 'a' should be same length: {} != {}"
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1834, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyObject_GetItem(__pyx_t_3, __pyx_v_axis); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1834, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = PyObject_Length(__pyx_v_repeats); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(1, 1834, __pyx_L1_error)
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1834, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_6, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1834, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 1834, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1837
 *             raise ValueError(
 *                 "'repeats' and 'axis' of 'a' should be same length: {} != {}"
 *                 .format(a.shape[axis], len(repeats)))             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError(
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_repeats_and_axis_of_a_should_be, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_10 = PyObject_GetItem(__pyx_t_6, __pyx_v_axis); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 1837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = PyObject_Length(__pyx_v_repeats); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(1, 1837, __pyx_L1_error)
      __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && 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);
          __pyx_t_8 = 1;
        }
      }
      __pyx_t_11 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 1837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_8, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_8, __pyx_t_6);
      __pyx_t_10 = 0;
      __pyx_t_6 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":1835
 *                 "'axis' should be specified if 'repeats' is sequence")
 *         if a.shape[axis] != len(repeats):
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 "'repeats' and 'axis' of 'a' should be same length: {} != {}"
 *                 .format(a.shape[axis], len(repeats)))
 */
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1835, __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_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1835, __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, 1835, __pyx_L1_error)

      /* "cupy/core/core.pyx":1834
 *             raise ValueError(
 *                 "'axis' should be specified if 'repeats' is sequence")
 *         if a.shape[axis] != len(repeats):             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 "'repeats' and 'axis' of 'a' should be same length: {} != {}"
 */
    }

    /* "cupy/core/core.pyx":1825
 * 
 *         repeats = [repeats] * a._shape[axis % a._shape.size()]
 *     elif cpython.PySequence_Check(repeats):             # <<<<<<<<<<<<<<
 *         for rep in repeats:
 *             if rep < 0:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1839
 *                 .format(a.shape[axis], len(repeats)))
 *     else:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             "'repeats' should be int or sequence: {}".format(repeats))
 * 
 */
  /*else*/ {

    /* "cupy/core/core.pyx":1840
 *     else:
 *         raise ValueError(
 *             "'repeats' should be int or sequence: {}".format(repeats))             # <<<<<<<<<<<<<<
 * 
 *     if axis < 0:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_repeats_should_be_int_or_sequen, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1840, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_repeats); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1840, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1840, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_11); __pyx_t_11 = NULL;
      __Pyx_INCREF(__pyx_v_repeats);
      __Pyx_GIVEREF(__pyx_v_repeats);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_repeats);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1840, __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;

    /* "cupy/core/core.pyx":1839
 *                 .format(a.shape[axis], len(repeats)))
 *     else:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             "'repeats' should be int or sequence: {}".format(repeats))
 * 
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1839, __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_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1839, __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, 1839, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1842
 *             "'repeats' should be int or sequence: {}".format(repeats))
 * 
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += a.ndim
 * 
 */
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1842, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 1842, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1843
 * 
 *     if axis < 0:
 *         axis += a.ndim             # <<<<<<<<<<<<<<
 * 
 *     ret_shape = list(a.shape)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1843, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_axis, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1843, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1842
 *             "'repeats' should be int or sequence: {}".format(repeats))
 * 
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += a.ndim
 * 
 */
  }

  /* "cupy/core/core.pyx":1845
 *         axis += a.ndim
 * 
 *     ret_shape = list(a.shape)             # <<<<<<<<<<<<<<
 *     ret_shape[axis] = sum(repeats)
 *     ret = ndarray(ret_shape, dtype=a.dtype)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_ret_shape = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":1846
 * 
 *     ret_shape = list(a.shape)
 *     ret_shape[axis] = sum(repeats)             # <<<<<<<<<<<<<<
 *     ret = ndarray(ret_shape, dtype=a.dtype)
 *     a_index = [slice(None)] * len(ret_shape)
 */
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1846, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_repeats);
  __Pyx_GIVEREF(__pyx_v_repeats);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_repeats);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1846, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(PyObject_SetItem(__pyx_v_ret_shape, __pyx_v_axis, __pyx_t_3) < 0)) __PYX_ERR(1, 1846, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1847
 *     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_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1847, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_ret_shape);
  __Pyx_GIVEREF(__pyx_v_ret_shape);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_ret_shape);
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1847, __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(1, 1847, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1847, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":1848
 *     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_8 = PyList_GET_SIZE(__pyx_v_ret_shape); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(1, 1848, __pyx_L1_error)
  __pyx_t_6 = PyList_New(1 * ((__pyx_t_8<0) ? 0:__pyx_t_8)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1848, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  { Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < __pyx_t_8; __pyx_temp++) {
      __Pyx_INCREF(__pyx_slice__80);
      __Pyx_GIVEREF(__pyx_slice__80);
      PyList_SET_ITEM(__pyx_t_6, __pyx_temp, __pyx_slice__80);
    }
  }
  __pyx_v_a_index = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":1849
 *     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_6 = PySequence_List(__pyx_v_a_index); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1849, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_ret_index = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":1850
 *     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":1851
 *     ret_index = list(a_index)
 *     offset = 0
 *     for i in range(a._shape[axis]):             # <<<<<<<<<<<<<<
 *         if repeats[i] == 0:
 *             continue
 */
  __pyx_t_7 = __Pyx_PyInt_As_size_t(__pyx_v_axis); if (unlikely((__pyx_t_7 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1851, __pyx_L1_error)
  __pyx_t_6 = PyInt_FromSsize_t((__pyx_v_a->_shape[__pyx_t_7])); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1851, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1851, __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 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1851, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(PyList_CheckExact(__pyx_t_6)) || PyTuple_CheckExact(__pyx_t_6)) {
    __pyx_t_4 = __pyx_t_6; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1851, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1851, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  for (;;) {
    if (likely(!__pyx_t_9)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 1851, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1851, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 1851, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1851, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_9(__pyx_t_4);
      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, 1851, __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":1852
 *     offset = 0
 *     for i in range(a._shape[axis]):
 *         if repeats[i] == 0:             # <<<<<<<<<<<<<<
 *             continue
 *         a_index[axis] = slice(i, i + 1)
 */
    __pyx_t_6 = PyObject_GetItem(__pyx_v_repeats, __pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1852, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_6, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1852, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 1852, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1853
 *     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_L13_continue;

      /* "cupy/core/core.pyx":1852
 *     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":1854
 *         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_3 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1854, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PySlice_New(__pyx_v_i, __pyx_t_3, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1854, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(PyObject_SetItem(__pyx_v_a_index, __pyx_v_axis, __pyx_t_6) < 0)) __PYX_ERR(1, 1854, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":1855
 *             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_6 = PyObject_GetItem(__pyx_v_repeats, __pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyNumber_Add(__pyx_v_offset, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PySlice_New(__pyx_v_offset, __pyx_t_3, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(PyObject_SetItem(__pyx_v_ret_index, __pyx_v_axis, __pyx_t_6) < 0)) __PYX_ERR(1, 1855, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":1857
 *         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_6 = PyList_AsTuple(__pyx_v_a_index); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1857, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1857, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyList_AsTuple(__pyx_v_ret_index); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1857, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_ret), __pyx_t_6, __pyx_t_3) < 0)) __PYX_ERR(1, 1857, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1858
 *         # convert to tuple because cupy has a indexing bug
 *         ret[tuple(ret_index)] = a[tuple(a_index)]
 *         offset += repeats[i]             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
    __pyx_t_3 = PyObject_GetItem(__pyx_v_repeats, __pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1858, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_offset, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1858, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_offset, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":1851
 *     ret_index = list(a_index)
 *     offset = 0
 *     for i in range(a._shape[axis]):             # <<<<<<<<<<<<<<
 *         if repeats[i] == 0:
 *             continue
 */
    __pyx_L13_continue:;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":1859
 *         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":1798
 * 
 * 
 * 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_10);
  __Pyx_XDECREF(__pyx_t_11);
  __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_59_repeat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_58_repeat[] = "Repeat 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_59_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);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 1798, __pyx_L3_error)
        }
        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(1, 1798, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        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(1, 1798, __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(1, 1798, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_58_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_58_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(1, 1798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1862
 * 
 * 
 * cpdef ndarray concatenate(tup, axis, shape, dtype):             # <<<<<<<<<<<<<<
 *     cdef ndarray ret
 *     ret = ndarray(shape, dtype=dtype)
 */

static PyObject *__pyx_pw_4cupy_4core_4core_61concatenate(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_ret = 0;
  PyObject *__pyx_v_skip = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_a = 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 *);
  __Pyx_RefNannySetupContext("concatenate", 0);

  /* "cupy/core/core.pyx":1864
 * cpdef ndarray concatenate(tup, axis, shape, dtype):
 *     cdef ndarray ret
 *     ret = ndarray(shape, dtype=dtype)             # <<<<<<<<<<<<<<
 * 
 *     skip = (slice(None),) * axis
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1864, __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(1, 1864, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 1864, __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(1, 1864, __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":1866
 *     ret = ndarray(shape, dtype=dtype)
 * 
 *     skip = (slice(None),) * axis             # <<<<<<<<<<<<<<
 *     i = 0
 *     for a in tup:
 */
  __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__82, __pyx_v_axis); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1866, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_skip = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1867
 * 
 *     skip = (slice(None),) * axis
 *     i = 0             # <<<<<<<<<<<<<<
 *     for a in tup:
 *         aw = a.shape[axis]
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_i = __pyx_int_0;

  /* "cupy/core/core.pyx":1868
 *     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_3 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1868, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1868, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 1868, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1868, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 1868, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1868, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 1868, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":1869
 *     i = 0
 *     for a in tup:
 *         aw = a.shape[axis]             # <<<<<<<<<<<<<<
 *         ret[skip + (slice(i, i + aw),)] = a
 *         i += aw
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1869, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_GetItem(__pyx_t_2, __pyx_v_axis); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1869, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_aw, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1870
 *     for a in tup:
 *         aw = a.shape[axis]
 *         ret[skip + (slice(i, i + aw),)] = a             # <<<<<<<<<<<<<<
 *         i += aw
 * 
 */
    __pyx_t_1 = PyNumber_Add(__pyx_v_i, __pyx_v_aw); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1870, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySlice_New(__pyx_v_i, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1870, __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(1, 1870, __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_Add(__pyx_v_skip, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1870, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_ret), __pyx_t_2, __pyx_v_a) < 0)) __PYX_ERR(1, 1870, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":1871
 *         aw = a.shape[axis]
 *         ret[skip + (slice(i, i + aw),)] = a
 *         i += aw             # <<<<<<<<<<<<<<
 * 
 *     return ret
 */
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_i, __pyx_v_aw); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1871, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_i, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":1868
 *     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_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1873
 *         i += aw
 * 
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * # -----------------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1862
 * 
 * 
 * cpdef ndarray concatenate(tup, axis, shape, dtype):             # <<<<<<<<<<<<<<
 *     cdef ndarray ret
 *     ret = ndarray(shape, dtype=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.concatenate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_skip);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_aw);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_61concatenate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_61concatenate(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);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 1862, __pyx_L3_error)
        }
        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(1, 1862, __pyx_L3_error)
        }
        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(1, 1862, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "concatenate") < 0)) __PYX_ERR(1, 1862, __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(1, 1862, __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_60concatenate(__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_60concatenate(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(1, 1862, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1879
 * # -----------------------------------------------------------------------------
 * 
 * cpdef _create_bit_op(name, op, no_bool, doc=''):             # <<<<<<<<<<<<<<
 *     types = () if no_bool else ('??->?',)
 *     return create_ufunc(
 */

static PyObject *__pyx_pw_4cupy_4core_4core_63_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__4);
  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":1880
 * 
 * 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(1, 1880, __pyx_L1_error)
  if (__pyx_t_2) {
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_t_1 = __pyx_empty_tuple;
  } else {
    __Pyx_INCREF(__pyx_tuple__84);
    __pyx_t_1 = __pyx_tuple__84;
  }
  __pyx_v_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1881
 * 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(1, 1881, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":1882
 *     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, __pyx_v_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1882, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/core.pyx":1883
 *     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__85); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":1885
 *         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(1, 1885, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/core.pyx":1881
 * 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(1, 1881, __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":1886
 *                  '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(1, 1886, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_doc, __pyx_v_doc) < 0) __PYX_ERR(1, 1886, __pyx_L1_error)

  /* "cupy/core/core.pyx":1881
 * 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(1, 1881, __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":1879
 * # -----------------------------------------------------------------------------
 * 
 * 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_63_create_bit_op(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_63_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__4);
    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);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 1879, __pyx_L3_error)
        }
        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(1, 1879, __pyx_L3_error)
        }
        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(1, 1879, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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(1, 1879, __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_62_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_62_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(1, 1879, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1994
 * 
 * 
 * cpdef ndarray _boolean_array_indexing(ndarray a, ndarray boolean_array):             # <<<<<<<<<<<<<<
 *     a = a.flatten()
 *     boolean_array = boolean_array.flatten()
 */

static PyObject *__pyx_pw_4cupy_4core_4core_65_boolean_array_indexing(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__boolean_array_indexing(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_boolean_array, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_nth_true_array = NULL;
  PyObject *__pyx_v_n_true = NULL;
  PyObject *__pyx_v_out_shape = NULL;
  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;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("_boolean_array_indexing", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF((PyObject *)__pyx_v_boolean_array);

  /* "cupy/core/core.pyx":1995
 * 
 * cpdef ndarray _boolean_array_indexing(ndarray a, ndarray boolean_array):
 *     a = a.flatten()             # <<<<<<<<<<<<<<
 *     boolean_array = boolean_array.flatten()
 *     nth_true_array = scan(boolean_array.astype(int)) - 1  # starts with 0
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->flatten(__pyx_v_a, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1995, __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":1996
 * cpdef ndarray _boolean_array_indexing(ndarray a, ndarray boolean_array):
 *     a = a.flatten()
 *     boolean_array = boolean_array.flatten()             # <<<<<<<<<<<<<<
 *     nth_true_array = scan(boolean_array.astype(int)) - 1  # starts with 0
 * 
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_boolean_array->__pyx_vtab)->flatten(__pyx_v_boolean_array, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1996, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_boolean_array, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1997
 *     a = a.flatten()
 *     boolean_array = boolean_array.flatten()
 *     nth_true_array = scan(boolean_array.astype(int)) - 1  # starts with 0             # <<<<<<<<<<<<<<
 * 
 *     n_true = int(nth_true_array.max()) + 1
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_scan); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_boolean_array->__pyx_vtab)->astype(__pyx_v_boolean_array, ((PyObject *)(&PyInt_Type)), 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1997, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1997, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1997, __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_2 = __Pyx_PyInt_SubtractObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_nth_true_array = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":1999
 *     nth_true_array = scan(boolean_array.astype(int)) - 1  # starts with 0
 * 
 *     n_true = int(nth_true_array.max()) + 1             # <<<<<<<<<<<<<<
 *     out_shape = (n_true,)
 *     out = ndarray(out_shape, dtype=a.dtype)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_nth_true_array, __pyx_n_s_max); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1999, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1999, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1999, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1999, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1999, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n_true = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2000
 * 
 *     n_true = int(nth_true_array.max()) + 1
 *     out_shape = (n_true,)             # <<<<<<<<<<<<<<
 *     out = ndarray(out_shape, dtype=a.dtype)
 * 
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2000, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_n_true);
  __Pyx_GIVEREF(__pyx_v_n_true);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_n_true);
  __pyx_v_out_shape = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2001
 *     n_true = int(nth_true_array.max()) + 1
 *     out_shape = (n_true,)
 *     out = ndarray(out_shape, dtype=a.dtype)             # <<<<<<<<<<<<<<
 * 
 *     return _boolean_array_indexing_nth(a, boolean_array, nth_true_array, out)
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_out_shape);
  __Pyx_GIVEREF(__pyx_v_out_shape);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_out_shape);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) __PYX_ERR(1, 2001, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2001, __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_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2003
 *     out = ndarray(out_shape, dtype=a.dtype)
 * 
 *     return _boolean_array_indexing_nth(a, boolean_array, nth_true_array, out)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__boolean_array_indexing_nth);
  __pyx_t_1 = __pyx_v_4cupy_4core_4core__boolean_array_indexing_nth; __pyx_t_2 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_6 = 1;
    }
  }
  __pyx_t_3 = PyTuple_New(4+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2003, __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(((PyObject *)__pyx_v_a));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
  PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_6, ((PyObject *)__pyx_v_a));
  __Pyx_INCREF(((PyObject *)__pyx_v_boolean_array));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_boolean_array));
  PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_6, ((PyObject *)__pyx_v_boolean_array));
  __Pyx_INCREF(__pyx_v_nth_true_array);
  __Pyx_GIVEREF(__pyx_v_nth_true_array);
  PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_6, __pyx_v_nth_true_array);
  __Pyx_INCREF(((PyObject *)__pyx_v_out));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
  PyTuple_SET_ITEM(__pyx_t_3, 3+__pyx_t_6, ((PyObject *)__pyx_v_out));
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2003, __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;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 2003, __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":1994
 * 
 * 
 * cpdef ndarray _boolean_array_indexing(ndarray a, ndarray boolean_array):             # <<<<<<<<<<<<<<
 *     a = a.flatten()
 *     boolean_array = boolean_array.flatten()
 */

  /* 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._boolean_array_indexing", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_nth_true_array);
  __Pyx_XDECREF(__pyx_v_n_true);
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XDECREF((PyObject *)__pyx_v_out);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF((PyObject *)__pyx_v_boolean_array);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_65_boolean_array_indexing(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_65_boolean_array_indexing(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_boolean_array = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_boolean_array_indexing (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_boolean_array,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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_boolean_array)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_boolean_array_indexing", 1, 2, 2, 1); __PYX_ERR(1, 1994, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_boolean_array_indexing") < 0)) __PYX_ERR(1, 1994, __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_boolean_array = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_boolean_array_indexing", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1994, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._boolean_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(1, 1994, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_boolean_array), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "boolean_array", 0))) __PYX_ERR(1, 1994, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_64_boolean_array_indexing(__pyx_self, __pyx_v_a, __pyx_v_boolean_array);

  /* 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_64_boolean_array_indexing(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_boolean_array) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_boolean_array_indexing", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__boolean_array_indexing(__pyx_v_a, __pyx_v_boolean_array, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1994, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._boolean_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":2006
 * 
 * 
 * cpdef ndarray _take(ndarray a, indices, axis=None, ndarray out=None):             # <<<<<<<<<<<<<<
 *     if a.ndim == 0:
 *         a = a[None]
 */

static PyObject *__pyx_pw_4cupy_4core_4core_67_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_axis = ((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;
  PyObject *__pyx_v_adim = NULL;
  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;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  struct __pyx_opt_args_4cupy_4core_4core_array __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("_take", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_out = __pyx_optional_args->out;
      }
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF(__pyx_v_indices);
  __Pyx_INCREF(__pyx_v_axis);
  __Pyx_INCREF((PyObject *)__pyx_v_out);

  /* "cupy/core/core.pyx":2007
 * 
 * cpdef ndarray _take(ndarray a, indices, axis=None, ndarray out=None):
 *     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(1, 2007, __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(1, 2007, __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(1, 2007, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2008
 * cpdef ndarray _take(ndarray a, indices, axis=None, ndarray out=None):
 *     if a.ndim == 0:
 *         a = a[None]             # <<<<<<<<<<<<<<
 * 
 *     if axis is None:
 */
    __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_a), Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2008, __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(1, 2008, __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":2007
 * 
 * cpdef ndarray _take(ndarray a, indices, axis=None, ndarray out=None):
 *     if a.ndim == 0:             # <<<<<<<<<<<<<<
 *         a = a[None]
 * 
 */
  }

  /* "cupy/core/core.pyx":2010
 *         a = a[None]
 * 
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         a = a.ravel()
 *         lshape = ()
 */
  __pyx_t_3 = (__pyx_v_axis == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":2011
 * 
 *     if axis 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(1, 2011, __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":2012
 *     if axis is None:
 *         a = a.ravel()
 *         lshape = ()             # <<<<<<<<<<<<<<
 *         rshape = ()
 *         adim = 1
 */
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_v_lshape = __pyx_empty_tuple;

    /* "cupy/core/core.pyx":2013
 *         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":2014
 *         lshape = ()
 *         rshape = ()
 *         adim = 1             # <<<<<<<<<<<<<<
 *         index_range = a.size
 *     else:
 */
    __Pyx_INCREF(__pyx_int_1);
    __pyx_v_adim = __pyx_int_1;

    /* "cupy/core/core.pyx":2015
 *         rshape = ()
 *         adim = 1
 *         index_range = a.size             # <<<<<<<<<<<<<<
 *     else:
 *         if not (-a.ndim <= axis < a.ndim):
 */
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_a->size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2015, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_index_range = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2010
 *         a = a[None]
 * 
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         a = a.ravel()
 *         lshape = ()
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":2017
 *         index_range = a.size
 *     else:
 *         if not (-a.ndim <= axis < a.ndim):             # <<<<<<<<<<<<<<
 *             raise ValueError('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(1, 2017, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_Negative(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2017, __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_axis, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2017, __pyx_L1_error)
    if (__Pyx_PyObject_IsTrue(__pyx_t_2)) {
      __Pyx_DECREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2017, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2017, __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_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 2017, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = ((!__pyx_t_4) != 0);
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":2018
 *     else:
 *         if not (-a.ndim <= axis < a.ndim):
 *             raise ValueError('Axis overrun')             # <<<<<<<<<<<<<<
 *         if a.ndim != 0:
 *             axis %= a.ndim
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2018, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(1, 2018, __pyx_L1_error)

      /* "cupy/core/core.pyx":2017
 *         index_range = a.size
 *     else:
 *         if not (-a.ndim <= axis < a.ndim):             # <<<<<<<<<<<<<<
 *             raise ValueError('Axis overrun')
 *         if a.ndim != 0:
 */
    }

    /* "cupy/core/core.pyx":2019
 *         if not (-a.ndim <= axis < a.ndim):
 *             raise ValueError('Axis overrun')
 *         if a.ndim != 0:             # <<<<<<<<<<<<<<
 *             axis %= a.ndim
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2019, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2019, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 2019, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":2020
 *             raise ValueError('Axis overrun')
 *         if a.ndim != 0:
 *             axis %= a.ndim             # <<<<<<<<<<<<<<
 * 
 *         lshape = a.shape[:axis]
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2020, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_InPlaceRemainder(__pyx_v_axis, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2020, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":2019
 *         if not (-a.ndim <= axis < a.ndim):
 *             raise ValueError('Axis overrun')
 *         if a.ndim != 0:             # <<<<<<<<<<<<<<
 *             axis %= a.ndim
 * 
 */
    }

    /* "cupy/core/core.pyx":2022
 *             axis %= a.ndim
 * 
 *         lshape = a.shape[:axis]             # <<<<<<<<<<<<<<
 *         rshape = a.shape[axis + 1:]
 *         adim = a.shape[axis]
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2022, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_2, 0, 0, NULL, &__pyx_v_axis, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2022, __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":2023
 * 
 *         lshape = a.shape[:axis]
 *         rshape = a.shape[axis + 1:]             # <<<<<<<<<<<<<<
 *         adim = a.shape[axis]
 *         index_range = adim
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2023, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_axis, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2023, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_t_1, 0, 0, &__pyx_t_2, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2023, __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_v_rshape = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2024
 *         lshape = a.shape[:axis]
 *         rshape = a.shape[axis + 1:]
 *         adim = a.shape[axis]             # <<<<<<<<<<<<<<
 *         index_range = adim
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2024, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyObject_GetItem(__pyx_t_5, __pyx_v_axis); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2024, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_adim = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2025
 *         rshape = a.shape[axis + 1:]
 *         adim = a.shape[axis]
 *         index_range = adim             # <<<<<<<<<<<<<<
 * 
 *     if numpy.isscalar(indices):
 */
    __Pyx_INCREF(__pyx_v_adim);
    __pyx_v_index_range = __pyx_v_adim;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":2027
 *         index_range = adim
 * 
 *     if numpy.isscalar(indices):             # <<<<<<<<<<<<<<
 *         indices %= index_range
 *         if axis is not None:
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2027, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_isscalar); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2027, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_indices); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2027, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2027, __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_indices);
    __Pyx_GIVEREF(__pyx_v_indices);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_indices);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2027, __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_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 2027, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2028
 * 
 *     if numpy.isscalar(indices):
 *         indices %= index_range             # <<<<<<<<<<<<<<
 *         if axis is not None:
 *             a = rollaxis(a, axis)
 */
    __pyx_t_2 = PyNumber_InPlaceRemainder(__pyx_v_indices, __pyx_v_index_range); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2028, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_indices, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2029
 *     if numpy.isscalar(indices):
 *         indices %= index_range
 *         if axis is not None:             # <<<<<<<<<<<<<<
 *             a = rollaxis(a, axis)
 *         if out is None:
 */
    __pyx_t_3 = (__pyx_v_axis != Py_None);
    __pyx_t_4 = (__pyx_t_3 != 0);
    if (__pyx_t_4) {

      /* "cupy/core/core.pyx":2030
 *         indices %= index_range
 *         if axis is not None:
 *             a = rollaxis(a, axis)             # <<<<<<<<<<<<<<
 *         if out is None:
 *             return a[indices].copy()
 */
      __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_v_axis); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 2030, __pyx_L1_error)
      __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core_rollaxis(__pyx_v_a, __pyx_t_7, 0, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2030, __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":2029
 *     if numpy.isscalar(indices):
 *         indices %= index_range
 *         if axis is not None:             # <<<<<<<<<<<<<<
 *             a = rollaxis(a, axis)
 *         if out is None:
 */
    }

    /* "cupy/core/core.pyx":2031
 *         if axis is not None:
 *             a = rollaxis(a, axis)
 *         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":2032
 *             a = rollaxis(a, axis)
 *         if out is None:
 *             return a[indices].copy()             # <<<<<<<<<<<<<<
 *         else:
 *             if out.dtype != a.dtype:
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_v_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2032, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_copy); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2032, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2032, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2032, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 2032, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2031
 *         if axis is not None:
 *             a = rollaxis(a, axis)
 *         if out is None:             # <<<<<<<<<<<<<<
 *             return a[indices].copy()
 *         else:
 */
    }

    /* "cupy/core/core.pyx":2034
 *             return a[indices].copy()
 *         else:
 *             if out.dtype != a.dtype:             # <<<<<<<<<<<<<<
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:
 */
    /*else*/ {
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_out->dtype, __pyx_v_a->dtype, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2034, __pyx_L1_error)
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 2034, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_3) {

        /* "cupy/core/core.pyx":2035
 *         else:
 *             if out.dtype != a.dtype:
 *                 raise TypeError('Output dtype mismatch')             # <<<<<<<<<<<<<<
 *             if out.shape != a.shape[1:]:
 *                 raise ValueError('Output shape mismatch')
 */
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__87, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2035, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __PYX_ERR(1, 2035, __pyx_L1_error)

        /* "cupy/core/core.pyx":2034
 *             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":2036
 *             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_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2036, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2036, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_6, 1, 0, NULL, NULL, &__pyx_slice__88, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2036, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2036, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 2036, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__pyx_t_3) {

        /* "cupy/core/core.pyx":2037
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:
 *                 raise ValueError('Output shape mismatch')             # <<<<<<<<<<<<<<
 *             out[()] = a[indices]
 *             return out
 */
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__89, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2037, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_Raise(__pyx_t_6, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __PYX_ERR(1, 2037, __pyx_L1_error)

        /* "cupy/core/core.pyx":2036
 *             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":2038
 *             if out.shape != a.shape[1:]:
 *                 raise ValueError('Output shape mismatch')
 *             out[()] = a[indices]             # <<<<<<<<<<<<<<
 *             return out
 *     elif not isinstance(indices, ndarray):
 */
      __pyx_t_6 = PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_v_indices); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2038, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_out), __pyx_empty_tuple, __pyx_t_6) < 0)) __PYX_ERR(1, 2038, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/core.pyx":2039
 *                 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":2027
 *         index_range = adim
 * 
 *     if numpy.isscalar(indices):             # <<<<<<<<<<<<<<
 *         indices %= index_range
 *         if axis is not None:
 */
  }

  /* "cupy/core/core.pyx":2040
 *             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":2041
 *             return out
 *     elif not isinstance(indices, ndarray):
 *         indices = array(indices, dtype=int)             # <<<<<<<<<<<<<<
 * 
 *     out_shape = lshape + indices.shape + rshape
 */
    __pyx_t_8.__pyx_n = 1;
    __pyx_t_8.dtype = ((PyObject *)(&PyInt_Type));
    __pyx_t_6 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_v_indices, 0, &__pyx_t_8)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2041, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF_SET(__pyx_v_indices, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2040
 *             out[()] = a[indices]
 *             return out
 *     elif not isinstance(indices, ndarray):             # <<<<<<<<<<<<<<
 *         indices = array(indices, dtype=int)
 * 
 */
  }

  /* "cupy/core/core.pyx":2043
 *         indices = array(indices, dtype=int)
 * 
 *     out_shape = lshape + indices.shape + rshape             # <<<<<<<<<<<<<<
 *     if out is None:
 *         out = ndarray(out_shape, dtype=a.dtype)
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = PyNumber_Add(__pyx_v_lshape, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Add(__pyx_t_1, __pyx_v_rshape); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_out_shape = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":2044
 * 
 *     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":2045
 *     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_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2045, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_out_shape);
    __Pyx_GIVEREF(__pyx_v_out_shape);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_out_shape);
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2045, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) __PYX_ERR(1, 2045, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2045, __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_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2044
 * 
 *     out_shape = lshape + indices.shape + rshape
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(out_shape, dtype=a.dtype)
 *     else:
 */
    goto __pyx_L12;
  }

  /* "cupy/core/core.pyx":2047
 *         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_2 = PyObject_RichCompare(__pyx_v_out->dtype, __pyx_v_a->dtype, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2047, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 2047, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":2048
 *     else:
 *         if out.dtype != a.dtype:
 *             raise TypeError('Output dtype mismatch')             # <<<<<<<<<<<<<<
 *         if out.shape != out_shape:
 *             raise ValueError('Output shape mismatch')
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__90, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2048, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(1, 2048, __pyx_L1_error)

      /* "cupy/core/core.pyx":2047
 *         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":2049
 *         if out.dtype != a.dtype:
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Output shape mismatch')
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_v_out_shape, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2049, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 2049, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":2050
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:
 *             raise ValueError('Output shape mismatch')             # <<<<<<<<<<<<<<
 * 
 *     cdim = indices.size
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__91, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2050, __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, 2050, __pyx_L1_error)

      /* "cupy/core/core.pyx":2049
 *         if out.dtype != a.dtype:
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Output shape mismatch')
 * 
 */
    }
  }
  __pyx_L12:;

  /* "cupy/core/core.pyx":2052
 *             raise ValueError('Output shape mismatch')
 * 
 *     cdim = indices.size             # <<<<<<<<<<<<<<
 *     rdim = internal.prod(rshape)
 *     indices = indices.reshape(
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2052, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_cdim = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2053
 * 
 *     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(1, 2053, __pyx_L1_error)
  __pyx_v_rdim = __pyx_t_7;

  /* "cupy/core/core.pyx":2054
 *     cdim = indices.size
 *     rdim = internal.prod(rshape)
 *     indices = indices.reshape(             # <<<<<<<<<<<<<<
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 *     if axis == 0 or axis is None:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2054, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/core.pyx":2055
 *     rdim = internal.prod(rshape)
 *     indices = indices.reshape(
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))             # <<<<<<<<<<<<<<
 *     if axis == 0 or axis is None:
 *         return _take_kernel_0axis(
 */
  __pyx_t_7 = PyObject_Length(__pyx_v_lshape); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(1, 2055, __pyx_L1_error)
  __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyNumber_Multiply(__pyx_tuple__92, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = PyNumber_Add(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_7 = PyObject_Length(__pyx_v_rshape); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(1, 2055, __pyx_L1_error)
  __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyNumber_Multiply(__pyx_tuple__93, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Add(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2054, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2054, __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_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_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2054, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_indices, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2056
 *     indices = indices.reshape(
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 *     if axis == 0 or axis is None:             # <<<<<<<<<<<<<<
 *         return _take_kernel_0axis(
 *             a.reduced_view(), indices, rdim, index_range, out)
 */
  __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_v_axis, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 2056, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L16_bool_binop_done;
  }
  __pyx_t_4 = (__pyx_v_axis == Py_None);
  __pyx_t_10 = (__pyx_t_4 != 0);
  __pyx_t_3 = __pyx_t_10;
  __pyx_L16_bool_binop_done:;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2057
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 *     if axis == 0 or axis is None:
 *         return _take_kernel_0axis(             # <<<<<<<<<<<<<<
 *             a.reduced_view(), indices, rdim, index_range, out)
 *     else:
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));

    /* "cupy/core/core.pyx":2058
 *     if axis == 0 or axis is None:
 *         return _take_kernel_0axis(
 *             a.reduced_view(), indices, rdim, index_range, out)             # <<<<<<<<<<<<<<
 *     else:
 *         return _take_kernel(
 */
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->reduced_view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2058, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_rdim); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2058, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__take_kernel_0axis);
    __pyx_t_6 = __pyx_v_4cupy_4core_4core__take_kernel_0axis; __pyx_t_5 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_11 = PyTuple_New(5+__pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 2057, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_7, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_indices);
    __Pyx_GIVEREF(__pyx_v_indices);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_7, __pyx_v_indices);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_7, __pyx_t_9);
    __Pyx_INCREF(__pyx_v_index_range);
    __Pyx_GIVEREF(__pyx_v_index_range);
    PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_7, __pyx_v_index_range);
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
    PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_7, ((PyObject *)__pyx_v_out));
    __pyx_t_2 = 0;
    __pyx_t_9 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2057, __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;

    /* "cupy/core/core.pyx":2057
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 *     if axis == 0 or axis is None:
 *         return _take_kernel_0axis(             # <<<<<<<<<<<<<<
 *             a.reduced_view(), indices, rdim, index_range, out)
 *     else:
 */
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 2057, __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":2056
 *     indices = indices.reshape(
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 *     if axis == 0 or axis is None:             # <<<<<<<<<<<<<<
 *         return _take_kernel_0axis(
 *             a.reduced_view(), indices, rdim, index_range, out)
 */
  }

  /* "cupy/core/core.pyx":2060
 *             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":2061
 *     else:
 *         return _take_kernel(
 *             a.reduced_view(), indices, cdim, rdim, adim, index_range, out)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->reduced_view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2061, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_11 = PyInt_FromSsize_t(__pyx_v_rdim); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 2061, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__take_kernel);
    __pyx_t_9 = __pyx_v_4cupy_4core_4core__take_kernel; __pyx_t_2 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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);
        __pyx_t_7 = 1;
      }
    }
    __pyx_t_5 = PyTuple_New(7+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2060, __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_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_t_6);
    __Pyx_INCREF(__pyx_v_indices);
    __Pyx_GIVEREF(__pyx_v_indices);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_v_indices);
    __Pyx_INCREF(__pyx_v_cdim);
    __Pyx_GIVEREF(__pyx_v_cdim);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_7, __pyx_v_cdim);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_7, __pyx_t_11);
    __Pyx_INCREF(__pyx_v_adim);
    __Pyx_GIVEREF(__pyx_v_adim);
    PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_7, __pyx_v_adim);
    __Pyx_INCREF(__pyx_v_index_range);
    __Pyx_GIVEREF(__pyx_v_index_range);
    PyTuple_SET_ITEM(__pyx_t_5, 5+__pyx_t_7, __pyx_v_index_range);
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
    PyTuple_SET_ITEM(__pyx_t_5, 6+__pyx_t_7, ((PyObject *)__pyx_v_out));
    __pyx_t_6 = 0;
    __pyx_t_11 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2060, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "cupy/core/core.pyx":2060
 *             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_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 2060, __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":2006
 * 
 * 
 * cpdef ndarray _take(ndarray a, indices, axis=None, ndarray out=None):             # <<<<<<<<<<<<<<
 *     if a.ndim == 0:
 *         a = a[None]
 */

  /* 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_9);
  __Pyx_XDECREF(__pyx_t_11);
  __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_adim);
  __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_axis);
  __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_67_take(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_67_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_axis = 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_axis,&__pyx_n_s_out,0};
    PyObject* values[4] = {0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    values[3] = (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  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_indices)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_take", 0, 2, 4, 1); __PYX_ERR(1, 2006, __pyx_L3_error)
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_take") < 0)) __PYX_ERR(1, 2006, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        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_axis = values[2];
    __pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[3]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_take", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 2006, __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(1, 2006, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(1, 2006, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_66_take(__pyx_self, __pyx_v_a, __pyx_v_indices, __pyx_v_axis, __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_66_take(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_indices, PyObject *__pyx_v_axis, 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 = 2;
  __pyx_t_2.axis = __pyx_v_axis;
  __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(1, 2006, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":2064
 * 
 * 
 * cpdef ndarray _diagonal(ndarray a, Py_ssize_t offset=0, Py_ssize_t axis1=0,             # <<<<<<<<<<<<<<
 *                         Py_ssize_t axis2=1):
 *     if axis1 < axis2:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_69_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_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
  int __pyx_t_1;
  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;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  long __pyx_t_9;
  std::vector<Py_ssize_t>  __pyx_t_10;
  std::vector<Py_ssize_t>  __pyx_t_11;
  __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":2066
 * cpdef ndarray _diagonal(ndarray a, Py_ssize_t offset=0, Py_ssize_t axis1=0,
 *                         Py_ssize_t axis2=1):
 *     if axis1 < axis2:             # <<<<<<<<<<<<<<
 *         min_axis, max_axis = axis1, axis2
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_axis1 < __pyx_v_axis2) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2067
 *                         Py_ssize_t axis2=1):
 *     if axis1 < axis2:
 *         min_axis, max_axis = axis1, axis2             # <<<<<<<<<<<<<<
 *     else:
 *         min_axis, max_axis = axis2, axis1
 */
    __pyx_t_2 = __pyx_v_axis1;
    __pyx_t_3 = __pyx_v_axis2;
    __pyx_v_min_axis = __pyx_t_2;
    __pyx_v_max_axis = __pyx_t_3;

    /* "cupy/core/core.pyx":2066
 * cpdef ndarray _diagonal(ndarray a, Py_ssize_t offset=0, Py_ssize_t axis1=0,
 *                         Py_ssize_t axis2=1):
 *     if axis1 < axis2:             # <<<<<<<<<<<<<<
 *         min_axis, max_axis = axis1, axis2
 *     else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":2069
 *         min_axis, max_axis = axis1, axis2
 *     else:
 *         min_axis, max_axis = axis2, axis1             # <<<<<<<<<<<<<<
 * 
 *     tr = list(six.moves.range(a.ndim))
 */
  /*else*/ {
    __pyx_t_3 = __pyx_v_axis2;
    __pyx_t_2 = __pyx_v_axis1;
    __pyx_v_min_axis = __pyx_t_3;
    __pyx_v_max_axis = __pyx_t_2;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":2071
 *         min_axis, max_axis = axis2, axis1
 * 
 *     tr = list(six.moves.range(a.ndim))             # <<<<<<<<<<<<<<
 *     del tr[max_axis]
 *     del tr[min_axis]
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2071, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_moves); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2071, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_range); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2071, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2071, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2071, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2071, __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_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2071, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PySequence_List(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2071, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_tr = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2072
 * 
 *     tr = list(six.moves.range(a.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(1, 2072, __pyx_L1_error)

  /* "cupy/core/core.pyx":2073
 *     tr = list(six.moves.range(a.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(1, 2073, __pyx_L1_error)

  /* "cupy/core/core.pyx":2074
 *     del tr[max_axis]
 *     del tr[min_axis]
 *     if offset >= 0:             # <<<<<<<<<<<<<<
 *         a = a.transpose(tr + [axis1, axis2])
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_offset >= 0) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2075
 *     del tr[min_axis]
 *     if offset >= 0:
 *         a = a.transpose(tr + [axis1, axis2])             # <<<<<<<<<<<<<<
 *     else:
 *         a = a.transpose(tr + [axis2, axis1])
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_transpose_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2075, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_axis1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2075, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_axis2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2075, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2075, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8);
    PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_6);
    PyList_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
    __pyx_t_8 = 0;
    __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_Add(__pyx_v_tr, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2075, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2075, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2075, __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_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2075, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 2075, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2074
 *     del tr[max_axis]
 *     del tr[min_axis]
 *     if offset >= 0:             # <<<<<<<<<<<<<<
 *         a = a.transpose(tr + [axis1, axis2])
 *     else:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":2077
 *         a = a.transpose(tr + [axis1, axis2])
 *     else:
 *         a = a.transpose(tr + [axis2, axis1])             # <<<<<<<<<<<<<<
 *         offset = -offset
 * 
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_transpose_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2077, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_axis2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2077, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_axis1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2077, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2077, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8);
    PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_6);
    PyList_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
    __pyx_t_8 = 0;
    __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_Add(__pyx_v_tr, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2077, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2077, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2077, __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_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2077, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 2077, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2078
 *     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_L4:;

  /* "cupy/core/core.pyx":2080
 *         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_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2080, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_5, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2080, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_offset); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2080, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2080, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2080, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_5, -2L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2080, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = PyObject_RichCompare(__pyx_t_8, __pyx_t_4, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2080, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 2080, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_1) {
    __Pyx_INCREF(__pyx_t_8);
    __pyx_t_5 = __pyx_t_8;
  } else {
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_5 = __pyx_t_4;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_8 = __pyx_t_5;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_9 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2080, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyObject_RichCompare(__pyx_t_8, __pyx_t_4, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2080, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 2080, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_1) {
    __Pyx_INCREF(__pyx_t_8);
    __pyx_t_5 = __pyx_t_8;
  } else {
    __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2080, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __pyx_t_6;
    __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __pyx_t_5;
  __Pyx_INCREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_diag_size = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2081
 * 
 *     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_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2081, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_t_8, 0, -2L, NULL, NULL, &__pyx_slice__94, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2081, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2081, __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_6 = PyNumber_Add(__pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2081, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_ret_shape = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":2082
 *     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_6 = __Pyx_PyInt_EqObjC(__pyx_v_diag_size, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2082, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 2082, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2083
 *     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_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2083, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_ret_shape);
    __Pyx_GIVEREF(__pyx_v_ret_shape);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_ret_shape);
    __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2083, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) __PYX_ERR(1, 2083, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2083, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2082
 *     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":2085
 *         return ndarray(ret_shape, dtype=a.dtype)
 * 
 *     a = a[..., :diag_size, offset:offset + diag_size]             # <<<<<<<<<<<<<<
 * 
 *     ret = a.view()
 */
  __pyx_t_5 = PySlice_New(Py_None, __pyx_v_diag_size, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_offset); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_offset); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = PyNumber_Add(__pyx_t_6, __pyx_v_diag_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PySlice_New(__pyx_t_8, __pyx_t_4, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(Py_Ellipsis);
  __Pyx_GIVEREF(Py_Ellipsis);
  PyTuple_SET_ITEM(__pyx_t_4, 0, Py_Ellipsis);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_6);
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 2085, __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":2087
 *     a = a[..., :diag_size, offset:offset + diag_size]
 * 
 *     ret = a.view()             # <<<<<<<<<<<<<<
 *     ret._set_shape_and_strides(
 *         a.shape[:-2] + (diag_size,),
 */
  __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(1, 2087, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":2089
 *     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_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_t_6, 0, -2L, NULL, NULL, &__pyx_slice__95, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_diag_size);
  __Pyx_GIVEREF(__pyx_v_diag_size);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_diag_size);
  __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_10 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2089, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2090
 *     ret._set_shape_and_strides(
 *         a.shape[:-2] + (diag_size,),
 *         a.strides[:-2] + (a.strides[-1] + a.strides[-2],))             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2090, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_t_5, 0, -2L, NULL, NULL, &__pyx_slice__96, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2090, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2090, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_5, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2090, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2090, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_5, -2L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2090, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2090, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2090, __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 = PyNumber_Add(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2090, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_11 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2090, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2088
 * 
 *     ret = a.view()
 *     ret._set_shape_and_strides(             # <<<<<<<<<<<<<<
 *         a.shape[:-2] + (diag_size,),
 *         a.strides[:-2] + (a.strides[-1] + a.strides[-2],))
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ret->__pyx_vtab)->_set_shape_and_strides(__pyx_v_ret, __pyx_t_10, __pyx_t_11, 0, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2088, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2091
 *         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":2064
 * 
 * 
 * cpdef ndarray _diagonal(ndarray a, Py_ssize_t offset=0, Py_ssize_t axis1=0,             # <<<<<<<<<<<<<<
 *                         Py_ssize_t axis2=1):
 *     if axis1 < axis2:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_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_69_diagonal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_69_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);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_offset);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis1);
          if (value) { values[2] = value; kw_args--; }
        }
        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(1, 2064, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        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(1, 2064, __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(1, 2064, __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(1, 2065, __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(1, 2064, __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(1, 2064, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_68_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_68_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(1, 2064, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":2094
 * 
 * 
 * cpdef ndarray _adv_getitem(ndarray a, slices):             # <<<<<<<<<<<<<<
 *     # slices consist of either slice(None) or ndarray
 *     cdef int i, p, li, ri
 */

static PyObject *__pyx_pw_4cupy_4core_4core_71_adv_getitem(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__adv_getitem(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slices, CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_v_i;
  int __pyx_v_p;
  int __pyx_v_li;
  int __pyx_v_ri;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_take_idx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_input_flat = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out_flat = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_o = 0;
  PyObject *__pyx_v_arr_slices = NULL;
  struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_br = NULL;
  PyObject *__pyx_v_j = NULL;
  PyObject *__pyx_v_s = NULL;
  int __pyx_v_do_transpose;
  PyObject *__pyx_v_prev_arr_i = NULL;
  PyObject *__pyx_v_transp = NULL;
  PyObject *__pyx_v_tmp = NULL;
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_strides = NULL;
  PyObject *__pyx_v_stride = NULL;
  PyObject *__pyx_v_flattened_indexes = NULL;
  PyObject *__pyx_v_concat_shape = NULL;
  PyObject *__pyx_v_out_flat_shape = NULL;
  PyObject *__pyx_v_index = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  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;
  int __pyx_t_13;
  Py_ssize_t __pyx_t_14;
  std::vector<Py_ssize_t>  __pyx_t_15;
  int __pyx_t_16;
  long __pyx_t_17;
  PyObject *(*__pyx_t_18)(PyObject *);
  PyObject *__pyx_t_19 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_take __pyx_t_20;
  __Pyx_RefNannySetupContext("_adv_getitem", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_a);

  /* "cupy/core/core.pyx":2099
 *     cdef ndarray take_idx, input_flat, out_flat, o
 * 
 *     arr_slices = [s for s in slices if isinstance(s, ndarray)]             # <<<<<<<<<<<<<<
 *     br = broadcast(*arr_slices)
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2099, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(PyList_CheckExact(__pyx_v_slices)) || PyTuple_CheckExact(__pyx_v_slices)) {
    __pyx_t_2 = __pyx_v_slices; __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_slices); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2099, __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, 2099, __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_COMPILING_IN_CPYTHON
        __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, 2099, __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, 2099, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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, 2099, __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, 2099, __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, 2099, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_7 = (__pyx_t_6 != 0);
    if (__pyx_t_7) {
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_v_s))) __PYX_ERR(1, 2099, __pyx_L1_error)
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_arr_slices = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2100
 * 
 *     arr_slices = [s for s in slices if isinstance(s, ndarray)]
 *     br = broadcast(*arr_slices)             # <<<<<<<<<<<<<<
 * 
 *     # broadcast all arrays to the largest shape
 */
  __pyx_t_1 = PySequence_Tuple(__pyx_v_arr_slices); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2100, __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(1, 2100, __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":2103
 * 
 *     # broadcast all arrays to the largest shape
 *     j = 0             # <<<<<<<<<<<<<<
 *     for i, s in enumerate(list(slices)):
 *         if isinstance(s, ndarray):
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_j = __pyx_int_0;

  /* "cupy/core/core.pyx":2104
 *     # broadcast all arrays to the largest shape
 *     j = 0
 *     for i, s in enumerate(list(slices)):             # <<<<<<<<<<<<<<
 *         if isinstance(s, ndarray):
 *             slices[i] = br.values[j]
 */
  __pyx_t_8 = 0;
  __pyx_t_2 = PySequence_List(__pyx_v_slices); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __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, 2104, __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, 2104, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_v_i = __pyx_t_8;
    __pyx_t_8 = (__pyx_t_8 + 1);

    /* "cupy/core/core.pyx":2105
 *     j = 0
 *     for i, s in enumerate(list(slices)):
 *         if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *             slices[i] = br.values[j]
 *             j += 1
 */
    __pyx_t_7 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_6 = (__pyx_t_7 != 0);
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":2106
 *     for i, s in enumerate(list(slices)):
 *         if isinstance(s, ndarray):
 *             slices[i] = br.values[j]             # <<<<<<<<<<<<<<
 *             j += 1
 * 
 */
      if (unlikely(__pyx_v_br->values == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(1, 2106, __pyx_L1_error)
      }
      __pyx_t_2 = PyObject_GetItem(__pyx_v_br->values, __pyx_v_j); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2106, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (unlikely(__Pyx_SetItemInt(__pyx_v_slices, __pyx_v_i, __pyx_t_2, int, 1, __Pyx_PyInt_From_int, 0, 1, 1) < 0)) __PYX_ERR(1, 2106, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":2107
 *         if isinstance(s, ndarray):
 *             slices[i] = br.values[j]
 *             j += 1             # <<<<<<<<<<<<<<
 * 
 *     # check if transpose is necessasry
 */
      __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_j, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2107, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF_SET(__pyx_v_j, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":2105
 *     j = 0
 *     for i, s in enumerate(list(slices)):
 *         if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *             slices[i] = br.values[j]
 *             j += 1
 */
    }

    /* "cupy/core/core.pyx":2104
 *     # broadcast all arrays to the largest shape
 *     j = 0
 *     for i, s in enumerate(list(slices)):             # <<<<<<<<<<<<<<
 *         if isinstance(s, ndarray):
 *             slices[i] = br.values[j]
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2112
 *     # 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":2113
 *     # 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":2114
 *     do_transpose = False
 *     prev_arr_i = None
 *     li = 0             # <<<<<<<<<<<<<<
 *     ri = 0
 *     for i, s in enumerate(list(slices)):
 */
  __pyx_v_li = 0;

  /* "cupy/core/core.pyx":2115
 *     prev_arr_i = None
 *     li = 0
 *     ri = 0             # <<<<<<<<<<<<<<
 *     for i, s in enumerate(list(slices)):
 *         if isinstance(s, ndarray):
 */
  __pyx_v_ri = 0;

  /* "cupy/core/core.pyx":2116
 *     li = 0
 *     ri = 0
 *     for i, s in enumerate(list(slices)):             # <<<<<<<<<<<<<<
 *         if isinstance(s, ndarray):
 *             if prev_arr_i is None:
 */
  __pyx_t_8 = 0;
  __pyx_t_1 = PySequence_List(__pyx_v_slices); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __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, 2116, __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, 2116, __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_8;
    __pyx_t_8 = (__pyx_t_8 + 1);

    /* "cupy/core/core.pyx":2117
 *     ri = 0
 *     for i, s in enumerate(list(slices)):
 *         if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *             if prev_arr_i is None:
 *                 prev_arr_i = i
 */
    __pyx_t_6 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_7 = (__pyx_t_6 != 0);
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":2118
 *     for i, s in enumerate(list(slices)):
 *         if isinstance(s, ndarray):
 *             if prev_arr_i is None:             # <<<<<<<<<<<<<<
 *                 prev_arr_i = i
 *                 li = i
 */
      __pyx_t_7 = (__pyx_v_prev_arr_i == Py_None);
      __pyx_t_6 = (__pyx_t_7 != 0);
      if (__pyx_t_6) {

        /* "cupy/core/core.pyx":2119
 *         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 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2119, __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":2120
 *             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":2118
 *     for i, s in enumerate(list(slices)):
 *         if isinstance(s, ndarray):
 *             if prev_arr_i is None:             # <<<<<<<<<<<<<<
 *                 prev_arr_i = i
 *                 li = i
 */
        goto __pyx_L12;
      }

      /* "cupy/core/core.pyx":2121
 *                 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_7 = (__pyx_v_prev_arr_i != Py_None);
      __pyx_t_9 = (__pyx_t_7 != 0);
      if (__pyx_t_9) {
      } else {
        __pyx_t_6 = __pyx_t_9;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2121, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = PyNumber_Subtract(__pyx_t_1, __pyx_v_prev_arr_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2121, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_5, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2121, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(1, 2121, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_6 = __pyx_t_9;
      __pyx_L13_bool_binop_done:;
      if (__pyx_t_6) {

        /* "cupy/core/core.pyx":2122
 *                 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":2121
 *                 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_L12;
      }

      /* "cupy/core/core.pyx":2124
 *                 do_transpose = True
 *             else:
 *                 prev_arr_i = i             # <<<<<<<<<<<<<<
 *                 ri = i
 * 
 */
      /*else*/ {
        __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2124, __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":2125
 *             else:
 *                 prev_arr_i = i
 *                 ri = i             # <<<<<<<<<<<<<<
 * 
 *     if do_transpose:
 */
        __pyx_v_ri = __pyx_v_i;
      }
      __pyx_L12:;

      /* "cupy/core/core.pyx":2117
 *     ri = 0
 *     for i, s in enumerate(list(slices)):
 *         if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *             if prev_arr_i is None:
 *                 prev_arr_i = i
 */
    }

    /* "cupy/core/core.pyx":2116
 *     li = 0
 *     ri = 0
 *     for i, s in enumerate(list(slices)):             # <<<<<<<<<<<<<<
 *         if isinstance(s, ndarray):
 *             if prev_arr_i is None:
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2127
 *                 ri = i
 * 
 *     if do_transpose:             # <<<<<<<<<<<<<<
 *         transp = list(range(a.ndim))
 *         p = 0
 */
  __pyx_t_6 = (__pyx_v_do_transpose != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":2128
 * 
 *     if do_transpose:
 *         transp = list(range(a.ndim))             # <<<<<<<<<<<<<<
 *         p = 0
 *         for i, s in enumerate(list(slices)):
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2128, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2128, __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(1, 2128, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PySequence_List(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2128, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_transp = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2129
 *     if do_transpose:
 *         transp = list(range(a.ndim))
 *         p = 0             # <<<<<<<<<<<<<<
 *         for i, s in enumerate(list(slices)):
 *             if isinstance(s, ndarray):
 */
    __pyx_v_p = 0;

    /* "cupy/core/core.pyx":2130
 *         transp = list(range(a.ndim))
 *         p = 0
 *         for i, s in enumerate(list(slices)):             # <<<<<<<<<<<<<<
 *             if isinstance(s, ndarray):
 *                 transp.remove(i)
 */
    __pyx_t_8 = 0;
    __pyx_t_1 = PySequence_List(__pyx_v_slices); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2130, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __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, 2130, __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, 2130, __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_8;
      __pyx_t_8 = (__pyx_t_8 + 1);

      /* "cupy/core/core.pyx":2131
 *         p = 0
 *         for i, s in enumerate(list(slices)):
 *             if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *                 transp.remove(i)
 *                 transp.insert(p, i)
 */
      __pyx_t_6 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
      __pyx_t_9 = (__pyx_t_6 != 0);
      if (__pyx_t_9) {

        /* "cupy/core/core.pyx":2132
 *         for i, s in enumerate(list(slices)):
 *             if isinstance(s, ndarray):
 *                 transp.remove(i)             # <<<<<<<<<<<<<<
 *                 transp.insert(p, i)
 *                 tmp = slices.pop(i)
 */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_transp, __pyx_n_s_remove); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2132, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2132, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2132, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else {
          __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2132, __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_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_10);
          __pyx_t_10 = 0;
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2132, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cupy/core/core.pyx":2133
 *             if isinstance(s, ndarray):
 *                 transp.remove(i)
 *                 transp.insert(p, i)             # <<<<<<<<<<<<<<
 *                 tmp = slices.pop(i)
 *                 slices.insert(p, tmp)
 */
        __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2133, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_13 = PyList_Insert(__pyx_v_transp, __pyx_v_p, __pyx_t_1); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(1, 2133, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cupy/core/core.pyx":2134
 *                 transp.remove(i)
 *                 transp.insert(p, i)
 *                 tmp = slices.pop(i)             # <<<<<<<<<<<<<<
 *                 slices.insert(p, tmp)
 *                 p += 1
 */
        __pyx_t_1 = __Pyx_PyObject_PopIndex(__pyx_v_slices, Py_None, __pyx_v_i, 1, int, __Pyx_PyInt_From_int); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2134, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_XDECREF_SET(__pyx_v_tmp, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "cupy/core/core.pyx":2135
 *                 transp.insert(p, i)
 *                 tmp = slices.pop(i)
 *                 slices.insert(p, tmp)             # <<<<<<<<<<<<<<
 *                 p += 1
 *         a = a.transpose(*transp)
 */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_slices, __pyx_n_s_insert); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2135, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_p); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2135, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_10 = NULL;
        __pyx_t_14 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && 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_14 = 1;
          }
        }
        __pyx_t_11 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 2135, __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_12);
        PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_14, __pyx_t_12);
        __Pyx_INCREF(__pyx_v_tmp);
        __Pyx_GIVEREF(__pyx_v_tmp);
        PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_14, __pyx_v_tmp);
        __pyx_t_12 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2135, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cupy/core/core.pyx":2136
 *                 tmp = slices.pop(i)
 *                 slices.insert(p, tmp)
 *                 p += 1             # <<<<<<<<<<<<<<
 *         a = a.transpose(*transp)
 * 
 */
        __pyx_v_p = (__pyx_v_p + 1);

        /* "cupy/core/core.pyx":2131
 *         p = 0
 *         for i, s in enumerate(list(slices)):
 *             if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *                 transp.remove(i)
 *                 transp.insert(p, i)
 */
      }

      /* "cupy/core/core.pyx":2130
 *         transp = list(range(a.ndim))
 *         p = 0
 *         for i, s in enumerate(list(slices)):             # <<<<<<<<<<<<<<
 *             if isinstance(s, ndarray):
 *                 transp.remove(i)
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2137
 *                 slices.insert(p, tmp)
 *                 p += 1
 *         a = a.transpose(*transp)             # <<<<<<<<<<<<<<
 * 
 *         li = 0
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_transpose_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2137, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PySequence_Tuple(__pyx_v_transp); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2137, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2137, __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;
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 2137, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2139
 *         a = a.transpose(*transp)
 * 
 *         li = 0             # <<<<<<<<<<<<<<
 *         ri = p - 1
 * 
 */
    __pyx_v_li = 0;

    /* "cupy/core/core.pyx":2140
 * 
 *         li = 0
 *         ri = p - 1             # <<<<<<<<<<<<<<
 * 
 *     # flatten the array-indexed dimensions
 */
    __pyx_v_ri = (__pyx_v_p - 1);

    /* "cupy/core/core.pyx":2127
 *                 ri = i
 * 
 *     if do_transpose:             # <<<<<<<<<<<<<<
 *         transp = list(range(a.ndim))
 *         p = 0
 */
  }

  /* "cupy/core/core.pyx":2143
 * 
 *     # flatten the array-indexed dimensions
 *     shape = a.shape[:li] +\             # <<<<<<<<<<<<<<
 *         (internal.prod_ssize_t(a.shape[li:ri+1]),) + a.shape[ri+1:]
 *     input_flat = a.reshape(shape)
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_5, 0, __pyx_v_li, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2144
 *     # flatten the array-indexed dimensions
 *     shape = a.shape[:li] +\
 *         (internal.prod_ssize_t(a.shape[li:ri+1]),) + a.shape[ri+1:]             # <<<<<<<<<<<<<<
 *     input_flat = a.reshape(shape)
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_t_5, __pyx_v_li, (__pyx_v_ri + 1), NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_15 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2144, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_f_4cupy_4core_8internal_prod_ssize_t(__pyx_t_15, 0, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2144, __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 = 0;

  /* "cupy/core/core.pyx":2143
 * 
 *     # flatten the array-indexed dimensions
 *     shape = a.shape[:li] +\             # <<<<<<<<<<<<<<
 *         (internal.prod_ssize_t(a.shape[li:ri+1]),) + a.shape[ri+1:]
 *     input_flat = a.reshape(shape)
 */
  __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2143, __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;

  /* "cupy/core/core.pyx":2144
 *     # flatten the array-indexed dimensions
 *     shape = a.shape[:li] +\
 *         (internal.prod_ssize_t(a.shape[li:ri+1]),) + a.shape[ri+1:]             # <<<<<<<<<<<<<<
 *     input_flat = a.reshape(shape)
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_5, (__pyx_v_ri + 1), 0, NULL, NULL, NULL, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2144, __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_shape = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2145
 *     shape = a.shape[:li] +\
 *         (internal.prod_ssize_t(a.shape[li:ri+1]),) + a.shape[ri+1:]
 *     input_flat = a.reshape(shape)             # <<<<<<<<<<<<<<
 * 
 *     # build the strides
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2145, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 2145, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_shape);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2145, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 2145, __pyx_L1_error)
  __pyx_v_input_flat = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2148
 * 
 *     # build the strides
 *     strides = [1]             # <<<<<<<<<<<<<<
 *     for i in range(ri, li, -1):
 *         stride = a.shape[i] * strides[0]
 */
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  __pyx_v_strides = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2149
 *     # build the strides
 *     strides = [1]
 *     for i in range(ri, li, -1):             # <<<<<<<<<<<<<<
 *         stride = a.shape[i] * strides[0]
 *         strides.insert(0, stride)
 */
  __pyx_t_8 = __pyx_v_li;
  for (__pyx_t_16 = __pyx_v_ri; __pyx_t_16 > __pyx_t_8; __pyx_t_16-=1) {
    __pyx_v_i = __pyx_t_16;

    /* "cupy/core/core.pyx":2150
 *     strides = [1]
 *     for i in range(ri, li, -1):
 *         stride = a.shape[i] * strides[0]             # <<<<<<<<<<<<<<
 *         strides.insert(0, stride)
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2150, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_5, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2150, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_v_strides, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2150, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_11 = PyNumber_Multiply(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 2150, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_stride, __pyx_t_11);
    __pyx_t_11 = 0;

    /* "cupy/core/core.pyx":2151
 *     for i in range(ri, li, -1):
 *         stride = a.shape[i] * strides[0]
 *         strides.insert(0, stride)             # <<<<<<<<<<<<<<
 * 
 *     # convert all negative indices to wrap_indices
 */
    __pyx_t_13 = PyList_Insert(__pyx_v_strides, 0, __pyx_v_stride); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(1, 2151, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":2154
 * 
 *     # convert all negative indices to wrap_indices
 *     for i in range(li, ri+1):             # <<<<<<<<<<<<<<
 *         slices[i] = slices[i] % a.shape[i]
 * 
 */
  __pyx_t_17 = (__pyx_v_ri + 1);
  for (__pyx_t_8 = __pyx_v_li; __pyx_t_8 < __pyx_t_17; __pyx_t_8+=1) {
    __pyx_v_i = __pyx_t_8;

    /* "cupy/core/core.pyx":2155
 *     # convert all negative indices to wrap_indices
 *     for i in range(li, ri+1):
 *         slices[i] = slices[i] % a.shape[i]             # <<<<<<<<<<<<<<
 * 
 *     flattened_indexes = []
 */
    __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_slices, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 2155, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2155, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_5, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2155, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Remainder(__pyx_t_11, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2155, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(__Pyx_SetItemInt(__pyx_v_slices, __pyx_v_i, __pyx_t_5, int, 1, __Pyx_PyInt_From_int, 0, 1, 1) < 0)) __PYX_ERR(1, 2155, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }

  /* "cupy/core/core.pyx":2157
 *         slices[i] = slices[i] % a.shape[i]
 * 
 *     flattened_indexes = []             # <<<<<<<<<<<<<<
 *     for stride, s in zip(strides, slices[li:ri+1]):
 *         flattened_indexes.append(stride * s)
 */
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_flattened_indexes = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2158
 * 
 *     flattened_indexes = []
 *     for stride, s in zip(strides, slices[li:ri+1]):             # <<<<<<<<<<<<<<
 *         flattened_indexes.append(stride * s)
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_v_slices, __pyx_v_li, (__pyx_v_ri + 1), NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_strides);
  __Pyx_GIVEREF(__pyx_v_strides);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_strides);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2158, __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_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2158, __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, 2158, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_COMPILING_IN_CPYTHON
        __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, 2158, __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, 2158, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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, 2158, __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, 2158, __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, 2158, __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_CPYTHON
      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, 2158, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_11 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_2);
      #else
      __pyx_t_11 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 2158, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2158, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_12 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2158, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_18 = Py_TYPE(__pyx_t_12)->tp_iternext;
      index = 0; __pyx_t_11 = __pyx_t_18(__pyx_t_12); if (unlikely(!__pyx_t_11)) goto __pyx_L25_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_11);
      index = 1; __pyx_t_2 = __pyx_t_18(__pyx_t_12); if (unlikely(!__pyx_t_2)) goto __pyx_L25_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_18(__pyx_t_12), 2) < 0) __PYX_ERR(1, 2158, __pyx_L1_error)
      __pyx_t_18 = NULL;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      goto __pyx_L26_unpacking_done;
      __pyx_L25_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_18 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(1, 2158, __pyx_L1_error)
      __pyx_L26_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_stride, __pyx_t_11);
    __pyx_t_11 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2159
 *     flattened_indexes = []
 *     for stride, s in zip(strides, slices[li:ri+1]):
 *         flattened_indexes.append(stride * s)             # <<<<<<<<<<<<<<
 * 
 *     # do stack: flattened_indexes = stack(flattened_indexes, axis=0)
 */
    __pyx_t_5 = PyNumber_Multiply(__pyx_v_stride, __pyx_v_s); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2159, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_13 = __Pyx_PyObject_Append(__pyx_v_flattened_indexes, __pyx_t_5); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(1, 2159, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2158
 * 
 *     flattened_indexes = []
 *     for stride, s in zip(strides, slices[li:ri+1]):             # <<<<<<<<<<<<<<
 *         flattened_indexes.append(stride * s)
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2162
 * 
 *     # 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(1, 2162, __pyx_L1_error)
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2162, __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 = 0;
  __pyx_t_1 = PyNumber_Add(__pyx_t_5, __pyx_v_br->shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_concat_shape = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2164
 *     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_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __pyx_v_flattened_indexes; __Pyx_INCREF(__pyx_t_5); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_5)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 2164, __pyx_L1_error)
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 2164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_shape); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_10 = PyNumber_Add(__pyx_tuple__97, __pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
      }
    }
    if (!__pyx_t_12) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2164, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_19 = PyTuple_New(1+1); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 2164, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_19);
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_12); __pyx_t_12 = NULL;
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_19, 0+1, __pyx_t_10);
      __pyx_t_10 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_19, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2164, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) __PYX_ERR(1, 2164, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2165
 *     flattened_indexes = concatenate(
 *         [index.reshape((1,) + index.shape) for index in flattened_indexes],
 *         axis=0, shape=concat_shape, dtype=flattened_indexes[0].dtype)             # <<<<<<<<<<<<<<
 * 
 *     take_idx = _sum(flattened_indexes, axis=0)
 */
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_flattened_indexes, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2163
 *     # 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_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_concatenate(__pyx_t_1, __pyx_int_0, __pyx_v_concat_shape, __pyx_t_2, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2163, __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_flattened_indexes, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2167
 *         axis=0, shape=concat_shape, dtype=flattened_indexes[0].dtype)
 * 
 *     take_idx = _sum(flattened_indexes, axis=0)             # <<<<<<<<<<<<<<
 * 
 *     out_flat = input_flat.take(take_idx.flatten(), axis=li)
 */
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_flattened_indexes);
  __Pyx_GIVEREF(__pyx_v_flattened_indexes);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_flattened_indexes);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_int_0) < 0) __PYX_ERR(1, 2167, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__sum, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2167, __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 (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 2167, __pyx_L1_error)
  __pyx_v_take_idx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2169
 *     take_idx = _sum(flattened_indexes, axis=0)
 * 
 *     out_flat = input_flat.take(take_idx.flatten(), axis=li)             # <<<<<<<<<<<<<<
 * 
 *     out_flat_shape = a.shape[:li] + take_idx.shape + a.shape[ri+1:]
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_take_idx->__pyx_vtab)->flatten(__pyx_v_take_idx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_li); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_20.__pyx_n = 1;
  __pyx_t_20.axis = __pyx_t_2;
  __pyx_t_5 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_input_flat->__pyx_vtab)->take(__pyx_v_input_flat, __pyx_t_1, 0, &__pyx_t_20)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2169, __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_v_out_flat = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2171
 *     out_flat = input_flat.take(take_idx.flatten(), axis=li)
 * 
 *     out_flat_shape = a.shape[:li] + take_idx.shape + a.shape[ri+1:]             # <<<<<<<<<<<<<<
 *     o = out_flat.reshape(out_flat_shape)
 *     return o
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_t_5, 0, __pyx_v_li, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_take_idx), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyNumber_Add(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_t_5, (__pyx_v_ri + 1), 0, NULL, NULL, NULL, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2171, __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_v_out_flat_shape = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2172
 * 
 *     out_flat_shape = a.shape[:li] + take_idx.shape + a.shape[ri+1:]
 *     o = out_flat.reshape(out_flat_shape)             # <<<<<<<<<<<<<<
 *     return o
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out_flat), __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(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);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_out_flat_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 2172, __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 = NULL;
    __Pyx_INCREF(__pyx_v_out_flat_shape);
    __Pyx_GIVEREF(__pyx_v_out_flat_shape);
    PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_out_flat_shape);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 2172, __pyx_L1_error)
  __pyx_v_o = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2173
 *     out_flat_shape = a.shape[:li] + take_idx.shape + a.shape[ri+1:]
 *     o = out_flat.reshape(out_flat_shape)
 *     return o             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_o));
  __pyx_r = __pyx_v_o;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2094
 * 
 * 
 * cpdef ndarray _adv_getitem(ndarray a, slices):             # <<<<<<<<<<<<<<
 *     # slices consist of either slice(None) or ndarray
 *     cdef int i, p, li, ri
 */

  /* 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_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_AddTraceback("cupy.core.core._adv_getitem", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_take_idx);
  __Pyx_XDECREF((PyObject *)__pyx_v_input_flat);
  __Pyx_XDECREF((PyObject *)__pyx_v_out_flat);
  __Pyx_XDECREF((PyObject *)__pyx_v_o);
  __Pyx_XDECREF(__pyx_v_arr_slices);
  __Pyx_XDECREF((PyObject *)__pyx_v_br);
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_prev_arr_i);
  __Pyx_XDECREF(__pyx_v_transp);
  __Pyx_XDECREF(__pyx_v_tmp);
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_strides);
  __Pyx_XDECREF(__pyx_v_stride);
  __Pyx_XDECREF(__pyx_v_flattened_indexes);
  __Pyx_XDECREF(__pyx_v_concat_shape);
  __Pyx_XDECREF(__pyx_v_out_flat_shape);
  __Pyx_XDECREF(__pyx_v_index);
  __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_71_adv_getitem(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_71_adv_getitem(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("_adv_getitem (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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_slices)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_adv_getitem", 1, 2, 2, 1); __PYX_ERR(1, 2094, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_adv_getitem") < 0)) __PYX_ERR(1, 2094, __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 = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_adv_getitem", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 2094, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._adv_getitem", __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(1, 2094, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_70_adv_getitem(__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_70_adv_getitem(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("_adv_getitem", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__adv_getitem(__pyx_v_a, __pyx_v_slices, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2094, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/core.pyx":2180
 * # -----------------------------------------------------------------------------
 * 
 * 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_73dot(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;
  Py_ssize_t __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":2186
 *     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":2187
 * 
 *     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":2189
 *     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(1, 2189, __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(1, 2189, __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_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2189, __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(1, 2189, __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(1, 2189, __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(1, 2189, __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":2190
 * 
 *     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__98, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2190, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __PYX_ERR(1, 2190, __pyx_L1_error)

    /* "cupy/core/core.pyx":2189
 *     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":2192
 *         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":2193
 * 
 *     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(1, 2193, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2193, __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(1, 2193, __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(1, 2193, __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(1, 2193, __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(1, 2193, __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":2192
 *         raise ValueError('Not supported dtype combination.')
 * 
 *     if a_ndim == 0 or b_ndim == 0:             # <<<<<<<<<<<<<<
 *         return multiply(a, b, out=out)
 * 
 */
  }

  /* "cupy/core/core.pyx":2195
 *         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":2196
 * 
 *     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":2197
 *     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":2198
 *     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":2199
 *     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(1, 2199, __pyx_L1_error)
    }

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

    /* "cupy/core/core.pyx":2201
 *         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(1, 2201, __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":2202
 *         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":2197
 *     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":2203
 *         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":2204
 *         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":2205
 *     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(1, 2205, __pyx_L1_error)
    }

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

    /* "cupy/core/core.pyx":2207
 *         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(1, 2207, __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":2208
 *         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":2203
 *         a = a._reshape(shape)
 *         a_ndim = 2
 *     if input_b_is_vec:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(b.size)
 */
  }

  /* "cupy/core/core.pyx":2210
 *         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":2211
 * 
 *     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":2213
 *     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":2214
 * 
 *     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__99, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2214, __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, 2214, __pyx_L1_error)

    /* "cupy/core/core.pyx":2213
 *     b_axis = b_ndim - 2
 * 
 *     if a._shape[a_axis] != b._shape[b_axis]:             # <<<<<<<<<<<<<<
 *         raise ValueError('Axis dimension mismatch')
 * 
 */
  }

  /* "cupy/core/core.pyx":2216
 *         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":2217
 * 
 *     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(1, 2217, __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":2216
 *         raise ValueError('Axis dimension mismatch')
 * 
 *     if a_axis:             # <<<<<<<<<<<<<<
 *         a = rollaxis(a, a_axis, 0)
 *     if b_axis:
 */
  }

  /* "cupy/core/core.pyx":2218
 *     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":2219
 *         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(1, 2219, __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":2218
 *     if a_axis:
 *         a = rollaxis(a, a_axis, 0)
 *     if b_axis:             # <<<<<<<<<<<<<<
 *         b = rollaxis(b, b_axis, 0)
 * 
 */
  }

  /* "cupy/core/core.pyx":2221
 *         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":2222
 * 
 *     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":2223
 *     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(1, 2223, __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(1, 2223, __pyx_L1_error)
    }
    __pyx_v_m = __Pyx_div_Py_ssize_t(__pyx_v_b->size, __pyx_v_k);

    /* "cupy/core/core.pyx":2224
 *     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(1, 2224, __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(1, 2224, __pyx_L1_error)
    }
    __pyx_v_n = __Pyx_div_Py_ssize_t(__pyx_v_a->size, __pyx_v_k);

    /* "cupy/core/core.pyx":2222
 * 
 *     k = a._shape[0]
 *     if k != 0:             # <<<<<<<<<<<<<<
 *         m = b.size // k
 *         n = a.size // k
 */
    goto __pyx_L14;
  }

  /* "cupy/core/core.pyx":2228
 *         # 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":2229
 *         # like NumPy.
 *         m = 0
 *         n = 0             # <<<<<<<<<<<<<<
 * 
 *     if not input_a_is_vec:
 */
    __pyx_v_n = 0;
  }
  __pyx_L14:;

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

    /* "cupy/core/core.pyx":2231
 *         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":2233
 *     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":2234
 *         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(1, 2234, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2233
 *     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":2235
 *     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":2236
 *         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":2237
 *     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__100, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2237, __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, 2237, __pyx_L1_error)

      /* "cupy/core/core.pyx":2236
 *         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":2238
 *         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":2239
 *             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__101, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2239, __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, 2239, __pyx_L1_error)

      /* "cupy/core/core.pyx":2238
 *         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":2235
 *     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":2241
 *             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(1, 2241, __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":2180
 * # -----------------------------------------------------------------------------
 * 
 * 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_73dot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_73dot(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);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 2180, __pyx_L3_error)
        }
        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(1, 2180, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        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(1, 2180, __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(1, 2180, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) __PYX_ERR(1, 2180, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(1, 2180, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_72dot(__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_72dot(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(1, 2180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":2244
 * 
 * 
 * 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_75_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":2247
 *                                  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(1, 2247, __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(1, 2247, __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(1, 2247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2247, __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_COMPILING_IN_CPYTHON && 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(1, 2247, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2247, __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(1, 2247, __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":2248
 *                                  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(1, 2248, __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(1, 2248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2248, __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(1, 2248, __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(1, 2248, __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, 2248, __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_COMPILING_IN_CPYTHON
        __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(1, 2248, __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(1, 2248, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(1, 2248, __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(1, 2248, __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(1, 2248, __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_CPYTHON
      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, 2248, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      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(1, 2248, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2248, __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(1, 2248, __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(1, 2248, __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(1, 2248, __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":2249
 *     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__103); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2249, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2249, __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(1, 2249, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 2249, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2249, __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(1, 2249, __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(1, 2249, __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__105); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2249, __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(1, 2249, __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(1, 2249, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 2249, __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(1, 2249, __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":2248
 *                                  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":2250
 *     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(1, 2250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2250, __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(1, 2250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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(1, 2250, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2250, __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(1, 2250, __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":2252
 *     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(1, 2252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2252, __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(1, 2252, __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(1, 2252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2252, __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(1, 2252, __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(1, 2252, __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(1, 2252, __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":2253
 * 
 *     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(1, 2253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":2254
 *     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":2244
 * 
 * 
 * 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_75_get_all_addresses(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_75_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);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 2244, __pyx_L3_error)
        }
        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(1, 2244, __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(1, 2244, __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(1, 2244, __pyx_L3_error)
    __pyx_v_shape = __pyx_convert_vector_from_py_size_t(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2245, __pyx_L3_error)
    __pyx_v_strides = __pyx_convert_vector_from_py_size_t(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2246, __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(1, 2244, __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_74_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_74_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(1, 2244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":2257
 * 
 * 
 * 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":2272
 *     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(1, 2272, __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(1, 2272, __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(1, 2272, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2273
 *     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(1, 2273, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2273, __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(1, 2273, __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(1, 2273, __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__107, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2273, __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":2274
 *     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(1, 2274, __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(1, 2274, __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":2275
 *         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":2272
 *     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":2277
 *         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(1, 2277, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_t_2, 0, -2L, NULL, NULL, &__pyx_slice__108, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2277, __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(1, 2277, __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(1, 2277, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_t_4, 0, -2L, NULL, NULL, &__pyx_slice__109, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2277, __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(1, 2277, __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(1, 2277, __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":2257
 * 
 * 
 * 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":2280
 * 
 * 
 * cpdef ndarray matmul(ndarray a, ndarray b):             # <<<<<<<<<<<<<<
 *     """ 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_77matmul(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) {
  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;
  int __pyx_v_batchCount;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = 0;
  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_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_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  std::vector<Py_ssize_t>  __pyx_t_8;
  std::vector<Py_ssize_t>  __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  int __pyx_t_13;
  size_t __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  Py_ssize_t __pyx_t_17;
  PyObject *(*__pyx_t_18)(PyObject *);
  PyObject *(*__pyx_t_19)(PyObject *);
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  __Pyx_RefNannySetupContext("matmul", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF((PyObject *)__pyx_v_b);

  /* "cupy/core/core.pyx":2313
 *     cdef ndarray out, ap, bp, outp
 * 
 *     dtype = numpy.result_type(a.dtype, b.dtype)             # <<<<<<<<<<<<<<
 * 
 *     if a.ndim == 1:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_result_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_4 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2313, __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(__pyx_v_a->dtype);
  __Pyx_GIVEREF(__pyx_v_a->dtype);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_a->dtype);
  __Pyx_INCREF(__pyx_v_b->dtype);
  __Pyx_GIVEREF(__pyx_v_b->dtype);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_b->dtype);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2313, __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_dtype = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2315
 *     dtype = numpy.result_type(a.dtype, b.dtype)
 * 
 *     if a.ndim == 1:             # <<<<<<<<<<<<<<
 *         a = a.reshape(1, len(a))
 *         a_part_outshape = ()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 2315, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":2316
 * 
 *     if a.ndim == 1:
 *         a = a.reshape(1, len(a))             # <<<<<<<<<<<<<<
 *         a_part_outshape = ()
 *     else:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2316, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_a)); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 2316, __pyx_L1_error)
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2316, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = NULL;
    __pyx_t_4 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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);
        __pyx_t_4 = 1;
      }
    }
    __pyx_t_7 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2316, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_4, __pyx_int_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_4, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2316, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 2316, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2317
 *     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":2315
 *     dtype = numpy.result_type(a.dtype, b.dtype)
 * 
 *     if a.ndim == 1:             # <<<<<<<<<<<<<<
 *         a = a.reshape(1, len(a))
 *         a_part_outshape = ()
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":2319
 *         a_part_outshape = ()
 *     else:
 *         a_part_outshape = (a.shape[-2],)             # <<<<<<<<<<<<<<
 *     if b.ndim == 1:
 *         b = b.reshape(len(b), 1)
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2319, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_3, -2L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2319, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2319, __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_v_a_part_outshape = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":2320
 *     else:
 *         a_part_outshape = (a.shape[-2],)
 *     if b.ndim == 1:             # <<<<<<<<<<<<<<
 *         b = b.reshape(len(b), 1)
 *         b_part_outshape = ()
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 2320, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":2321
 *         a_part_outshape = (a.shape[-2],)
 *     if b.ndim == 1:
 *         b = b.reshape(len(b), 1)             # <<<<<<<<<<<<<<
 *         b_part_outshape = ()
 *         ldout = 1
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2321, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_b)); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 2321, __pyx_L1_error)
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2321, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = NULL;
    __pyx_t_4 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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);
        __pyx_t_4 = 1;
      }
    }
    __pyx_t_2 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2321, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_4, __pyx_t_7);
    __Pyx_INCREF(__pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_4, __pyx_int_1);
    __pyx_t_7 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2321, __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(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 2321, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2322
 *     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":2323
 *         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":2320
 *     else:
 *         a_part_outshape = (a.shape[-2],)
 *     if b.ndim == 1:             # <<<<<<<<<<<<<<
 *         b = b.reshape(len(b), 1)
 *         b_part_outshape = ()
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":2325
 *         ldout = 1
 *     else:
 *         b_part_outshape = b.shape[-1:]             # <<<<<<<<<<<<<<
 *         ldout = b.shape[-1]
 * 
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2325, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_t_1, -1L, 0, NULL, NULL, &__pyx_slice__110, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2325, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_b_part_outshape = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2326
 *     else:
 *         b_part_outshape = b.shape[-1:]
 *         ldout = b.shape[-1]             # <<<<<<<<<<<<<<
 * 
 *     # expand dims
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_3, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_ldout = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":2329
 * 
 *     # expand dims
 *     if a.ndim < b.ndim:             # <<<<<<<<<<<<<<
 *         view = a.view()
 *         view._set_shape_and_strides(
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2329, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2329, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2329, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 2329, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":2330
 *     # expand dims
 *     if a.ndim < b.ndim:
 *         view = a.view()             # <<<<<<<<<<<<<<
 *         view._set_shape_and_strides(
 *             (1,) * (b.ndim - a.ndim) + a.shape,
 */
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2330, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_view = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2332
 *         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_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2332, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2332, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2332, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__111, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2332, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __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(1, 2332, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyNumber_Add(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2332, __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_8 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2332, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2333
 *         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_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2333, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2333, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2333, __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_t_1 = PyNumber_Multiply(__pyx_tuple__112, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2333, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2333, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2333, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_9 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2333, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2331
 *     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_2 = ((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_2)) __PYX_ERR(1, 2331, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2334
 *             (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":2329
 * 
 *     # expand dims
 *     if a.ndim < b.ndim:             # <<<<<<<<<<<<<<
 *         view = a.view()
 *         view._set_shape_and_strides(
 */
    goto __pyx_L5;
  }

  /* "cupy/core/core.pyx":2335
 *             (0,) * (b.ndim - a.ndim) + a.strides)
 *         a = view
 *     elif a.ndim > b.ndim:             # <<<<<<<<<<<<<<
 *         view = b.view()
 *         view._set_shape_and_strides(
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2335, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 2335, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":2336
 *         a = view
 *     elif a.ndim > b.ndim:
 *         view = b.view()             # <<<<<<<<<<<<<<
 *         view._set_shape_and_strides(
 *             (1,) * (a.ndim - b.ndim) + b.shape,
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_b->__pyx_vtab)->view(__pyx_v_b, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2336, __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":2338
 *         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_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__113, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2338, __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_9 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2338, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2339
 *         view._set_shape_and_strides(
 *             (1,) * (a.ndim - b.ndim) + b.shape,
 *             (0,) * (a.ndim - b.ndim) + b.strides)             # <<<<<<<<<<<<<<
 *         b = view
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2339, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2339, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2339, __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_t_2 = PyNumber_Multiply(__pyx_tuple__114, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2339, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_strides); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2339, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyNumber_Add(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2339, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2339, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2337
 *     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_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_t_9, __pyx_t_8, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2337, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2340
 *             (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":2335
 *             (0,) * (b.ndim - a.ndim) + a.strides)
 *         a = view
 *     elif a.ndim > b.ndim:             # <<<<<<<<<<<<<<
 *         view = b.view()
 *         view._set_shape_and_strides(
 */
  }
  __pyx_L5:;

  /* "cupy/core/core.pyx":2342
 *         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_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_maximum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __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(1, 2342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = __Pyx_PyObject_GetSlice(__pyx_t_3, 0, -2L, NULL, NULL, &__pyx_slice__115, 0, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_t_3, 0, -2L, NULL, NULL, &__pyx_slice__116, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && 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;
    }
  }
  __pyx_t_10 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (__pyx_t_3) {
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3); __pyx_t_3 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_4, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_4, __pyx_t_5);
  __pyx_t_7 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_broatcast_pre_shape = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2344
 *     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_1 = PySequence_List(__pyx_v_broatcast_pre_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyList_Extend(__pyx_t_1, __pyx_v_a_part_outshape) < 0) __PYX_ERR(1, 2344, __pyx_L1_error)
  if (__Pyx_PyList_Extend(__pyx_t_1, __pyx_v_b_part_outshape) < 0) __PYX_ERR(1, 2344, __pyx_L1_error)
  {
    PyObject *__pyx_temp = PyList_AsTuple(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_temp; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2344, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_v_out_shape = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2346
 *     out_shape = (*broatcast_pre_shape, *a_part_outshape, *b_part_outshape)
 * 
 *     a = ascontiguousarray(a, dtype=dtype)             # <<<<<<<<<<<<<<
 *     b = ascontiguousarray(b, dtype=dtype)
 * 
 */
  __pyx_t_11.__pyx_n = 1;
  __pyx_t_11.dtype = __pyx_v_dtype;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_ascontiguousarray(__pyx_v_a, 0, &__pyx_t_11)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2346, __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":2347
 * 
 *     a = ascontiguousarray(a, dtype=dtype)
 *     b = ascontiguousarray(b, dtype=dtype)             # <<<<<<<<<<<<<<
 * 
 *     # broadcast
 */
  __pyx_t_11.__pyx_n = 1;
  __pyx_t_11.dtype = __pyx_v_dtype;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_ascontiguousarray(__pyx_v_b, 0, &__pyx_t_11)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2347, __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":2350
 * 
 *     # broadcast
 *     a_strides = list(a.strides)             # <<<<<<<<<<<<<<
 *     a_shape = list(a.shape)
 *     b_strides = list(b.strides)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_a_strides = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2351
 *     # broadcast
 *     a_strides = list(a.strides)
 *     a_shape = list(a.shape)             # <<<<<<<<<<<<<<
 *     b_strides = list(b.strides)
 *     b_shape = list(b.shape)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PySequence_List(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_a_shape = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2352
 *     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_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_strides); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_b_strides = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2353
 *     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_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PySequence_List(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_b_shape = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2354
 *     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(1, 2354, __pyx_L1_error)
  __pyx_t_12 = (__pyx_t_4 - 2);
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_12; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "cupy/core/core.pyx":2355
 *     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_1 = __Pyx_GetItemInt_List(__pyx_v_a_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(1, 2355, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_13) {
    } else {
      __pyx_t_6 = __pyx_t_13;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_broatcast_pre_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2355, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(1, 2355, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __pyx_t_13;
    __pyx_L9_bool_binop_done:;
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":2356
 *     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(1, 2356, __pyx_L1_error)

      /* "cupy/core/core.pyx":2357
 *         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_1 = __Pyx_GetItemInt(__pyx_v_broatcast_pre_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2357, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(__Pyx_SetItemInt(__pyx_v_a_shape, __pyx_v_i, __pyx_t_1, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(1, 2357, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":2355
 *     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":2358
 *             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_12 = PyList_GET_SIZE(__pyx_v_b_strides); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(1, 2358, __pyx_L1_error)
  __pyx_t_4 = (__pyx_t_12 - 2);
  for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_4; __pyx_t_12+=1) {
    __pyx_v_i = __pyx_t_12;

    /* "cupy/core/core.pyx":2359
 *             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_1 = __Pyx_GetItemInt_List(__pyx_v_b_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2359, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2359, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(1, 2359, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_13) {
    } else {
      __pyx_t_6 = __pyx_t_13;
      goto __pyx_L14_bool_binop_done;
    }
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_broatcast_pre_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2359, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2359, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(1, 2359, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __pyx_t_13;
    __pyx_L14_bool_binop_done:;
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":2360
 *     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(1, 2360, __pyx_L1_error)

      /* "cupy/core/core.pyx":2361
 *         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_1 = __Pyx_GetItemInt(__pyx_v_broatcast_pre_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2361, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(__Pyx_SetItemInt(__pyx_v_b_shape, __pyx_v_i, __pyx_t_1, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(1, 2361, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":2359
 *             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":2363
 *             b_shape[i] = broatcast_pre_shape[i]
 * 
 *     view = a.view()             # <<<<<<<<<<<<<<
 *     view._set_shape_and_strides(a_shape, a_strides)
 *     a = 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(1, 2363, __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":2364
 * 
 *     view = a.view()
 *     view._set_shape_and_strides(a_shape, a_strides)             # <<<<<<<<<<<<<<
 *     a = view
 *     view = b.view()
 */
  __pyx_t_8 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_a_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2364, __pyx_L1_error)
  __pyx_t_9 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_a_strides); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2364, __pyx_L1_error)
  __pyx_t_1 = ((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_1)) __PYX_ERR(1, 2364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2365
 *     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":2366
 *     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_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_b->__pyx_vtab)->view(__pyx_v_b, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2366, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_view, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2367
 *     a = view
 *     view = b.view()
 *     view._set_shape_and_strides(b_shape, b_strides)             # <<<<<<<<<<<<<<
 *     b = view
 * 
 */
  __pyx_t_9 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_b_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2367, __pyx_L1_error)
  __pyx_t_8 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_b_strides); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2367, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_t_9, __pyx_t_8, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2368
 *     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":2370
 *     b = view
 * 
 *     out = ndarray(out_shape, dtype=dtype)             # <<<<<<<<<<<<<<
 *     out.data.memset(0, out.nbytes)
 * 
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_out_shape);
  __Pyx_GIVEREF(__pyx_v_out_shape);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_out_shape);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 2370, __pyx_L1_error)
  __pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10);
  __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":2371
 * 
 *     out = ndarray(out_shape, dtype=dtype)
 *     out.data.memset(0, out.nbytes)             # <<<<<<<<<<<<<<
 * 
 *     out_view = out.view()
 */
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_14 = __Pyx_PyInt_As_size_t(__pyx_t_10); if (unlikely((__pyx_t_14 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 2371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_out->data->__pyx_vtab)->memset(__pyx_v_out->data, 0, __pyx_t_14, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":2373
 *     out.data.memset(0, out.nbytes)
 * 
 *     out_view = out.view()             # <<<<<<<<<<<<<<
 *     out_view_shape = out.shape
 *     out_view_strides = out.strides
 */
  __pyx_t_10 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_out->__pyx_vtab)->view(__pyx_v_out, 0, NULL)); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_v_out_view = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10);
  __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":2374
 * 
 *     out_view = out.view()
 *     out_view_shape = out.shape             # <<<<<<<<<<<<<<
 *     out_view_strides = out.strides
 *     if a_part_outshape == ():
 */
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_v_out_view_shape = __pyx_t_10;
  __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":2375
 *     out_view = out.view()
 *     out_view_shape = out.shape
 *     out_view_strides = out.strides             # <<<<<<<<<<<<<<
 *     if a_part_outshape == ():
 *         out_view_shape += (1,)
 */
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_strides); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_v_out_view_strides = __pyx_t_10;
  __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":2376
 *     out_view_shape = out.shape
 *     out_view_strides = out.strides
 *     if a_part_outshape == ():             # <<<<<<<<<<<<<<
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 */
  __pyx_t_10 = PyObject_RichCompare(__pyx_v_a_part_outshape, __pyx_empty_tuple, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2376, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 2376, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":2377
 *     out_view_strides = out.strides
 *     if a_part_outshape == ():
 *         out_view_shape += (1,)             # <<<<<<<<<<<<<<
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():
 */
    __pyx_t_10 = PyNumber_InPlaceAdd(__pyx_v_out_view_shape, __pyx_tuple__117); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2377, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF_SET(__pyx_v_out_view_shape, __pyx_t_10);
    __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":2378
 *     if a_part_outshape == ():
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)             # <<<<<<<<<<<<<<
 *     if b_part_outshape == ():
 *         out_view_shape += (1,)
 */
    __pyx_t_10 = PyNumber_InPlaceAdd(__pyx_v_out_view_strides, __pyx_tuple__118); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2378, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF_SET(__pyx_v_out_view_strides, __pyx_t_10);
    __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":2376
 *     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":2379
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():             # <<<<<<<<<<<<<<
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 */
  __pyx_t_10 = PyObject_RichCompare(__pyx_v_b_part_outshape, __pyx_empty_tuple, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2379, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 2379, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":2380
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():
 *         out_view_shape += (1,)             # <<<<<<<<<<<<<<
 *         out_view_strides += (0,)
 * 
 */
    __pyx_t_10 = PyNumber_InPlaceAdd(__pyx_v_out_view_shape, __pyx_tuple__119); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2380, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF_SET(__pyx_v_out_view_shape, __pyx_t_10);
    __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":2381
 *     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_10 = PyNumber_InPlaceAdd(__pyx_v_out_view_strides, __pyx_tuple__120); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2381, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF_SET(__pyx_v_out_view_strides, __pyx_t_10);
    __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":2379
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():             # <<<<<<<<<<<<<<
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 */
  }

  /* "cupy/core/core.pyx":2383
 *         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_8 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_out_view_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2383, __pyx_L1_error)
  __pyx_t_9 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_out_view_strides); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2383, __pyx_L1_error)
  __pyx_t_10 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_out_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_out_view, __pyx_t_8, __pyx_t_9, 0, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":2386
 * 
 *     # (A B)^T = B^T A^T
 *     a, b = b, a             # <<<<<<<<<<<<<<
 * 
 *     lda = a.shape[-1]
 */
  __pyx_t_15 = ((PyObject *)__pyx_v_b);
  __pyx_t_16 = ((PyObject *)__pyx_v_a);
  __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_15);
  __pyx_t_15 = 0;
  __pyx_v_b = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_16);
  __pyx_t_16 = 0;

  /* "cupy/core/core.pyx":2388
 *     a, b = b, a
 * 
 *     lda = a.shape[-1]             # <<<<<<<<<<<<<<
 *     ldb = b.shape[-1]
 * 
 */
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_10, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_v_lda = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2389
 * 
 *     lda = a.shape[-1]
 *     ldb = b.shape[-1]             # <<<<<<<<<<<<<<
 * 
 *     *la, ka, n = a.shape
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_2, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_ldb = __pyx_t_10;
  __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":2391
 *     ldb = b.shape[-1]
 * 
 *     *la, ka, n = a.shape             # <<<<<<<<<<<<<<
 *     *lb, m, kb = b.shape
 * 
 */
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_2 = PySequence_List(__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_4 = PyList_GET_SIZE(__pyx_t_2);
  if (unlikely(__pyx_t_4 < 2)) {
    __Pyx_RaiseNeedMoreValuesError(0+__pyx_t_4); __PYX_ERR(1, 2391, __pyx_L1_error)
  }
  #if CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4-1); 
  ((PyVarObject*)__pyx_t_2)->ob_size--;
  #else
  __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4-1); 
  #endif
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 2391, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4-2); 
  ((PyVarObject*)__pyx_t_2)->ob_size--;
  #else
  __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_4-2); 
  #endif
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_17 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_17 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 2391, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  #if !CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_7 = PySequence_GetSlice(__pyx_t_2, 0, __pyx_t_4-2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2);
  __pyx_t_2 = __pyx_t_7; __pyx_t_7 = NULL;
  #else

  #endif
  __pyx_v_la = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_v_ka = __pyx_t_17;
  __pyx_v_n = __pyx_t_12;

  /* "cupy/core/core.pyx":2392
 * 
 *     *la, ka, n = a.shape
 *     *lb, m, kb = b.shape             # <<<<<<<<<<<<<<
 * 
 *     assert ka == kb
 */
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2392, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_1 = PySequence_List(__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2392, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_12 = PyList_GET_SIZE(__pyx_t_1);
  if (unlikely(__pyx_t_12 < 2)) {
    __Pyx_RaiseNeedMoreValuesError(0+__pyx_t_12); __PYX_ERR(1, 2392, __pyx_L1_error)
  }
  #if CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_12-1); 
  ((PyVarObject*)__pyx_t_1)->ob_size--;
  #else
  __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_12-1); 
  #endif
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_17 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_17 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 2392, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_12-2); 
  ((PyVarObject*)__pyx_t_1)->ob_size--;
  #else
  __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_12-2); 
  #endif
  __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(1, 2392, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  #if !CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_7 = PySequence_GetSlice(__pyx_t_1, 0, __pyx_t_12-2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2392, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_7; __pyx_t_7 = NULL;
  #else

  #endif
  __pyx_v_lb = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_m = __pyx_t_4;
  __pyx_v_kb = __pyx_t_17;

  /* "cupy/core/core.pyx":2394
 *     *lb, m, kb = b.shape
 * 
 *     assert ka == kb             # <<<<<<<<<<<<<<
 *     for la_, lb_ in zip(la, lb):
 *         assert la_ == lb_ or la_ == 1 or lb_ == 1
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_ka == __pyx_v_kb) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(1, 2394, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/core/core.pyx":2395
 * 
 *     assert ka == kb
 *     for la_, lb_ in zip(la, lb):             # <<<<<<<<<<<<<<
 *         assert la_ == lb_ or la_ == 1 or lb_ == 1
 * 
 */
  __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2395, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_INCREF(__pyx_v_la);
  __Pyx_GIVEREF(__pyx_v_la);
  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_la);
  __Pyx_INCREF(__pyx_v_lb);
  __Pyx_GIVEREF(__pyx_v_lb);
  PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_lb);
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2395, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
    __pyx_t_10 = __pyx_t_5; __Pyx_INCREF(__pyx_t_10); __pyx_t_17 = 0;
    __pyx_t_18 = NULL;
  } else {
    __pyx_t_17 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2395, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_18 = Py_TYPE(__pyx_t_10)->tp_iternext; if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 2395, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  for (;;) {
    if (likely(!__pyx_t_18)) {
      if (likely(PyList_CheckExact(__pyx_t_10))) {
        if (__pyx_t_17 >= PyList_GET_SIZE(__pyx_t_10)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_17); __Pyx_INCREF(__pyx_t_5); __pyx_t_17++; if (unlikely(0 < 0)) __PYX_ERR(1, 2395, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_10, __pyx_t_17); __pyx_t_17++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2395, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_17 >= PyTuple_GET_SIZE(__pyx_t_10)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_17); __Pyx_INCREF(__pyx_t_5); __pyx_t_17++; if (unlikely(0 < 0)) __PYX_ERR(1, 2395, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_10, __pyx_t_17); __pyx_t_17++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2395, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_18(__pyx_t_10);
      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, 2395, __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_CPYTHON
      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, 2395, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      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(1, 2395, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2395, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2395, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_19 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_2 = __pyx_t_19(__pyx_t_7); if (unlikely(!__pyx_t_2)) goto __pyx_L20_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      index = 1; __pyx_t_1 = __pyx_t_19(__pyx_t_7); if (unlikely(!__pyx_t_1)) goto __pyx_L20_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_19(__pyx_t_7), 2) < 0) __PYX_ERR(1, 2395, __pyx_L1_error)
      __pyx_t_19 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L21_unpacking_done;
      __pyx_L20_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_19 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(1, 2395, __pyx_L1_error)
      __pyx_L21_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_la_, __pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_lb_, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2396
 *     assert ka == kb
 *     for la_, lb_ in zip(la, lb):
 *         assert la_ == lb_ or la_ == 1 or lb_ == 1             # <<<<<<<<<<<<<<
 * 
 *     batchCount = 1  # batchCount = numpy.prod(la)
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_la_, __pyx_v_lb_, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2396, __pyx_L1_error)
      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(1, 2396, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!__pyx_t_13) {
      } else {
        __pyx_t_6 = __pyx_t_13;
        goto __pyx_L22_bool_binop_done;
      }
      __pyx_t_5 = __Pyx_PyInt_EqObjC(__pyx_v_la_, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2396, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(1, 2396, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!__pyx_t_13) {
      } else {
        __pyx_t_6 = __pyx_t_13;
        goto __pyx_L22_bool_binop_done;
      }
      __pyx_t_5 = __Pyx_PyInt_EqObjC(__pyx_v_lb_, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2396, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(1, 2396, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __pyx_t_13;
      __pyx_L22_bool_binop_done:;
      if (unlikely(!__pyx_t_6)) {
        PyErr_SetNone(PyExc_AssertionError);
        __PYX_ERR(1, 2396, __pyx_L1_error)
      }
    }
    #endif

    /* "cupy/core/core.pyx":2395
 * 
 *     assert ka == kb
 *     for la_, lb_ in zip(la, lb):             # <<<<<<<<<<<<<<
 *         assert la_ == lb_ or la_ == 1 or lb_ == 1
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":2398
 *         assert la_ == lb_ or la_ == 1 or lb_ == 1
 * 
 *     batchCount = 1  # batchCount = numpy.prod(la)             # <<<<<<<<<<<<<<
 *     for i in la:
 *         batchCount *= i
 */
  __pyx_v_batchCount = 1;

  /* "cupy/core/core.pyx":2399
 * 
 *     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_10 = __pyx_v_la; __Pyx_INCREF(__pyx_t_10); __pyx_t_17 = 0;
    __pyx_t_18 = NULL;
  } else {
    __pyx_t_17 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_v_la); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_18 = Py_TYPE(__pyx_t_10)->tp_iternext; if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 2399, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_18)) {
      if (likely(PyList_CheckExact(__pyx_t_10))) {
        if (__pyx_t_17 >= PyList_GET_SIZE(__pyx_t_10)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_17); __Pyx_INCREF(__pyx_t_5); __pyx_t_17++; if (unlikely(0 < 0)) __PYX_ERR(1, 2399, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_10, __pyx_t_17); __pyx_t_17++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2399, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_17 >= PyTuple_GET_SIZE(__pyx_t_10)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_17); __Pyx_INCREF(__pyx_t_5); __pyx_t_17++; if (unlikely(0 < 0)) __PYX_ERR(1, 2399, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_10, __pyx_t_17); __pyx_t_17++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2399, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_18(__pyx_t_10);
      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, 2399, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 2399, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_i = __pyx_t_4;

    /* "cupy/core/core.pyx":2400
 *     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":2399
 * 
 *     batchCount = 1  # batchCount = numpy.prod(la)
 *     for i in la:             # <<<<<<<<<<<<<<
 *         batchCount *= i
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":2402
 *         batchCount *= i
 * 
 *     ap = _mat_ptrs(a)             # <<<<<<<<<<<<<<
 *     bp = _mat_ptrs(b)
 *     outp = _mat_ptrs(out_view)
 */
  __pyx_t_10 = ((PyObject *)__pyx_f_4cupy_4core_4core__mat_ptrs(__pyx_v_a)); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_v_ap = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10);
  __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":2403
 * 
 *     ap = _mat_ptrs(a)
 *     bp = _mat_ptrs(b)             # <<<<<<<<<<<<<<
 *     outp = _mat_ptrs(out_view)
 * 
 */
  __pyx_t_10 = ((PyObject *)__pyx_f_4cupy_4core_4core__mat_ptrs(__pyx_v_b)); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_v_bp = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10);
  __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":2404
 *     ap = _mat_ptrs(a)
 *     bp = _mat_ptrs(b)
 *     outp = _mat_ptrs(out_view)             # <<<<<<<<<<<<<<
 * 
 *     if dtype == numpy.float32:
 */
  __pyx_t_10 = ((PyObject *)__pyx_f_4cupy_4core_4core__mat_ptrs(__pyx_v_out_view)); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_v_outp = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10);
  __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":2406
 *     outp = _mat_ptrs(out_view)
 * 
 *     if dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *         cuda.cublas.sgemmBatched(
 *             cuda.Device().cublas_handle,
 */
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_float32); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2406, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 2406, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":2407
 * 
 *     if dtype == numpy.float32:
 *         cuda.cublas.sgemmBatched(             # <<<<<<<<<<<<<<
 *             cuda.Device().cublas_handle,
 *             0,  # transa
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_cublas); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sgemmBatched); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2408
 *     if dtype == numpy.float32:
 *         cuda.cublas.sgemmBatched(
 *             cuda.Device().cublas_handle,             # <<<<<<<<<<<<<<
 *             0,  # transa
 *             0,  # transb
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Device); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (__pyx_t_2) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2408, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2408, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_cublas_handle); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2411
 *             0,  # transa
 *             0,  # transb
 *             n, m, ka, 1.0,             # <<<<<<<<<<<<<<
 *             ap.data.ptr, lda,
 *             bp.data.ptr, ldb,
 */
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ka); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "cupy/core/core.pyx":2412
 *             0,  # transb
 *             n, m, ka, 1.0,
 *             ap.data.ptr, lda,             # <<<<<<<<<<<<<<
 *             bp.data.ptr, ldb,
 *             0.0, outp.data.ptr, ldout, batchCount)
 */
    __pyx_t_20 = __Pyx_PyInt_FromSize_t(__pyx_v_ap->data->ptr); if (unlikely(!__pyx_t_20)) __PYX_ERR(1, 2412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_20);

    /* "cupy/core/core.pyx":2413
 *             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_21 = __Pyx_PyInt_FromSize_t(__pyx_v_bp->data->ptr); if (unlikely(!__pyx_t_21)) __PYX_ERR(1, 2413, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);

    /* "cupy/core/core.pyx":2414
 *             ap.data.ptr, lda,
 *             bp.data.ptr, ldb,
 *             0.0, outp.data.ptr, ldout, batchCount)             # <<<<<<<<<<<<<<
 *     elif dtype == numpy.float64:
 *         cuda.cublas.dgemmBatched(
 */
    __pyx_t_22 = __Pyx_PyInt_FromSize_t(__pyx_v_outp->data->ptr); if (unlikely(!__pyx_t_22)) __PYX_ERR(1, 2414, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    __pyx_t_23 = __Pyx_PyInt_From_int(__pyx_v_batchCount); if (unlikely(!__pyx_t_23)) __PYX_ERR(1, 2414, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    __pyx_t_24 = NULL;
    __pyx_t_17 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_24)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_24);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_17 = 1;
      }
    }
    __pyx_t_25 = PyTuple_New(15+__pyx_t_17); if (unlikely(!__pyx_t_25)) __PYX_ERR(1, 2407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    if (__pyx_t_24) {
      __Pyx_GIVEREF(__pyx_t_24); PyTuple_SET_ITEM(__pyx_t_25, 0, __pyx_t_24); __pyx_t_24 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_25, 0+__pyx_t_17, __pyx_t_7);
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_25, 1+__pyx_t_17, __pyx_int_0);
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_25, 2+__pyx_t_17, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_25, 3+__pyx_t_17, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_25, 4+__pyx_t_17, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_25, 5+__pyx_t_17, __pyx_t_3);
    __Pyx_INCREF(__pyx_float_1_0);
    __Pyx_GIVEREF(__pyx_float_1_0);
    PyTuple_SET_ITEM(__pyx_t_25, 6+__pyx_t_17, __pyx_float_1_0);
    __Pyx_GIVEREF(__pyx_t_20);
    PyTuple_SET_ITEM(__pyx_t_25, 7+__pyx_t_17, __pyx_t_20);
    __Pyx_INCREF(__pyx_v_lda);
    __Pyx_GIVEREF(__pyx_v_lda);
    PyTuple_SET_ITEM(__pyx_t_25, 8+__pyx_t_17, __pyx_v_lda);
    __Pyx_GIVEREF(__pyx_t_21);
    PyTuple_SET_ITEM(__pyx_t_25, 9+__pyx_t_17, __pyx_t_21);
    __Pyx_INCREF(__pyx_v_ldb);
    __Pyx_GIVEREF(__pyx_v_ldb);
    PyTuple_SET_ITEM(__pyx_t_25, 10+__pyx_t_17, __pyx_v_ldb);
    __Pyx_INCREF(__pyx_float_0_0);
    __Pyx_GIVEREF(__pyx_float_0_0);
    PyTuple_SET_ITEM(__pyx_t_25, 11+__pyx_t_17, __pyx_float_0_0);
    __Pyx_GIVEREF(__pyx_t_22);
    PyTuple_SET_ITEM(__pyx_t_25, 12+__pyx_t_17, __pyx_t_22);
    __Pyx_INCREF(__pyx_v_ldout);
    __Pyx_GIVEREF(__pyx_v_ldout);
    PyTuple_SET_ITEM(__pyx_t_25, 13+__pyx_t_17, __pyx_v_ldout);
    __Pyx_GIVEREF(__pyx_t_23);
    PyTuple_SET_ITEM(__pyx_t_25, 14+__pyx_t_17, __pyx_t_23);
    __pyx_t_7 = 0;
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_20 = 0;
    __pyx_t_21 = 0;
    __pyx_t_22 = 0;
    __pyx_t_23 = 0;
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_25, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":2406
 *     outp = _mat_ptrs(out_view)
 * 
 *     if dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *         cuda.cublas.sgemmBatched(
 *             cuda.Device().cublas_handle,
 */
    goto __pyx_L27;
  }

  /* "cupy/core/core.pyx":2415
 *             bp.data.ptr, ldb,
 *             0.0, outp.data.ptr, ldout, batchCount)
 *     elif dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *         cuda.cublas.dgemmBatched(
 *             cuda.Device().cublas_handle,
 */
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2415, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 2415, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":2416
 *             0.0, outp.data.ptr, ldout, batchCount)
 *     elif dtype == numpy.float64:
 *         cuda.cublas.dgemmBatched(             # <<<<<<<<<<<<<<
 *             cuda.Device().cublas_handle,
 *             0,  # transa
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_cublas); if (unlikely(!__pyx_t_25)) __PYX_ERR(1, 2416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_n_s_dgemmBatched); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

    /* "cupy/core/core.pyx":2417
 *     elif dtype == numpy.float64:
 *         cuda.cublas.dgemmBatched(
 *             cuda.Device().cublas_handle,             # <<<<<<<<<<<<<<
 *             0,  # transa
 *             0,  # transb
 */
    __pyx_t_23 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_23)) __PYX_ERR(1, 2417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_n_s_Device); if (unlikely(!__pyx_t_22)) __PYX_ERR(1, 2417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
    __pyx_t_23 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_22))) {
      __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_22);
      if (likely(__pyx_t_23)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_22);
        __Pyx_INCREF(__pyx_t_23);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_22, function);
      }
    }
    if (__pyx_t_23) {
      __pyx_t_25 = __Pyx_PyObject_CallOneArg(__pyx_t_22, __pyx_t_23); if (unlikely(!__pyx_t_25)) __PYX_ERR(1, 2417, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
    } else {
      __pyx_t_25 = __Pyx_PyObject_CallNoArg(__pyx_t_22); if (unlikely(!__pyx_t_25)) __PYX_ERR(1, 2417, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_25);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
    __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_n_s_cublas_handle); if (unlikely(!__pyx_t_22)) __PYX_ERR(1, 2417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

    /* "cupy/core/core.pyx":2420
 *             0,  # transa
 *             0,  # transb
 *             n, m, ka, 1.0,             # <<<<<<<<<<<<<<
 *             ap.data.ptr, lda,
 *             bp.data.ptr, ldb,
 */
    __pyx_t_25 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_25)) __PYX_ERR(1, 2420, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __pyx_t_23 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_23)) __PYX_ERR(1, 2420, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    __pyx_t_21 = PyInt_FromSsize_t(__pyx_v_ka); if (unlikely(!__pyx_t_21)) __PYX_ERR(1, 2420, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);

    /* "cupy/core/core.pyx":2421
 *             0,  # transb
 *             n, m, ka, 1.0,
 *             ap.data.ptr, lda,             # <<<<<<<<<<<<<<
 *             bp.data.ptr, ldb,
 *             0.0, outp.data.ptr, ldout, batchCount)
 */
    __pyx_t_20 = __Pyx_PyInt_FromSize_t(__pyx_v_ap->data->ptr); if (unlikely(!__pyx_t_20)) __PYX_ERR(1, 2421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_20);

    /* "cupy/core/core.pyx":2422
 *             n, m, ka, 1.0,
 *             ap.data.ptr, lda,
 *             bp.data.ptr, ldb,             # <<<<<<<<<<<<<<
 *             0.0, outp.data.ptr, ldout, batchCount)
 *     # elif dtype == numpy.complex64:
 */
    __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_bp->data->ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2422, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "cupy/core/core.pyx":2423
 *             ap.data.ptr, lda,
 *             bp.data.ptr, ldb,
 *             0.0, outp.data.ptr, ldout, batchCount)             # <<<<<<<<<<<<<<
 *     # elif dtype == numpy.complex64:
 *     #     cuda.cublas.cgemmBatched(
 */
    __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_outp->data->ptr); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2423, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_batchCount); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2423, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = NULL;
    __pyx_t_17 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && 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_17 = 1;
      }
    }
    __pyx_t_24 = PyTuple_New(15+__pyx_t_17); if (unlikely(!__pyx_t_24)) __PYX_ERR(1, 2416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_24);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_22);
    PyTuple_SET_ITEM(__pyx_t_24, 0+__pyx_t_17, __pyx_t_22);
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_24, 1+__pyx_t_17, __pyx_int_0);
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_24, 2+__pyx_t_17, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_t_25);
    PyTuple_SET_ITEM(__pyx_t_24, 3+__pyx_t_17, __pyx_t_25);
    __Pyx_GIVEREF(__pyx_t_23);
    PyTuple_SET_ITEM(__pyx_t_24, 4+__pyx_t_17, __pyx_t_23);
    __Pyx_GIVEREF(__pyx_t_21);
    PyTuple_SET_ITEM(__pyx_t_24, 5+__pyx_t_17, __pyx_t_21);
    __Pyx_INCREF(__pyx_float_1_0);
    __Pyx_GIVEREF(__pyx_float_1_0);
    PyTuple_SET_ITEM(__pyx_t_24, 6+__pyx_t_17, __pyx_float_1_0);
    __Pyx_GIVEREF(__pyx_t_20);
    PyTuple_SET_ITEM(__pyx_t_24, 7+__pyx_t_17, __pyx_t_20);
    __Pyx_INCREF(__pyx_v_lda);
    __Pyx_GIVEREF(__pyx_v_lda);
    PyTuple_SET_ITEM(__pyx_t_24, 8+__pyx_t_17, __pyx_v_lda);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_24, 9+__pyx_t_17, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_ldb);
    __Pyx_GIVEREF(__pyx_v_ldb);
    PyTuple_SET_ITEM(__pyx_t_24, 10+__pyx_t_17, __pyx_v_ldb);
    __Pyx_INCREF(__pyx_float_0_0);
    __Pyx_GIVEREF(__pyx_float_0_0);
    PyTuple_SET_ITEM(__pyx_t_24, 11+__pyx_t_17, __pyx_float_0_0);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_24, 12+__pyx_t_17, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_ldout);
    __Pyx_GIVEREF(__pyx_v_ldout);
    PyTuple_SET_ITEM(__pyx_t_24, 13+__pyx_t_17, __pyx_v_ldout);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_24, 14+__pyx_t_17, __pyx_t_1);
    __pyx_t_22 = 0;
    __pyx_t_25 = 0;
    __pyx_t_23 = 0;
    __pyx_t_21 = 0;
    __pyx_t_20 = 0;
    __pyx_t_3 = 0;
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_24, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":2415
 *             bp.data.ptr, ldb,
 *             0.0, outp.data.ptr, ldout, batchCount)
 *     elif dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *         cuda.cublas.dgemmBatched(
 *             cuda.Device().cublas_handle,
 */
    goto __pyx_L27;
  }

  /* "cupy/core/core.pyx":2443
 *     #         0, outp.data.ptr, ldout, batchCount)
 *     else:
 *         raise TypeError(dtype, a.dtype, b.dtype)             # <<<<<<<<<<<<<<
 * 
 *     return out
 */
  /*else*/ {
    __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2443, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_dtype);
    __Pyx_INCREF(__pyx_v_a->dtype);
    __Pyx_GIVEREF(__pyx_v_a->dtype);
    PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_a->dtype);
    __Pyx_INCREF(__pyx_v_b->dtype);
    __Pyx_GIVEREF(__pyx_v_b->dtype);
    PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_v_b->dtype);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2443, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(1, 2443, __pyx_L1_error)
  }
  __pyx_L27:;

  /* "cupy/core/core.pyx":2445
 *         raise TypeError(dtype, a.dtype, b.dtype)
 * 
 *     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":2280
 * 
 * 
 * cpdef ndarray matmul(ndarray a, ndarray b):             # <<<<<<<<<<<<<<
 *     """ 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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_24);
  __Pyx_XDECREF(__pyx_t_25);
  __Pyx_AddTraceback("cupy.core.core.matmul", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_out);
  __Pyx_XDECREF((PyObject *)__pyx_v_ap);
  __Pyx_XDECREF((PyObject *)__pyx_v_bp);
  __Pyx_XDECREF((PyObject *)__pyx_v_outp);
  __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_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_77matmul(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_76matmul[] = " 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 float32 (float64, comlplex64\n        and complex128 follow later). This means, that\n        numpy.result_type(a.dtype, b.dtype) have to be numpy.float32.\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    .. seealso:: :func:`numpy.matmul`\n\n    ";
static PyObject *__pyx_pw_4cupy_4core_4core_77matmul(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;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("matmul (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_b,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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_b)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("matmul", 1, 2, 2, 1); __PYX_ERR(1, 2280, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "matmul") < 0)) __PYX_ERR(1, 2280, __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_b = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("matmul", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 2280, __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(1, 2280, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) __PYX_ERR(1, 2280, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_76matmul(__pyx_self, __pyx_v_a, __pyx_v_b);

  /* 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_76matmul(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) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("matmul", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_matmul(__pyx_v_a, __pyx_v_b, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":2451
 * 
 * 
 * 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_79tensordot_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;
  int __pyx_v_transa;
  int __pyx_v_transb;
  int __pyx_v_lda;
  int __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;
  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;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  __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":2459
 *     cdef str dtype, ret_dtype
 *     cdef bint use_sgemmEx
 *     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(1, 2459, __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(1, 2459, __pyx_L1_error)
  __pyx_v_ret_dtype = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2460
 *     cdef bint use_sgemmEx
 *     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(1, 2460, __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(1, 2460, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2461
 *     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(1, 2461, __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(1, 2461, __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(1, 2461, __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_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2461, __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(1, 2461, __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(1, 2461, __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(1, 2461, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_ret_dtype, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2460
 *     cdef bint use_sgemmEx
 *     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":2463
 *         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":2464
 * 
 *     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":2465
 *     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(1, 2465, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2465, __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(1, 2465, __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(1, 2465, __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(1, 2465, __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":2464
 * 
 *     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":2466
 *         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(1, 2466, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2467
 *             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":2463
 *         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":2470
 * 
 *     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":2471
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:
 *         _cuda_runtime_version = runtime.runtimeGetVersion()             # <<<<<<<<<<<<<<
 * 
 *     use_sgemmEx = (_cuda_runtime_version >= 7500 and
 */
    __pyx_t_9 = __pyx_f_4cupy_4cuda_7runtime_runtimeGetVersion(0); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2471, __pyx_L1_error)
    __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2471, __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":2470
 * 
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  }

  /* "cupy/core/core.pyx":2473
 *         _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(1, 2473, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 2473, __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":2474
 * 
 *     use_sgemmEx = (_cuda_runtime_version >= 7500 and
 *                    a.dtype == 'e' and b.dtype == 'e' and             # <<<<<<<<<<<<<<
 *                    (ret_dtype == 'e' or ret_dtype == 'f'))
 * 
 */
  __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_a->dtype, __pyx_n_s_e, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 2474, __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(1, 2474, __pyx_L1_error)
  if (__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L9_bool_binop_done;
  }

  /* "cupy/core/core.pyx":2475
 *     use_sgemmEx = (_cuda_runtime_version >= 7500 and
 *                    a.dtype == 'e' and b.dtype == 'e' and
 *                    (ret_dtype == 'e' or ret_dtype == 'f'))             # <<<<<<<<<<<<<<
 * 
 *     if use_sgemmEx or ret_dtype == 'f' or ret_dtype == 'd':
 */
  __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_ret_dtype, __pyx_n_s_e, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 2475, __pyx_L1_error)
  __pyx_t_10 = (__pyx_t_8 != 0);
  if (!__pyx_t_10) {
  } else {
    __pyx_t_2 = __pyx_t_10;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_v_ret_dtype, __pyx_n_s_f, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(1, 2475, __pyx_L1_error)
  __pyx_t_8 = (__pyx_t_10 != 0);
  __pyx_t_2 = __pyx_t_8;
  __pyx_L9_bool_binop_done:;
  __pyx_v_use_sgemmEx = __pyx_t_2;

  /* "cupy/core/core.pyx":2477
 *                    (ret_dtype == 'e' or ret_dtype == 'f'))
 * 
 *     if use_sgemmEx or ret_dtype == 'f' or ret_dtype == 'd':             # <<<<<<<<<<<<<<
 *         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_L15_bool_binop_done;
  }
  __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_ret_dtype, __pyx_n_s_f, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 2477, __pyx_L1_error)
  __pyx_t_10 = (__pyx_t_8 != 0);
  if (!__pyx_t_10) {
  } else {
    __pyx_t_2 = __pyx_t_10;
    goto __pyx_L15_bool_binop_done;
  }
  __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_v_ret_dtype, __pyx_n_s_d, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(1, 2477, __pyx_L1_error)
  __pyx_t_8 = (__pyx_t_10 != 0);
  __pyx_t_2 = __pyx_t_8;
  __pyx_L15_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2478
 * 
 *     if use_sgemmEx or ret_dtype == 'f' or ret_dtype == 'd':
 *         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":2477
 *                    (ret_dtype == 'e' or ret_dtype == 'f'))
 * 
 *     if use_sgemmEx or ret_dtype == 'f' or ret_dtype == 'd':             # <<<<<<<<<<<<<<
 *         dtype = ret_dtype
 *     else:
 */
    goto __pyx_L14;
  }

  /* "cupy/core/core.pyx":2480
 *         dtype = ret_dtype
 *     else:
 *         dtype = numpy.find_common_type((ret_dtype, 'f'), ()).char             # <<<<<<<<<<<<<<
 * 
 *     if not use_sgemmEx:
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2480, __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(1, 2480, __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(1, 2480, __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_COMPILING_IN_CPYTHON && 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;
      }
    }
    __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2480, __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(1, 2480, __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(1, 2480, __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(1, 2480, __pyx_L1_error)
    __pyx_v_dtype = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
  }
  __pyx_L14:;

  /* "cupy/core/core.pyx":2482
 *         dtype = numpy.find_common_type((ret_dtype, 'f'), ()).char
 * 
 *     if not use_sgemmEx:             # <<<<<<<<<<<<<<
 *         a = a.astype(dtype, copy=False)
 *         b = b.astype(dtype, copy=False)
 */
  __pyx_t_2 = ((!(__pyx_v_use_sgemmEx != 0)) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2483
 * 
 *     if not use_sgemmEx:
 *         a = a.astype(dtype, copy=False)             # <<<<<<<<<<<<<<
 *         b = b.astype(dtype, copy=False)
 * 
 */
    __pyx_t_11.__pyx_n = 1;
    __pyx_t_11.copy = Py_False;
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->astype(__pyx_v_a, __pyx_v_dtype, 0, &__pyx_t_11)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2483, __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":2484
 *     if not use_sgemmEx:
 *         a = a.astype(dtype, copy=False)
 *         b = b.astype(dtype, copy=False)             # <<<<<<<<<<<<<<
 * 
 *     if out is None:
 */
    __pyx_t_11.__pyx_n = 1;
    __pyx_t_11.copy = Py_False;
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_b->__pyx_vtab)->astype(__pyx_v_b, __pyx_v_dtype, 0, &__pyx_t_11)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2484, __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":2482
 *         dtype = numpy.find_common_type((ret_dtype, 'f'), ()).char
 * 
 *     if not use_sgemmEx:             # <<<<<<<<<<<<<<
 *         a = a.astype(dtype, copy=False)
 *         b = b.astype(dtype, copy=False)
 */
  }

  /* "cupy/core/core.pyx":2486
 *         b = b.astype(dtype, copy=False)
 * 
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_out) == Py_None);
  __pyx_t_8 = (__pyx_t_2 != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":2487
 * 
 *     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(1, 2487, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2487, __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(1, 2487, __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":2488
 *     if out is None:
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:             # <<<<<<<<<<<<<<
 *             ret = out
 *         else:
 */
    __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_v_ret_dtype, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 2488, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_8 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2489
 *         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":2488
 *     if out is None:
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:             # <<<<<<<<<<<<<<
 *             ret = out
 *         else:
 */
      goto __pyx_L20;
    }

    /* "cupy/core/core.pyx":2491
 *             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(1, 2491, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2491, __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(1, 2491, __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_L20:;

    /* "cupy/core/core.pyx":2486
 *         b = b.astype(dtype, copy=False)
 * 
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:
 */
    goto __pyx_L19;
  }

  /* "cupy/core/core.pyx":2493
 *             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":2494
 *     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(1, 2494, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2495
 *         ret = out
 *         if out.dtype != dtype:
 *             out = ndarray(ret_shape, dtype)             # <<<<<<<<<<<<<<
 * 
 *     # It copies the operands if needed
 */
      __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_ret_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2495, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2495, __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(1, 2495, __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":2494
 *     else:
 *         ret = out
 *         if out.dtype != dtype:             # <<<<<<<<<<<<<<
 *             out = ndarray(ret_shape, dtype)
 * 
 */
    }
  }
  __pyx_L19:;

  /* "cupy/core/core.pyx":2498
 * 
 *     # It copies the operands if needed
 *     if a._shape.size() != 2 or a._shape[0] != k or a._shape[1] != n:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(k)
 */
  __pyx_t_8 = ((__pyx_v_a->_shape.size() != 2) != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L23_bool_binop_done;
  }
  __pyx_t_8 = (((__pyx_v_a->_shape[0]) != __pyx_v_k) != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L23_bool_binop_done;
  }
  __pyx_t_8 = (((__pyx_v_a->_shape[1]) != __pyx_v_n) != 0);
  __pyx_t_2 = __pyx_t_8;
  __pyx_L23_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2499
 *     # 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":2500
 *     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(1, 2500, __pyx_L1_error)
    }

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

    /* "cupy/core/core.pyx":2502
 *         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(1, 2502, __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":2498
 * 
 *     # 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":2503
 *         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_8 = ((__pyx_v_b->_shape.size() != 2) != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L27_bool_binop_done;
  }
  __pyx_t_8 = (((__pyx_v_b->_shape[0]) != __pyx_v_k) != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L27_bool_binop_done;
  }
  __pyx_t_8 = (((__pyx_v_b->_shape[1]) != __pyx_v_m) != 0);
  __pyx_t_2 = __pyx_t_8;
  __pyx_L27_bool_binop_done:;
  if (__pyx_t_2) {

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

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

    /* "cupy/core/core.pyx":2507
 *         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(1, 2507, __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":2503
 *         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":2508
 *         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":2509
 *         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_8 = ((__pyx_v_c->_shape.size() != 2) != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L31_bool_binop_done;
  }
  __pyx_t_8 = (((__pyx_v_c->_shape[0]) != __pyx_v_n) != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L31_bool_binop_done;
  }
  __pyx_t_8 = (((__pyx_v_c->_shape[1]) != __pyx_v_m) != 0);
  __pyx_t_2 = __pyx_t_8;
  __pyx_L31_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2510
 *     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(1, 2510, __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":2511
 *     if c._shape.size() != 2 or c._shape[0] != n or c._shape[1] != m:
 *         c = c.view()
 *         c.shape = (n, m)             # <<<<<<<<<<<<<<
 * 
 *     # Be careful that cuBLAS uses the FORTRAN-order matrix representation.
 */
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2511, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2511, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2511, __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_7);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_7);
    __pyx_t_1 = 0;
    __pyx_t_7 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_c), __pyx_n_s_shape, __pyx_t_5) < 0) __PYX_ERR(1, 2511, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2509
 *         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":2514
 * 
 *     # 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_5 = __pyx_f_4cupy_4cuda_6device_get_cublas_handle(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 2514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_handle = __pyx_t_6;

  /* "cupy/core/core.pyx":2518
 *     # 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_5 = __pyx_f_4cupy_4core_4core__mat_to_cublas_contiguous(__pyx_v_a, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (likely(__pyx_t_5 != Py_None)) {
    PyObject* sequence = __pyx_t_5;
    #if CYTHON_COMPILING_IN_CPYTHON
    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, 2518, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_7 = 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_7);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 2518, __pyx_L1_error)
  }
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 2518, __pyx_L1_error)
  __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 2518, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 2518, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7));
  __pyx_t_7 = 0;
  __pyx_v_transa = __pyx_t_9;
  __pyx_v_lda = __pyx_t_12;

  /* "cupy/core/core.pyx":2519
 *     # 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_5 = __pyx_f_4cupy_4core_4core__mat_to_cublas_contiguous(__pyx_v_b, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2519, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (likely(__pyx_t_5 != Py_None)) {
    PyObject* sequence = __pyx_t_5;
    #if CYTHON_COMPILING_IN_CPYTHON
    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, 2519, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_7);
    #else
    __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 2519, __pyx_L1_error)
  }
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 2519, __pyx_L1_error)
  __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 2519, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 2519, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
  __pyx_t_4 = 0;
  __pyx_v_transb = __pyx_t_12;
  __pyx_v_ldb = __pyx_t_9;

  /* "cupy/core/core.pyx":2520
 *     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
 *         cublas.sgemmEx(
 */
  __pyx_t_2 = (__pyx_v_use_sgemmEx != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2521
 *     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             # <<<<<<<<<<<<<<
 *         cublas.sgemmEx(
 *             handle, transb, transa, m, n, k, 1, b.data.ptr, runtime.CUDA_R_16F,
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_c->dtype, __pyx_n_s_e, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 2521, __pyx_L1_error)
    if (__pyx_t_2) {
      __pyx_t_13 = __pyx_e_4cupy_4cuda_7runtime_CUDA_R_16F;
    } else {
      __pyx_t_13 = __pyx_e_4cupy_4cuda_7runtime_CUDA_R_32F;
    }
    __pyx_v_Ctype = __pyx_t_13;

    /* "cupy/core/core.pyx":2522
 *     if use_sgemmEx:
 *         Ctype = runtime.CUDA_R_16F if c.dtype == 'e' else runtime.CUDA_R_32F
 *         cublas.sgemmEx(             # <<<<<<<<<<<<<<
 *             handle, transb, transa, m, n, k, 1, b.data.ptr, runtime.CUDA_R_16F,
 *             ldb, a.data.ptr, runtime.CUDA_R_16F, lda, 0, c.data.ptr, Ctype, m)
 */
    __pyx_t_5 = __pyx_f_4cupy_4cuda_6cublas_sgemmEx(__pyx_v_handle, __pyx_v_transb, __pyx_v_transa, __pyx_v_m, __pyx_v_n, __pyx_v_k, 1.0, __pyx_v_b->data->ptr, __pyx_e_4cupy_4cuda_7runtime_CUDA_R_16F, __pyx_v_ldb, __pyx_v_a->data->ptr, __pyx_e_4cupy_4cuda_7runtime_CUDA_R_16F, __pyx_v_lda, 0.0, __pyx_v_c->data->ptr, __pyx_v_Ctype, __pyx_v_m, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2522, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2520
 *     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
 *         cublas.sgemmEx(
 */
    goto __pyx_L34;
  }

  /* "cupy/core/core.pyx":2525
 *             handle, transb, transa, m, n, k, 1, b.data.ptr, runtime.CUDA_R_16F,
 *             ldb, a.data.ptr, runtime.CUDA_R_16F, lda, 0, c.data.ptr, Ctype, m)
 *     elif dtype == 'f':             # <<<<<<<<<<<<<<
 *         cublas.sgemm(handle, transb, transa, m, n, k, 1, b.data.ptr, ldb,
 *                      a.data.ptr, lda, 0, c.data.ptr, m)
 */
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_f, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 2525, __pyx_L1_error)
  __pyx_t_8 = (__pyx_t_2 != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":2526
 *             ldb, a.data.ptr, runtime.CUDA_R_16F, lda, 0, c.data.ptr, Ctype, m)
 *     elif dtype == 'f':
 *         cublas.sgemm(handle, transb, transa, m, n, k, 1, b.data.ptr, ldb,             # <<<<<<<<<<<<<<
 *                      a.data.ptr, lda, 0, c.data.ptr, m)
 *     elif dtype == 'd':
 */
    __pyx_t_5 = __pyx_f_4cupy_4cuda_6cublas_sgemm(__pyx_v_handle, __pyx_v_transb, __pyx_v_transa, __pyx_v_m, __pyx_v_n, __pyx_v_k, 1.0, __pyx_v_b->data->ptr, __pyx_v_ldb, __pyx_v_a->data->ptr, __pyx_v_lda, 0.0, __pyx_v_c->data->ptr, __pyx_v_m, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2526, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2525
 *             handle, transb, transa, m, n, k, 1, b.data.ptr, runtime.CUDA_R_16F,
 *             ldb, a.data.ptr, runtime.CUDA_R_16F, lda, 0, c.data.ptr, Ctype, m)
 *     elif dtype == 'f':             # <<<<<<<<<<<<<<
 *         cublas.sgemm(handle, transb, transa, m, n, k, 1, b.data.ptr, ldb,
 *                      a.data.ptr, lda, 0, c.data.ptr, m)
 */
    goto __pyx_L34;
  }

  /* "cupy/core/core.pyx":2528
 *         cublas.sgemm(handle, transb, transa, m, n, k, 1, b.data.ptr, ldb,
 *                      a.data.ptr, lda, 0, c.data.ptr, m)
 *     elif dtype == 'd':             # <<<<<<<<<<<<<<
 *         cublas.dgemm(handle, transb, transa, m, n, k, 1, b.data.ptr, ldb,
 *                      a.data.ptr, lda, 0, c.data.ptr, m)
 */
  __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_d, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 2528, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_8 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2529
 *                      a.data.ptr, lda, 0, c.data.ptr, m)
 *     elif dtype == 'd':
 *         cublas.dgemm(handle, transb, transa, m, n, k, 1, b.data.ptr, ldb,             # <<<<<<<<<<<<<<
 *                      a.data.ptr, lda, 0, c.data.ptr, m)
 * 
 */
    __pyx_t_5 = __pyx_f_4cupy_4cuda_6cublas_dgemm(__pyx_v_handle, __pyx_v_transb, __pyx_v_transa, __pyx_v_m, __pyx_v_n, __pyx_v_k, 1.0, __pyx_v_b->data->ptr, __pyx_v_ldb, __pyx_v_a->data->ptr, __pyx_v_lda, 0.0, __pyx_v_c->data->ptr, __pyx_v_m, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2529, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2528
 *         cublas.sgemm(handle, transb, transa, m, n, k, 1, b.data.ptr, ldb,
 *                      a.data.ptr, lda, 0, c.data.ptr, m)
 *     elif dtype == 'd':             # <<<<<<<<<<<<<<
 *         cublas.dgemm(handle, transb, transa, m, n, k, 1, b.data.ptr, ldb,
 *                      a.data.ptr, lda, 0, c.data.ptr, m)
 */
  }
  __pyx_L34:;

  /* "cupy/core/core.pyx":2532
 *                      a.data.ptr, lda, 0, c.data.ptr, m)
 * 
 *     if out is not ret:             # <<<<<<<<<<<<<<
 *         elementwise_copy(out, ret)
 *     return ret
 */
  __pyx_t_2 = (__pyx_v_out != __pyx_v_ret);
  __pyx_t_8 = (__pyx_t_2 != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":2533
 * 
 *     if out is not ret:
 *         elementwise_copy(out, ret)             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2533, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(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);
        __pyx_t_6 = 1;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2533, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
    PyTuple_SET_ITEM(__pyx_t_4, 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_4, 1+__pyx_t_6, ((PyObject *)__pyx_v_ret));
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2533, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2532
 *                      a.data.ptr, lda, 0, c.data.ptr, m)
 * 
 *     if out is not ret:             # <<<<<<<<<<<<<<
 *         elementwise_copy(out, ret)
 *     return ret
 */
  }

  /* "cupy/core/core.pyx":2534
 *     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":2451
 * 
 * 
 * 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_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((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_79tensordot_core(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_79tensordot_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);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 2451, __pyx_L3_error)
        }
        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(1, 2451, __pyx_L3_error)
        }
        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(1, 2451, __pyx_L3_error)
        }
        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(1, 2451, __pyx_L3_error)
        }
        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(1, 2451, __pyx_L3_error)
        }
        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(1, 2451, __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(1, 2451, __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(1, 2452, __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(1, 2452, __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(1, 2453, __pyx_L3_error)
    __pyx_v_ret_shape = __pyx_convert_vector_from_py_Py_ssize_t(values[6]); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 2453, __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(1, 2451, __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(1, 2452, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) __PYX_ERR(1, 2452, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(1, 2452, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_78tensordot_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_78tensordot_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(1, 2451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":2538
 * 
 * @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_81_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":2539
 * @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(1, 2539, __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(1, 2539, __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(1, 2539, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(1, 2539, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/core/core.pyx":2540
 * 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":2542
 *     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(1, 2542, __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(1, 2542, __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(1, 2542, __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":2543
 *         # 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(1, 2543, __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(1, 2543, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 2543, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":2544
 *         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(1, 2544, __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":2543
 *         # 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":2545
 *         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(1, 2545, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2545, __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":2540
 * 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":2546
 *             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":2547
 *         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)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2547, __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":2546
 *             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":2548
 *     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(1, 2548, __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(1, 2548, __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(1, 2548, __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(1, 2548, __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(1, 2548, __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":2538
 * 
 * @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_81_mat_to_cublas_contiguous(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_81_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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 2538, __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(1, 2538, __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(1, 2538, __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(1, 2538, __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(1, 2538, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_80_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_80_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(1, 2538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":2552
 * 
 * @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_83_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":2553
 * @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":2554
 * 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)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2554, __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":2553
 * @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":2556
 *         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(1, 2556, __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(1, 2556, __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(1, 2556, __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(1, 2556, __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":2552
 * 
 * @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_83_to_cublas_vector(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_83_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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 2552, __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(1, 2552, __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(1, 2552, __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(1, 2552, __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(1, 2552, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_82_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_82_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(1, 2552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":2562
 * # -----------------------------------------------------------------------------
 * 
 * cpdef create_comparison(name, op, doc=''):             # <<<<<<<<<<<<<<
 *     return create_ufunc(
 *         'cupy_' + name,
 */

static PyObject *__pyx_pw_4cupy_4core_4core_85create_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__4);
  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("create_comparison", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_doc = __pyx_optional_args->doc;
    }
  }

  /* "cupy/core/core.pyx":2563
 * 
 * cpdef create_comparison(name, op, doc=''):
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":2564
 * cpdef create_comparison(name, op, doc=''):
 *     return create_ufunc(
 *         'cupy_' + name,             # <<<<<<<<<<<<<<
 *         ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',
 *          'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?'),
 */
  __pyx_t_2 = PyNumber_Add(__pyx_n_s_cupy, __pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/core.pyx":2567
 *         ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',
 *          'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?'),
 *         'out0 = in0 %s in1' % op,             # <<<<<<<<<<<<<<
 *         doc=doc)
 * 
 */
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_out0_in0_s_in1, __pyx_v_op); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/core.pyx":2563
 * 
 * cpdef create_comparison(name, op, doc=''):
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',
 */
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_tuple__121);
  __Pyx_GIVEREF(__pyx_tuple__121);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_tuple__121);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2568
 *          'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?'),
 *         'out0 = in0 %s in1' % op,
 *         doc=doc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_doc, __pyx_v_doc) < 0) __PYX_ERR(1, 2568, __pyx_L1_error)

  /* "cupy/core/core.pyx":2563
 * 
 * cpdef create_comparison(name, op, doc=''):
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',
 */
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2563, __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_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2562
 * # -----------------------------------------------------------------------------
 * 
 * cpdef create_comparison(name, op, 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_AddTraceback("cupy.core.core.create_comparison", __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_85create_comparison(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_85create_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_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,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)__pyx_kp_s__4);
    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);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_op)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_comparison", 0, 2, 3, 1); __PYX_ERR(1, 2562, __pyx_L3_error)
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_doc);
          if (value) { values[2] = 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(1, 2562, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        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];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_comparison", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 2562, __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_84create_comparison(__pyx_self, __pyx_v_name, __pyx_v_op, __pyx_v_doc);

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

static PyObject *__pyx_pf_4cupy_4core_4core_84create_comparison(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_op, PyObject *__pyx_v_doc) {
  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 = 1;
  __pyx_t_2.doc = __pyx_v_doc;
  __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(1, 2562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":2663
 * 
 * 
 * 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":2664
 * 
 * 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(1, 2664, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":2665
 * 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, __pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2665, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/core.pyx":2666
 *     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'),
 */
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_out0_in0_s_in1, __pyx_v_boolop); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2666, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2666, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_kp_s__83);
  __Pyx_GIVEREF(__pyx_kp_s__83);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_s__83);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(14); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2666, __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_t_4 = 0;

  /* "cupy/core/core.pyx":2669
 *          '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 = 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(1, 2669, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":2664
 * 
 * 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(1, 2664, __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":2670
 *          'LL->L', 'qq->q', 'QQ->Q', 'ee->e', 'ff->f', 'dd->d'),
 *         'out0 = in0 %s in1' % op,
 *         doc=doc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2670, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_doc, __pyx_v_doc) < 0) __PYX_ERR(1, 2670, __pyx_L1_error)

  /* "cupy/core/core.pyx":2664
 * 
 * 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(1, 2664, __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":2663
 * 
 * 
 * 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":2820
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                    keepdims=False):
 *     if axis is None:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_87_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":2821
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,
 *                    keepdims=False):             # <<<<<<<<<<<<<<
 *     if axis is None:
 *         axis = tuple(range(a.ndim))
 */
  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
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  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":2822
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,
 *                    keepdims=False):
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         axis = tuple(range(a.ndim))
 *     if not isinstance(axis, tuple):
 */
  __pyx_t_1 = (__pyx_v_axis == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2823
 *                    keepdims=False):
 *     if axis is None:
 *         axis = tuple(range(a.ndim))             # <<<<<<<<<<<<<<
 *     if not isinstance(axis, tuple):
 *         axis = (axis,)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2823, __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(1, 2823, __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(1, 2823, __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/core.pyx":2822
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,
 *                    keepdims=False):
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         axis = tuple(range(a.ndim))
 *     if not isinstance(axis, tuple):
 */
  }

  /* "cupy/core/core.pyx":2824
 *     if axis is None:
 *         axis = tuple(range(a.ndim))
 *     if not isinstance(axis, tuple):             # <<<<<<<<<<<<<<
 *         axis = (axis,)
 * 
 */
  __pyx_t_2 = PyTuple_Check(__pyx_v_axis); 
  __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2825
 *         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(1, 2825, __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":2824
 *     if axis is None:
 *         axis = tuple(range(a.ndim))
 *     if not isinstance(axis, tuple):             # <<<<<<<<<<<<<<
 *         axis = (axis,)
 * 
 */
  }

  /* "cupy/core/core.pyx":2827
 *         axis = (axis,)
 * 
 *     if dtype is None and issubclass(a.dtype.type,             # <<<<<<<<<<<<<<
 *                                     (numpy.integer, numpy.bool_)):
 *         dtype = 'd'
 */
  __pyx_t_2 = (__pyx_v_dtype == Py_None);
  __pyx_t_5 = (__pyx_t_2 != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_1 = __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(1, 2827, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":2828
 * 
 *     if dtype is None and issubclass(a.dtype.type,
 *                                     (numpy.integer, numpy.bool_)):             # <<<<<<<<<<<<<<
 *         dtype = 'd'
 * 
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_integer); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __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(1, 2828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_bool); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_7);
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2827
 *         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_3); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(1, 2827, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = (__pyx_t_5 != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2829
 *     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":2827
 *         axis = (axis,)
 * 
 *     if dtype is None and issubclass(a.dtype.type,             # <<<<<<<<<<<<<<
 *                                     (numpy.integer, numpy.bool_)):
 *         dtype = 'd'
 */
  }

  /* "cupy/core/core.pyx":2831
 *         dtype = 'd'
 * 
 *     shape = a.shape             # <<<<<<<<<<<<<<
 *     items = 1
 *     for ax in axis:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2831, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_shape = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2832
 * 
 *     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":2833
 *     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_3 = __pyx_v_axis; __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_axis); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2833, __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(1, 2833, __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_COMPILING_IN_CPYTHON
        __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, 2833, __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, 2833, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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(1, 2833, __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, 2833, __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(1, 2833, __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":2834
 *     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(1, 2834, __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(1, 2834, __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":2833
 *     shape = a.shape
 *     items = 1
 *     for ax in axis:             # <<<<<<<<<<<<<<
 *         items *= shape[ax]
 *     alpha = 1. / max(items - ddof, 0)
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2835
 *     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_3 = PyNumber_Subtract(__pyx_v_items, __pyx_v_ddof); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2835, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2835, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2835, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 2835, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_1) {
    __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __pyx_t_6;
    __pyx_t_6 = 0;
  } else {
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_7 = __pyx_t_3;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyFloat_TrueDivideCObj(__pyx_float_1_, __pyx_t_7, 1., 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2835, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_alpha = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2836
 *         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_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_mean); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2836, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2836, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(1, 2836, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 2836, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_keepdims, Py_True) < 0) __PYX_ERR(1, 2836, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2836, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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(1, 2836, __pyx_L1_error)
  __pyx_v_arrmean = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":2837
 *     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_1 = (__pyx_v_out == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2838
 *     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(1, 2838, __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(1, 2838, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(1, 2838, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(1, 2838, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__var_core, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2838, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 2838, __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":2837
 *     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":2840
 *         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":2841
 *     else:
 *         return _var_core_out(
 *             a, arrmean, alpha, out, axis=axis, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2840, __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_arrmean));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_arrmean));
    PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_arrmean));
    __Pyx_INCREF(__pyx_v_alpha);
    __Pyx_GIVEREF(__pyx_v_alpha);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_alpha);
    __Pyx_INCREF(__pyx_v_out);
    __Pyx_GIVEREF(__pyx_v_out);
    PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_out);
    __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2841, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(1, 2841, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(1, 2841, __pyx_L1_error)

    /* "cupy/core/core.pyx":2840
 *         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_3, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2840, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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(1, 2840, __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":2820
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                    keepdims=False):
 *     if axis 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_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_87_var(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_87_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":2821
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,
 *                    keepdims=False):             # <<<<<<<<<<<<<<
 *     if axis is None:
 *         axis = tuple(range(a.ndim))
 */
    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);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ddof);
          if (value) { values[4] = value; kw_args--; }
        }
        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(1, 2820, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        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(1, 2820, __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(1, 2820, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_86_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":2820
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                    keepdims=False):
 *     if axis is None:
 */

  /* 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_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(1, 2820, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":2844
 * 
 * 
 * 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_89_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":2845
 * 
 * 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(1, 2845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2845, __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(1, 2845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(1, 2845, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 2845, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_ddof, __pyx_v_ddof) < 0) __PYX_ERR(1, 2845, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(1, 2845, __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(1, 2845, __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(1, 2845, __pyx_L1_error)
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2846
 * 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(1, 2846, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2846, __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(1, 2846, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 2846, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(1, 2846, __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(1, 2846, __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":2844
 * 
 * 
 * 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_89_std(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_89_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);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ddof);
          if (value) { values[4] = value; kw_args--; }
        }
        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(1, 2844, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        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(1, 2844, __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_88_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_88_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(1, 2844, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":2874
 * 
 * @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_91_inclusive_scan_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_90_inclusive_scan_kernel[] = "return 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_91_inclusive_scan_kernel = {"_inclusive_scan_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_91_inclusive_scan_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_90_inclusive_scan_kernel};
static PyObject *__pyx_pw_4cupy_4core_4core_91_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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 2874, __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(1, 2874, __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(1, 2874, __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_90_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_90_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":2895
 *     """
 * 
 *     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":2896
 * 
 *     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(1, 2896, __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":2897
 *     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(1, 2897, __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, 2897, __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__122, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2897, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2935
 *         }
 *     }
 *     """).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(1, 2935, __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(1, 2935, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(1, 2935, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 2935, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_block_size, __pyx_v_block_size) < 0) __PYX_ERR(1, 2935, __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(1, 2935, __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":2936
 *     }
 *     """).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(1, 2936, __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(1, 2936, __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":2937
 *     """).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(1, 2937, __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, 2937, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2874
 * 
 * @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":2941
 * 
 * @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_93_add_scan_blocked_sum_kernel(PyObject *__pyx_self, PyObject *__pyx_v_dtype); /*proto*/
static PyMethodDef __pyx_mdef_4cupy_4core_4core_93_add_scan_blocked_sum_kernel = {"_add_scan_blocked_sum_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_93_add_scan_blocked_sum_kernel, METH_O, 0};
static PyObject *__pyx_pw_4cupy_4core_4core_93_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_92_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_92_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":2942
 * @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":2943
 * 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(1, 2943, __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":2944
 *     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(1, 2944, __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, 2944, __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__123, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2944, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2955
 *         }
 *     }
 *     """).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(1, 2955, __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(1, 2955, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(1, 2955, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(1, 2955, __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(1, 2955, __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":2956
 *     }
 *     """).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(1, 2956, __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(1, 2956, __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":2957
 *     """).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(1, 2957, __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, 2957, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2941
 * 
 * @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":2961
 * 
 * @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_95_nonzero_1d_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4cupy_4core_4core_95_nonzero_1d_kernel = {"_nonzero_1d_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_95_nonzero_1d_kernel, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4cupy_4core_4core_95_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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 2961, __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(1, 2961, __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(1, 2961, __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_94_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_94_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":2962
 * @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":2963
 * 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(1, 2963, __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":2964
 *     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(1, 2964, __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":2966
 *     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(1, 2966, __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, 2966, __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__124, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2966, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2978
 *         }
 *     }
 *     """).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(1, 2978, __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(1, 2978, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(1, 2978, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_src_dtype, __pyx_v_src_dtype) < 0) __PYX_ERR(1, 2978, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_index_dtype, __pyx_v_index_dtype) < 0) __PYX_ERR(1, 2978, __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(1, 2978, __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":2979
 *     }
 *     """).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(1, 2979, __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(1, 2979, __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":2980
 *     """).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(1, 2980, __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, 2980, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2961
 * 
 * @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":2984
 * 
 * @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_97_nonzero_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4cupy_4core_4core_97_nonzero_kernel = {"_nonzero_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_97_nonzero_kernel, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4cupy_4core_4core_97_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);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 2984, __pyx_L3_error)
        }
        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(1, 2984, __pyx_L3_error)
        }
        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(1, 2984, __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(1, 2984, __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(1, 2984, __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_96_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_96_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":2985
 * @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":2986
 * 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(1, 2986, __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":2987
 *     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(1, 2987, __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":2988
 *     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(1, 2988, __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":2990
 *     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(1, 2990, __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, 2990, __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__125, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2990, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":3011
 *             }
 *         }
 *         """).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(1, 3011, __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(1, 3011, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(1, 3011, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_src_dtype, __pyx_v_src_dtype) < 0) __PYX_ERR(1, 3011, __pyx_L1_error)

  /* "cupy/core/core.pyx":3012
 *         }
 *         """).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(1, 3011, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_index_dtype, __pyx_v_index_dtype) < 0) __PYX_ERR(1, 3011, __pyx_L1_error)

  /* "cupy/core/core.pyx":3013
 *         """).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(1, 3011, __pyx_L1_error)

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

  /* "cupy/core/core.pyx":2984
 * 
 * @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":3018
 * 
 * 
 * def scan(a, out=None):             # <<<<<<<<<<<<<<
 *     """Return the prefix sum(scan) of the elements.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_99scan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_98scan[] = "Return 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 PyMethodDef __pyx_mdef_4cupy_4core_4core_99scan = {"scan", (PyCFunction)__pyx_pw_4cupy_4core_4core_99scan, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_98scan};
static PyObject *__pyx_pw_4cupy_4core_4core_99scan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_a = 0;
  PyObject *__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 *)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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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;
        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(1, 3018, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = values[0];
    __pyx_v_out = 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(1, 3018, __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:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_98scan(__pyx_self, __pyx_v_a, __pyx_v_out);

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

static PyObject *__pyx_pf_4cupy_4core_4core_98scan(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_out) {
  PyObject *__pyx_v_block_size = NULL;
  PyObject *__pyx_v_kern_scan = NULL;
  PyObject *__pyx_v_blocked_sum = NULL;
  PyObject *__pyx_v_kern_add = 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;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("scan", 0);
  __Pyx_INCREF(__pyx_v_out);

  /* "cupy/core/core.pyx":3030
 * 
 *     """
 *     if a.ndim != 1:             # <<<<<<<<<<<<<<
 *         raise TypeError("Input array should be 1D array.")
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3030, __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(1, 3030, __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(1, 3030, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":3031
 *     """
 *     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__126, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3031, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(1, 3031, __pyx_L1_error)

    /* "cupy/core/core.pyx":3030
 * 
 *     """
 *     if a.ndim != 1:             # <<<<<<<<<<<<<<
 *         raise TypeError("Input array should be 1D array.")
 * 
 */
  }

  /* "cupy/core/core.pyx":3033
 *         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":3035
 *     block_size = 256
 * 
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(a.shape, dtype=a.dtype)
 *     else:
 */
  __pyx_t_3 = (__pyx_v_out == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":3036
 * 
 *     if out is None:
 *         out = ndarray(a.shape, dtype=a.dtype)             # <<<<<<<<<<<<<<
 *     else:
 *         if a.size != out.size:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3036, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3036, __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(1, 3036, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3036, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(1, 3036, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __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(1, 3036, __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, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3035
 *     block_size = 256
 * 
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(a.shape, dtype=a.dtype)
 *     else:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":3038
 *         out = ndarray(a.shape, dtype=a.dtype)
 *     else:
 *         if a.size != out.size:             # <<<<<<<<<<<<<<
 *             raise ValueError("Provided out is the wrong size")
 * 
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3038, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3038, __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(1, 3038, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 3038, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_4) {

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

      /* "cupy/core/core.pyx":3038
 *         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":3041
 *             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(1, 3041, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3041, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_7 = 1;
    }
  }
  __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 3041, __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_5);
  PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_5);
  __Pyx_INCREF(__pyx_v_block_size);
  __Pyx_GIVEREF(__pyx_v_block_size);
  PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_block_size);
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3041, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_kern_scan = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3042
 * 
 *     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 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3042, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3042, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyInt_SubtractObjC(__pyx_t_2, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 3042, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Multiply(__pyx_int_2, __pyx_v_block_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3042, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = PyNumber_FloorDivide(__pyx_t_8, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3042, __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_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_5, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3042, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3042, __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 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_grid, __pyx_t_5) < 0) __PYX_ERR(1, 3042, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3043
 *     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_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_block_size);
  __Pyx_GIVEREF(__pyx_v_block_size);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_block_size);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_block, __pyx_t_5) < 0) __PYX_ERR(1, 3042, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3044
 *     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_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3044, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_a);
  __Pyx_GIVEREF(__pyx_v_a);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_a);
  __Pyx_INCREF(__pyx_v_out);
  __Pyx_GIVEREF(__pyx_v_out);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_out);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_args, __pyx_t_5) < 0) __PYX_ERR(1, 3042, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3045
 *               block=(block_size,),
 *               args=(a, out),
 *               shared_mem=a.itemsize * block_size * 2)             # <<<<<<<<<<<<<<
 * 
 *     if (a.size - 1) // (block_size * 2) > 0:
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = PyNumber_Multiply(__pyx_t_5, __pyx_v_block_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Multiply(__pyx_t_2, __pyx_int_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_shared_mem, __pyx_t_5) < 0) __PYX_ERR(1, 3042, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3042
 * 
 *     kern_scan = _inclusive_scan_kernel(a.dtype, block_size)
 *     kern_scan(grid=((a.size - 1) // (2 * block_size) + 1,),             # <<<<<<<<<<<<<<
 *               block=(block_size,),
 *               args=(a, out),
 */
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_v_kern_scan, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3042, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3047
 *               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_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3047, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_PyInt_SubtractObjC(__pyx_t_5, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3047, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __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(1, 3047, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = PyNumber_FloorDivide(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3047, __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_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3047, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 3047, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":3048
 * 
 *     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(1, 3048, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyInt_SubtractObjC(__pyx_t_5, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3048, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __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(1, 3048, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PySlice_New(__pyx_t_2, Py_None, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3048, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_GetItem(__pyx_v_out, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3048, __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":3049
 *     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),),
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_scan); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_7 = 1;
      }
    }
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 3049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_v_blocked_sum);
    __Pyx_GIVEREF(__pyx_v_blocked_sum);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_blocked_sum);
    __Pyx_INCREF(__pyx_v_blocked_sum);
    __Pyx_GIVEREF(__pyx_v_blocked_sum);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_blocked_sum);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3050
 *         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(1, 3050, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 3050, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_2 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3050, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 3050, __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_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3050, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 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":3051
 *         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(1, 3051, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3051, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyInt_SubtractObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 3051, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Multiply(__pyx_int_2, __pyx_v_block_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3051, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = PyNumber_FloorDivide(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 3051, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3051, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
    __pyx_t_8 = 0;
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_grid, __pyx_t_1) < 0) __PYX_ERR(1, 3051, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3052
 *         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_1 = PyNumber_Multiply(__pyx_int_2, __pyx_v_block_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3052, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyInt_SubtractObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 3052, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3052, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
    __pyx_t_8 = 0;
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_block, __pyx_t_1) < 0) __PYX_ERR(1, 3051, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3053
 *         kern_add(grid=((a.size - 1) // (2 * block_size),),
 *                  block=(2 * block_size - 1,),
 *                  args=(out,))             # <<<<<<<<<<<<<<
 *     return out
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3053, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_out);
    __Pyx_GIVEREF(__pyx_v_out);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_out);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_args, __pyx_t_1) < 0) __PYX_ERR(1, 3051, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3051
 *         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_1 = __Pyx_PyObject_Call(__pyx_v_kern_add, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3051, __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":3047
 *               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":3054
 *                  block=(2 * block_size - 1,),
 *                  args=(out,))
 *     return out             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_out);
  __pyx_r = __pyx_v_out;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3018
 * 
 * 
 * def scan(a, 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_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.core.core.scan", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __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(__pyx_v_out);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "vector.to_py":67
 * 
 * @cname("__pyx_convert_vector_to_py_Py_ssize_t")
 * cdef object __pyx_convert_vector_to_py_Py_ssize_t(vector[X]& v):             # <<<<<<<<<<<<<<
 *     return [X_to_py(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":68
 * @cname("__pyx_convert_vector_to_py_Py_ssize_t")
 * cdef object __pyx_convert_vector_to_py_Py_ssize_t(vector[X]& v):
 *     return [X_to_py(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, 68, __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, 68, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) __PYX_ERR(4, 68, __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":67
 * 
 * @cname("__pyx_convert_vector_to_py_Py_ssize_t")
 * cdef object __pyx_convert_vector_to_py_Py_ssize_t(vector[X]& v):             # <<<<<<<<<<<<<<
 *     return [X_to_py(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;
}

/* "vector.from_py":49
 * 
 * @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":51
 * 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_from_py(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, 51, __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, 51, __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_COMPILING_IN_CPYTHON
        __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, 51, __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, 51, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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, 51, __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, 51, __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, 51, __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":52
 *     cdef vector[X] v
 *     for item in o:
 *         v.push_back(X_from_py(item))             # <<<<<<<<<<<<<<
 *     return v
 * 
 */
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_item); if (unlikely(__pyx_t_5 == -1L && PyErr_Occurred())) __PYX_ERR(4, 52, __pyx_L1_error)
    __pyx_v_v.push_back(__pyx_t_5);

    /* "vector.from_py":51
 * 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_from_py(item))
 *     return v
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "vector.from_py":53
 *     for item in o:
 *         v.push_back(X_from_py(item))
 *     return v             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_v;
  goto __pyx_L0;

  /* "vector.from_py":49
 * 
 * @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_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":51
 * 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_from_py(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, 51, __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, 51, __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_COMPILING_IN_CPYTHON
        __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, 51, __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, 51, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __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, 51, __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, 51, __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, 51, __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":52
 *     cdef vector[X] v
 *     for item in o:
 *         v.push_back(X_from_py(item))             # <<<<<<<<<<<<<<
 *     return v
 * 
 */
    __pyx_t_5 = __Pyx_PyInt_As_size_t(__pyx_v_item); if (unlikely(__pyx_t_5 == -1L && PyErr_Occurred())) __PYX_ERR(4, 52, __pyx_L1_error)
    __pyx_v_v.push_back(__pyx_t_5);

    /* "vector.from_py":51
 * 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_from_py(item))
 *     return v
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "vector.from_py":53
 *     for item in o:
 *         v.push_back(X_from_py(item))
 *     return v             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_v;
  goto __pyx_L0;

  /* "vector.from_py":49
 * 
 * @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_L0:;
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "vector.to_py":67
 * 
 * @cname("__pyx_convert_vector_to_py_size_t")
 * cdef object __pyx_convert_vector_to_py_size_t(vector[X]& v):             # <<<<<<<<<<<<<<
 *     return [X_to_py(v[i]) for i in range(v.size())]
 * 
 */

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":68
 * @cname("__pyx_convert_vector_to_py_size_t")
 * cdef object __pyx_convert_vector_to_py_size_t(vector[X]& v):
 *     return [X_to_py(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, 68, __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, 68, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) __PYX_ERR(4, 68, __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":67
 * 
 * @cname("__pyx_convert_vector_to_py_size_t")
 * cdef object __pyx_convert_vector_to_py_size_t(vector[X]& v):             # <<<<<<<<<<<<<<
 *     return [X_to_py(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;
}
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(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_149__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_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_NOARGS, __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, 0},
  {"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, 0},
  {"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},
  {"nonzero", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_39nonzero, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_38nonzero},
  {"diagonal", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_41diagonal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_40diagonal},
  {"max", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_43max, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_42max},
  {"argmax", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_45argmax, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_44argmax},
  {"min", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_47min, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_46min},
  {"argmin", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_49argmin, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_48argmin},
  {"clip", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_51clip, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_50clip},
  {"trace", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_53trace, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_52trace},
  {"sum", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_55sum, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_54sum},
  {"mean", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_57mean, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_56mean},
  {"var", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_59var, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_58var},
  {"std", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_61std, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_60std},
  {"prod", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_63prod, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_62prod},
  {"all", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_65all, METH_VARARGS|METH_KEYWORDS, 0},
  {"any", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_67any, METH_VARARGS|METH_KEYWORDS, 0},
  {"__copy__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_137__copy__, METH_NOARGS, 0},
  {"__deepcopy__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_139__deepcopy__, METH_O, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_141__reduce__, METH_NOARGS, 0},
  {"__array__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_143__array__, METH_VARARGS|METH_KEYWORDS, 0},
  {"dot", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_165dot, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_164dot},
  {"get", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_167get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_166get},
  {"set", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_169set, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_168set},
  {"reduced_view", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_171reduced_view, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_170reduced_view},
  {"_update_c_contiguity", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_173_update_c_contiguity, METH_NOARGS, 0},
  {"_update_f_contiguity", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_175_update_f_contiguity, METH_NOARGS, 0},
  {"_update_contiguity", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_177_update_contiguity, METH_NOARGS, 0},
  {"_set_shape_and_strides", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_179_set_shape_and_strides, METH_VARARGS|METH_KEYWORDS, 0},
  {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 *)"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 *)0, 0},
  {(char *)"_strides", __pyx_getprop_4cupy_4core_4core_7ndarray__strides, __pyx_setprop_4cupy_4core_4core_7ndarray__strides, (char *)0, 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_81__add__, /*nb_add*/
  __pyx_pw_4cupy_4core_4core_7ndarray_83__sub__, /*nb_subtract*/
  __pyx_pw_4cupy_4core_4core_7ndarray_85__mul__, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4cupy_4core_4core_7ndarray_89__div__, /*nb_divide*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_95__mod__, /*nb_remainder*/
  __pyx_pw_4cupy_4core_4core_7ndarray_97__divmod__, /*nb_divmod*/
  __pyx_pw_4cupy_4core_4core_7ndarray_99__pow__, /*nb_power*/
  __pyx_pw_4cupy_4core_4core_7ndarray_73__neg__, /*nb_negative*/
  __pyx_pw_4cupy_4core_4core_7ndarray_75__pos__, /*nb_positive*/
  __pyx_pw_4cupy_4core_4core_7ndarray_77__abs__, /*nb_absolute*/
  __pyx_pw_4cupy_4core_4core_7ndarray_71__nonzero__, /*nb_nonzero*/
  __pyx_pw_4cupy_4core_4core_7ndarray_79__invert__, /*nb_invert*/
  __pyx_pw_4cupy_4core_4core_7ndarray_101__lshift__, /*nb_lshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_103__rshift__, /*nb_rshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_105__and__, /*nb_and*/
  __pyx_pw_4cupy_4core_4core_7ndarray_109__xor__, /*nb_xor*/
  __pyx_pw_4cupy_4core_4core_7ndarray_107__or__, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  0, /*nb_coerce*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_151__int__, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  __pyx_pw_4cupy_4core_4core_7ndarray_153__long__, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_155__float__, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4cupy_4core_4core_7ndarray_157__oct__, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4cupy_4core_4core_7ndarray_159__hex__, /*nb_hex*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_111__iadd__, /*nb_inplace_add*/
  __pyx_pw_4cupy_4core_4core_7ndarray_113__isub__, /*nb_inplace_subtract*/
  __pyx_pw_4cupy_4core_4core_7ndarray_115__imul__, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4cupy_4core_4core_7ndarray_117__idiv__, /*nb_inplace_divide*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_123__imod__, /*nb_inplace_remainder*/
  __pyx_pw_4cupy_4core_4core_7ndarray_125__ipow__, /*nb_inplace_power*/
  __pyx_pw_4cupy_4core_4core_7ndarray_127__ilshift__, /*nb_inplace_lshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_129__irshift__, /*nb_inplace_rshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_131__iand__, /*nb_inplace_and*/
  __pyx_pw_4cupy_4core_4core_7ndarray_135__ixor__, /*nb_inplace_xor*/
  __pyx_pw_4cupy_4core_4core_7ndarray_133__ior__, /*nb_inplace_or*/
  __pyx_pw_4cupy_4core_4core_7ndarray_93__floordiv__, /*nb_floor_divide*/
  __pyx_pw_4cupy_4core_4core_7ndarray_91__truediv__, /*nb_true_divide*/
  __pyx_pw_4cupy_4core_4core_7ndarray_121__ifloordiv__, /*nb_inplace_floor_divide*/
  __pyx_pw_4cupy_4core_4core_7ndarray_119__itruediv__, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  __pyx_pw_4cupy_4core_4core_7ndarray_87__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_145__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_145__len__, /*mp_length*/
  __pyx_pw_4cupy_4core_4core_7ndarray_147__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_161__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_163__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*/
  "Multi-dimensional array on a CUDA device.\n\n    This class implements a subset of methods of :class:`numpy.ndarray`.\n    The difference is that this class allocates the array content on the\n    current GPU device.\n\n    Args:\n        shape (tuple of ints): Length of axes.\n        dtype: Data type. It must be an argument of :class:`numpy.dtype`.\n        memptr (cupy.cuda.MemoryPointer): Pointer to the array content head.\n        strides (tuple of ints): The strides for axes.\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        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        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_69__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 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(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[] = {
  {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*/
  0, /*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(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[] = {
  {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*/
  0, /*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_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->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(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_cstruct(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7Indexer_7cstruct_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 int __pyx_setprop_4cupy_4core_4core_7Indexer_size(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4cupy_4core_4core_7Indexer_4size_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

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 int __pyx_setprop_4cupy_4core_4core_7Indexer_shape(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4cupy_4core_4core_7Indexer_5shape_3__set__(o, v);
  }
  else {
    return __pyx_pw_4cupy_4core_4core_7Indexer_5shape_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_4cupy_4core_4core_Indexer[] = {
  {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 *)"cstruct", __pyx_getprop_4cupy_4core_4core_7Indexer_cstruct, 0, (char *)0, 0},
  {(char *)"size", __pyx_getprop_4cupy_4core_4core_7Indexer_size, __pyx_setprop_4cupy_4core_4core_7Indexer_size, (char *)0, 0},
  {(char *)"shape", __pyx_getprop_4cupy_4core_4core_7Indexer_shape, __pyx_setprop_4cupy_4core_4core_7Indexer_shape, (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*/
  0, /*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_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(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[] = {
  {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*/
  0, /*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(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[] = {
  {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*/
  "User-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(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[] = {
  {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*/
  "Object 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        shape (tuple of ints): The broadcasted shape.\n        nd (int): Number of dimensions of the broadcasted shape.\n        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 PyMethodDef __pyx_methods[] = {
  {"_get_strides_for_nocopy_reshape", (PyCFunction)__pyx_pw_4cupy_4core_4core_1_get_strides_for_nocopy_reshape, METH_VARARGS|METH_KEYWORDS, 0},
  {"to_cindexer", (PyCFunction)__pyx_pw_4cupy_4core_4core_3to_cindexer, METH_VARARGS|METH_KEYWORDS, 0},
  {"_get_header_source", (PyCFunction)__pyx_pw_4cupy_4core_4core_5_get_header_source, METH_NOARGS, 0},
  {"compile_with_cache", (PyCFunction)__pyx_pw_4cupy_4core_4core_7compile_with_cache, METH_VARARGS|METH_KEYWORDS, 0},
  {"_get_simple_elementwise_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_9_get_simple_elementwise_kernel, METH_VARARGS|METH_KEYWORDS, 0},
  {"_get_typename", (PyCFunction)__pyx_pw_4cupy_4core_4core_11_get_typename, METH_O, 0},
  {"_preprocess_args", (PyCFunction)__pyx_pw_4cupy_4core_4core_13_preprocess_args, METH_O, 0},
  {"_get_args_info", (PyCFunction)__pyx_pw_4cupy_4core_4core_15_get_args_info, METH_O, 0},
  {"_get_kernel_params", (PyCFunction)__pyx_pw_4cupy_4core_4core_17_get_kernel_params, METH_VARARGS|METH_KEYWORDS, 0},
  {"_reduce_dims", (PyCFunction)__pyx_pw_4cupy_4core_4core_19_reduce_dims, METH_VARARGS|METH_KEYWORDS, 0},
  {"create_ufunc", (PyCFunction)__pyx_pw_4cupy_4core_4core_29create_ufunc, METH_VARARGS|METH_KEYWORDS, 0},
  {"_get_simple_reduction_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_31_get_simple_reduction_kernel, METH_VARARGS|METH_KEYWORDS, 0},
  {"_get_axis", (PyCFunction)__pyx_pw_4cupy_4core_4core_33_get_axis, METH_VARARGS|METH_KEYWORDS, 0},
  {"_get_out_shape", (PyCFunction)__pyx_pw_4cupy_4core_4core_35_get_out_shape, METH_VARARGS|METH_KEYWORDS, 0},
  {"_get_trans_args", (PyCFunction)__pyx_pw_4cupy_4core_4core_37_get_trans_args, METH_VARARGS|METH_KEYWORDS, 0},
  {"_get_inout_args", (PyCFunction)__pyx_pw_4cupy_4core_4core_39_get_inout_args, METH_VARARGS|METH_KEYWORDS, 0},
  {"create_reduction_func", (PyCFunction)__pyx_pw_4cupy_4core_4core_45create_reduction_func, METH_VARARGS|METH_KEYWORDS, 0},
  {"array", (PyCFunction)__pyx_pw_4cupy_4core_4core_51array, METH_VARARGS|METH_KEYWORDS, 0},
  {"ascontiguousarray", (PyCFunction)__pyx_pw_4cupy_4core_4core_53ascontiguousarray, METH_VARARGS|METH_KEYWORDS, 0},
  {"rollaxis", (PyCFunction)__pyx_pw_4cupy_4core_4core_55rollaxis, METH_VARARGS|METH_KEYWORDS, 0},
  {"broadcast_to", (PyCFunction)__pyx_pw_4cupy_4core_4core_57broadcast_to, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_56broadcast_to},
  {"_repeat", (PyCFunction)__pyx_pw_4cupy_4core_4core_59_repeat, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_58_repeat},
  {"concatenate", (PyCFunction)__pyx_pw_4cupy_4core_4core_61concatenate, METH_VARARGS|METH_KEYWORDS, 0},
  {"_create_bit_op", (PyCFunction)__pyx_pw_4cupy_4core_4core_63_create_bit_op, METH_VARARGS|METH_KEYWORDS, 0},
  {"_boolean_array_indexing", (PyCFunction)__pyx_pw_4cupy_4core_4core_65_boolean_array_indexing, METH_VARARGS|METH_KEYWORDS, 0},
  {"_take", (PyCFunction)__pyx_pw_4cupy_4core_4core_67_take, METH_VARARGS|METH_KEYWORDS, 0},
  {"_diagonal", (PyCFunction)__pyx_pw_4cupy_4core_4core_69_diagonal, METH_VARARGS|METH_KEYWORDS, 0},
  {"_adv_getitem", (PyCFunction)__pyx_pw_4cupy_4core_4core_71_adv_getitem, METH_VARARGS|METH_KEYWORDS, 0},
  {"dot", (PyCFunction)__pyx_pw_4cupy_4core_4core_73dot, METH_VARARGS|METH_KEYWORDS, 0},
  {"_get_all_addresses", (PyCFunction)__pyx_pw_4cupy_4core_4core_75_get_all_addresses, METH_VARARGS|METH_KEYWORDS, 0},
  {"matmul", (PyCFunction)__pyx_pw_4cupy_4core_4core_77matmul, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_76matmul},
  {"tensordot_core", (PyCFunction)__pyx_pw_4cupy_4core_4core_79tensordot_core, METH_VARARGS|METH_KEYWORDS, 0},
  {"_mat_to_cublas_contiguous", (PyCFunction)__pyx_pw_4cupy_4core_4core_81_mat_to_cublas_contiguous, METH_VARARGS|METH_KEYWORDS, 0},
  {"_to_cublas_vector", (PyCFunction)__pyx_pw_4cupy_4core_4core_83_to_cublas_vector, METH_VARARGS|METH_KEYWORDS, 0},
  {"create_comparison", (PyCFunction)__pyx_pw_4cupy_4core_4core_85create_comparison, METH_VARARGS|METH_KEYWORDS, 0},
  {"_var", (PyCFunction)__pyx_pw_4cupy_4core_4core_87_var, METH_VARARGS|METH_KEYWORDS, 0},
  {"_std", (PyCFunction)__pyx_pw_4cupy_4core_4core_89_std, METH_VARARGS|METH_KEYWORDS, 0},
  {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_kp_s_1_out_0__raw_out_0__ind_get, __pyx_k_1_out_0__raw_out_0__ind_get, sizeof(__pyx_k_1_out_0__raw_out_0__ind_get), 0, 0, 1, 0},
  {&__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_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_kp_s_Axis_dimension_mismatch, __pyx_k_Axis_dimension_mismatch, sizeof(__pyx_k_Axis_dimension_mismatch), 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_l, __pyx_k_B_l, sizeof(__pyx_k_B_l), 0, 0, 1, 0},
  {&__pyx_kp_s_Boolean_array_indexing_is_suppor, __pyx_k_Boolean_array_indexing_is_suppor, sizeof(__pyx_k_Boolean_array_indexing_is_suppor), 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_CArray_s_d, __pyx_k_CArray_s_d, sizeof(__pyx_k_CArray_s_d), 0, 0, 1, 0},
  {&__pyx_n_s_CIndexer, __pyx_k_CIndexer, sizeof(__pyx_k_CIndexer), 0, 0, 1, 1},
  {&__pyx_kp_s_CIndexer__in_ind_CIndexer__out_i, __pyx_k_CIndexer__in_ind_CIndexer__out_i, sizeof(__pyx_k_CIndexer__in_ind_CIndexer__out_i), 0, 0, 1, 0},
  {&__pyx_kp_s_CIndexer__ind, __pyx_k_CIndexer__ind, sizeof(__pyx_k_CIndexer__ind), 0, 0, 1, 0},
  {&__pyx_kp_s_CIndexer_d, __pyx_k_CIndexer_d, sizeof(__pyx_k_CIndexer_d), 0, 0, 1, 0},
  {&__pyx_kp_s_Can_not_use_i_as_a_parameter_nam, __pyx_k_Can_not_use_i_as_a_parameter_nam, sizeof(__pyx_k_Can_not_use_i_as_a_parameter_nam), 0, 0, 1, 0},
  {&__pyx_kp_s_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_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_n_s_Exception, __pyx_k_Exception, sizeof(__pyx_k_Exception), 0, 0, 1, 1},
  {&__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_l, __pyx_k_H_l, sizeof(__pyx_k_H_l), 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_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_l, __pyx_k_I_l, sizeof(__pyx_k_I_l), 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_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 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_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_Input_type_must_be_cupy_ndarray, __pyx_k_Input_type_must_be_cupy_ndarray, sizeof(__pyx_k_Input_type_must_be_cupy_ndarray), 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_index_type_s, __pyx_k_Invalid_index_type_s, sizeof(__pyx_k_Invalid_index_type_s), 0, 0, 1, 0},
  {&__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_l, __pyx_k_L_l, sizeof(__pyx_k_L_l), 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_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_kp_s_Only_basic_indexing_is_supported, __pyx_k_Only_basic_indexing_is_supported, sizeof(__pyx_k_Only_basic_indexing_is_supported), 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_shape_is_mismatched, __pyx_k_Out_shape_is_mismatched, sizeof(__pyx_k_Out_shape_is_mismatched), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_arguments_must_be_cupy_nd, __pyx_k_Output_arguments_must_be_cupy_nd, sizeof(__pyx_k_Output_arguments_must_be_cupy_nd), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_arguments_type_must_be_cu, __pyx_k_Output_arguments_type_must_be_cu, sizeof(__pyx_k_Output_arguments_type_must_be_cu), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_array_has_an_invalid_size, __pyx_k_Output_array_has_an_invalid_size, sizeof(__pyx_k_Output_array_has_an_invalid_size), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_array_must_be_C_contiguou, __pyx_k_Output_array_must_be_C_contiguou, sizeof(__pyx_k_Output_array_must_be_C_contiguou), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_array_size_is_Undecided, __pyx_k_Output_array_size_is_Undecided, sizeof(__pyx_k_Output_array_size_is_Undecided), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_dtype_mismatch, __pyx_k_Output_dtype_mismatch, sizeof(__pyx_k_Output_dtype_mismatch), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_shape_mismatch, __pyx_k_Output_shape_mismatch, sizeof(__pyx_k_Output_shape_mismatch), 0, 0, 1, 0},
  {&__pyx_n_s_PY3, __pyx_k_PY3, sizeof(__pyx_k_PY3), 0, 0, 1, 1},
  {&__pyx_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_l, __pyx_k_Q_l, sizeof(__pyx_k_Q_l), 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_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__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_n_s_Sequence, __pyx_k_Sequence, sizeof(__pyx_k_Sequence), 0, 0, 1, 1},
  {&__pyx_kp_s_Shape_mismatch, __pyx_k_Shape_mismatch, sizeof(__pyx_k_Shape_mismatch), 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_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_bool_boolean_array_S_nth, __pyx_k_T_a_bool_boolean_array_S_nth, sizeof(__pyx_k_T_a_bool_boolean_array_S_nth), 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_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_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_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_Universal_function_Attributes_na, __pyx_k_Universal_function_Attributes_na, sizeof(__pyx_k_Universal_function_Attributes_na), 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_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_of_arguments_for_s, __pyx_k_Wrong_type_of_arguments_for_s, sizeof(__pyx_k_Wrong_type_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_n_s__154, __pyx_k__154, sizeof(__pyx_k__154), 0, 0, 1, 1},
  {&__pyx_kp_s__173, __pyx_k__173, sizeof(__pyx_k__173), 0, 0, 1, 0},
  {&__pyx_kp_s__216, __pyx_k__216, sizeof(__pyx_k__216), 0, 0, 1, 0},
  {&__pyx_kp_s__217, __pyx_k__217, sizeof(__pyx_k__217), 0, 0, 1, 0},
  {&__pyx_kp_s__218, __pyx_k__218, sizeof(__pyx_k__218), 0, 0, 1, 0},
  {&__pyx_kp_s__222, __pyx_k__222, sizeof(__pyx_k__222), 0, 0, 1, 0},
  {&__pyx_kp_s__223, __pyx_k__223, sizeof(__pyx_k__223), 0, 0, 1, 0},
  {&__pyx_kp_s__227, __pyx_k__227, sizeof(__pyx_k__227), 0, 0, 1, 0},
  {&__pyx_kp_s__228, __pyx_k__228, sizeof(__pyx_k__228), 0, 0, 1, 0},
  {&__pyx_kp_s__229, __pyx_k__229, sizeof(__pyx_k__229), 0, 0, 1, 0},
  {&__pyx_kp_s__230, __pyx_k__230, sizeof(__pyx_k__230), 0, 0, 1, 0},
  {&__pyx_kp_s__231, __pyx_k__231, sizeof(__pyx_k__231), 0, 0, 1, 0},
  {&__pyx_kp_s__232, __pyx_k__232, sizeof(__pyx_k__232), 0, 0, 1, 0},
  {&__pyx_kp_s__244, __pyx_k__244, sizeof(__pyx_k__244), 0, 0, 1, 0},
  {&__pyx_kp_s__248, __pyx_k__248, sizeof(__pyx_k__248), 0, 0, 1, 0},
  {&__pyx_kp_s__259, __pyx_k__259, sizeof(__pyx_k__259), 0, 0, 1, 0},
  {&__pyx_kp_s__281, __pyx_k__281, sizeof(__pyx_k__281), 0, 0, 1, 0},
  {&__pyx_kp_s__33, __pyx_k__33, sizeof(__pyx_k__33), 0, 0, 1, 0},
  {&__pyx_kp_s__34, __pyx_k__34, sizeof(__pyx_k__34), 0, 0, 1, 0},
  {&__pyx_kp_s__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 0, 1, 0},
  {&__pyx_kp_s__44, __pyx_k__44, sizeof(__pyx_k__44), 0, 0, 1, 0},
  {&__pyx_kp_s__53, __pyx_k__53, sizeof(__pyx_k__53), 0, 0, 1, 0},
  {&__pyx_kp_s__83, __pyx_k__83, sizeof(__pyx_k__83), 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_absolute, __pyx_k_absolute, sizeof(__pyx_k_absolute), 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_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_any, __pyx_k_any, sizeof(__pyx_k_any), 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_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_n_s_array_priority, __pyx_k_array_priority, sizeof(__pyx_k_array_priority), 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_ascontiguousarray, __pyx_k_ascontiguousarray, sizeof(__pyx_k_ascontiguousarray), 0, 0, 1, 1},
  {&__pyx_n_s_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 0, 0, 1, 1},
  {&__pyx_n_s_axis, __pyx_k_axis, sizeof(__pyx_k_axis), 0, 0, 1, 1},
  {&__pyx_n_s_axis1, __pyx_k_axis1, sizeof(__pyx_k_axis1), 0, 0, 1, 1},
  {&__pyx_n_s_axis2, __pyx_k_axis2, sizeof(__pyx_k_axis2), 0, 0, 1, 1},
  {&__pyx_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_should_be_specified_if_rep, __pyx_k_axis_should_be_specified_if_rep, sizeof(__pyx_k_axis_should_be_specified_if_rep), 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_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_bhilqBHILQefd, __pyx_k_bhilqBHILQefd, sizeof(__pyx_k_bhilqBHILQefd), 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_blocked_sum, __pyx_k_blocked_sum, sizeof(__pyx_k_blocked_sum), 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_boolean_array, __pyx_k_boolean_array, sizeof(__pyx_k_boolean_array), 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_cPickle, __pyx_k_cPickle, sizeof(__pyx_k_cPickle), 0, 0, 1, 1},
  {&__pyx_n_s_c_void_p, __pyx_k_c_void_p, sizeof(__pyx_k_c_void_p), 0, 0, 1, 1},
  {&__pyx_n_s_cachd_dir, __pyx_k_cachd_dir, sizeof(__pyx_k_cachd_dir), 0, 0, 1, 1},
  {&__pyx_n_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_kp_s_carray_cuh, __pyx_k_carray_cuh, sizeof(__pyx_k_carray_cuh), 0, 0, 1, 0},
  {&__pyx_n_s_casting, __pyx_k_casting, sizeof(__pyx_k_casting), 0, 0, 1, 1},
  {&__pyx_n_s_char, __pyx_k_char, sizeof(__pyx_k_char), 0, 0, 1, 1},
  {&__pyx_n_s_clip, __pyx_k_clip, sizeof(__pyx_k_clip), 0, 0, 1, 1},
  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_n_s_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_kp_s_const, __pyx_k_const, sizeof(__pyx_k_const), 0, 0, 1, 0},
  {&__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_t_n__raw__n__ind_get, __pyx_k_const_t_n__raw__n__ind_get, sizeof(__pyx_k_const_t_n__raw__n__ind_get), 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_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_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_n_s_cupy_boolean_array_indexing_nth, __pyx_k_cupy_boolean_array_indexing_nth, sizeof(__pyx_k_cupy_boolean_array_indexing_nth), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_clip, __pyx_k_cupy_clip, sizeof(__pyx_k_cupy_clip), 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_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_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_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_remainder, __pyx_k_cupy_remainder, sizeof(__pyx_k_cupy_remainder), 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_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_2, __pyx_k_d_d_2, sizeof(__pyx_k_d_d_2), 0, 0, 1, 0},
  {&__pyx_kp_s_d_l, __pyx_k_d_l, sizeof(__pyx_k_d_l), 0, 0, 1, 0},
  {&__pyx_n_s_data_as, __pyx_k_data_as, sizeof(__pyx_k_data_as), 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_device, __pyx_k_device, sizeof(__pyx_k_device), 0, 0, 1, 1},
  {&__pyx_kp_s_dfeqlihbQLIHB, __pyx_k_dfeqlihbQLIHB, sizeof(__pyx_k_dfeqlihbQLIHB), 0, 0, 1, 0},
  {&__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_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_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_l, __pyx_k_e_l, sizeof(__pyx_k_e_l), 0, 0, 1, 0},
  {&__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_elementwise_copy, __pyx_k_elementwise_copy, sizeof(__pyx_k_elementwise_copy), 0, 0, 1, 1},
  {&__pyx_n_s_elementwise_copy_2, __pyx_k_elementwise_copy_2, sizeof(__pyx_k_elementwise_copy_2), 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_elementwise_copy_where_2, __pyx_k_elementwise_copy_where_2, sizeof(__pyx_k_elementwise_copy_where_2), 0, 0, 1, 1},
  {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 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_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_2, __pyx_k_f_f_2, sizeof(__pyx_k_f_f_2), 0, 0, 1, 0},
  {&__pyx_kp_s_f_l, __pyx_k_f_l, sizeof(__pyx_k_f_l), 0, 0, 1, 0},
  {&__pyx_n_s_false, __pyx_k_false, sizeof(__pyx_k_false), 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_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_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_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_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_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_kp_s_home_beam2d_src_github_com_pfne, __pyx_k_home_beam2d_src_github_com_pfne, sizeof(__pyx_k_home_beam2d_src_github_com_pfne), 0, 0, 1, 0},
  {&__pyx_kp_s_home_beam2d_src_github_com_pfne_2, __pyx_k_home_beam2d_src_github_com_pfne_2, sizeof(__pyx_k_home_beam2d_src_github_com_pfne_2), 0, 0, 1, 0},
  {&__pyx_kp_s_home_beam2d_src_github_com_pfne_3, __pyx_k_home_beam2d_src_github_com_pfne_3, sizeof(__pyx_k_home_beam2d_src_github_com_pfne_3), 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_n_s_identity, __pyx_k_identity, sizeof(__pyx_k_identity), 0, 0, 1, 1},
  {&__pyx_kp_s_if_boolean_array_out_nth_a, __pyx_k_if_boolean_array_out_nth_a, sizeof(__pyx_k_if_boolean_array_out_nth_a), 0, 0, 1, 0},
  {&__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_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_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_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_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_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_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_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_insert, __pyx_k_insert, sizeof(__pyx_k_insert), 0, 0, 1, 1},
  {&__pyx_n_s_int, __pyx_k_int, sizeof(__pyx_k_int), 0, 0, 1, 1},
  {&__pyx_n_s_int16, __pyx_k_int16, sizeof(__pyx_k_int16), 0, 0, 1, 1},
  {&__pyx_n_s_int32, __pyx_k_int32, sizeof(__pyx_k_int32), 0, 0, 1, 1},
  {&__pyx_kp_s_int32__block_stride, __pyx_k_int32__block_stride, sizeof(__pyx_k_int32__block_stride), 0, 0, 1, 0},
  {&__pyx_n_s_int64, __pyx_k_int64, sizeof(__pyx_k_int64), 0, 0, 1, 1},
  {&__pyx_n_s_int8, __pyx_k_int8, sizeof(__pyx_k_int8), 0, 0, 1, 1},
  {&__pyx_n_s_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_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_isscalar, __pyx_k_isscalar, sizeof(__pyx_k_isscalar), 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_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_kern_add, __pyx_k_kern_add, sizeof(__pyx_k_kern_add), 0, 0, 1, 1},
  {&__pyx_n_s_kern_scan, __pyx_k_kern_scan, sizeof(__pyx_k_kern_scan), 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_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_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_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_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_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_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_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_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_1016, __pyx_k_ndarray___getitem___line_1016, sizeof(__pyx_k_ndarray___getitem___line_1016), 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_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_n_s_nonzero_1d_kernel, __pyx_k_nonzero_1d_kernel, sizeof(__pyx_k_nonzero_1d_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_nonzero_1d_kernel_2, __pyx_k_nonzero_1d_kernel_2, sizeof(__pyx_k_nonzero_1d_kernel_2), 0, 0, 1, 1},
  {&__pyx_n_s_nonzero_kernel, __pyx_k_nonzero_kernel, sizeof(__pyx_k_nonzero_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_nonzero_kernel_2, __pyx_k_nonzero_kernel_2, sizeof(__pyx_k_nonzero_kernel_2), 0, 0, 1, 1},
  {&__pyx_n_s_not_equal, __pyx_k_not_equal, sizeof(__pyx_k_not_equal), 0, 0, 1, 1},
  {&__pyx_n_s_nout, __pyx_k_nout, sizeof(__pyx_k_nout), 0, 0, 1, 1},
  {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
  {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
  {&__pyx_n_s_oct, __pyx_k_oct, sizeof(__pyx_k_oct), 0, 0, 1, 1},
  {&__pyx_n_s_offset, __pyx_k_offset, sizeof(__pyx_k_offset), 0, 0, 1, 1},
  {&__pyx_kp_s_only_integers_slices_ellipsis_nu, __pyx_k_only_integers_slices_ellipsis_nu, sizeof(__pyx_k_only_integers_slices_ellipsis_nu), 0, 0, 1, 0},
  {&__pyx_n_s_op, __pyx_k_op, sizeof(__pyx_k_op), 0, 0, 1, 1},
  {&__pyx_n_s_open, __pyx_k_open, sizeof(__pyx_k_open), 0, 0, 1, 1},
  {&__pyx_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_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__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__in_ind_size__out_ind_siz, __pyx_k_out0_a__in_ind_size__out_ind_siz, sizeof(__pyx_k_out0_a__in_ind_size__out_ind_siz), 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_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_in0, __pyx_k_out0_in0, sizeof(__pyx_k_out0_in0), 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_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_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_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_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_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_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_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_prod, __pyx_k_prod, sizeof(__pyx_k_prod), 0, 0, 1, 1},
  {&__pyx_n_s_property, __pyx_k_property, sizeof(__pyx_k_property), 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_d, __pyx_k_q_d, sizeof(__pyx_k_q_d), 0, 0, 1, 0},
  {&__pyx_kp_s_q_l, __pyx_k_q_l, sizeof(__pyx_k_q_l), 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_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_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_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_reduce_dims, __pyx_k_reduce_dims, sizeof(__pyx_k_reduce_dims), 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_remove, __pyx_k_remove, sizeof(__pyx_k_remove), 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_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_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_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_s, __pyx_k_s_s_s_s, sizeof(__pyx_k_s_s_s_s), 0, 0, 1, 0},
  {&__pyx_n_s_same_kind, __pyx_k_same_kind, sizeof(__pyx_k_same_kind), 0, 0, 1, 1},
  {&__pyx_n_s_scan, __pyx_k_scan, sizeof(__pyx_k_scan), 0, 0, 1, 1},
  {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  {&__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_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_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_six_zip, __pyx_k_six_zip, sizeof(__pyx_k_six_zip), 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_source, __pyx_k_source, sizeof(__pyx_k_source), 0, 0, 1, 1},
  {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
  {&__pyx_n_s_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_n_s_std, __pyx_k_std, sizeof(__pyx_k_std), 0, 0, 1, 1},
  {&__pyx_n_s_std_2, __pyx_k_std_2, sizeof(__pyx_k_std_2), 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_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_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
  {&__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_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_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  {&__pyx_n_s_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_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_unknown_ctype, __pyx_k_unknown_ctype, sizeof(__pyx_k_unknown_ctype), 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_c_contiguity, __pyx_k_update_c_contiguity, sizeof(__pyx_k_update_c_contiguity), 0, 0, 1, 1},
  {&__pyx_n_s_update_c_contiguity_2, __pyx_k_update_c_contiguity_2, sizeof(__pyx_k_update_c_contiguity_2), 0, 0, 1, 1},
  {&__pyx_n_s_update_contiguity, __pyx_k_update_contiguity, sizeof(__pyx_k_update_contiguity), 0, 0, 1, 1},
  {&__pyx_n_s_update_f_contiguity, __pyx_k_update_f_contiguity, sizeof(__pyx_k_update_f_contiguity), 0, 0, 1, 1},
  {&__pyx_n_s_util, __pyx_k_util, sizeof(__pyx_k_util), 0, 0, 1, 1},
  {&__pyx_n_s_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_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1},
  {&__pyx_kp_u_x___getitem___y_x_y_note_CuPy_ha, __pyx_k_x___getitem___y_x_y_note_CuPy_ha, sizeof(__pyx_k_x___getitem___y_x_y_note_CuPy_ha), 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_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_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 654, __pyx_L1_error)
  __pyx_builtin_property = __Pyx_GetBuiltinName(__pyx_n_s_property); if (!__pyx_builtin_property) __PYX_ERR(0, 686, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 81, __pyx_L1_error)
  __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(1, 135, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(1, 411, __pyx_L1_error)
  __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(1, 415, __pyx_L1_error)
  __pyx_builtin_NotImplemented = __Pyx_GetBuiltinName(__pyx_n_s_NotImplemented); if (!__pyx_builtin_NotImplemented) __PYX_ERR(1, 821, __pyx_L1_error)
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 1013, __pyx_L1_error)
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(1, 1045, __pyx_L1_error)
  __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(1, 1048, __pyx_L1_error)
  __pyx_builtin_sum = __Pyx_GetBuiltinName(__pyx_n_s_sum); if (!__pyx_builtin_sum) __PYX_ERR(1, 1118, __pyx_L1_error)
  __pyx_builtin_oct = __Pyx_GetBuiltinName(__pyx_n_s_oct); if (!__pyx_builtin_oct) __PYX_ERR(1, 1212, __pyx_L1_error)
  __pyx_builtin_hex = __Pyx_GetBuiltinName(__pyx_n_s_hex); if (!__pyx_builtin_hex) __PYX_ERR(1, 1215, __pyx_L1_error)
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 1283, __pyx_L1_error)
  __pyx_builtin_open = __Pyx_GetBuiltinName(__pyx_n_s_open); if (!__pyx_builtin_open) __PYX_ERR(2, 79, __pyx_L1_error)
  __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) __PYX_ERR(0, 235, __pyx_L1_error)
  __pyx_builtin_map = __Pyx_GetBuiltinName(__pyx_n_s_map); if (!__pyx_builtin_map) __PYX_ERR(0, 793, __pyx_L1_error)
  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(3, 146, __pyx_L1_error)
  __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(1, 2158, __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":81
 *         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(1, 81, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "cupy/core/core.pyx":135
 *             strides = _get_strides_for_nocopy_reshape(self, newshape)
 *             if strides.size() != shape.size():
 *                 raise AttributeError('incompatible shape')             # <<<<<<<<<<<<<<
 *             self._shape = shape
 *             self._strides = strides
 */
  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_incompatible_shape); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 135, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);

  /* "cupy/core/core.pyx":306
 *         a = self
 *         if not self._c_contiguous:
 *             with self.device:             # <<<<<<<<<<<<<<
 *                 a = ascontiguousarray(self)
 *             if a.data.device.id == device.get_device_id():
 */
  __pyx_tuple__5 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "cupy/core/core.pyx":355
 *         """
 *         if value == 0 and self._c_contiguous:
 *             self.data.memset_async(0, self.nbytes, stream.Stream(True))             # <<<<<<<<<<<<<<
 *         else:
 *             elementwise_copy(value, self, dtype=self.dtype)
 */
  __pyx_tuple__6 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "cupy/core/core.pyx":415
 *             axis = axes[i]
 *             if axis < -ndim or axis >= ndim:
 *                 raise IndexError('Axes overrun')             # <<<<<<<<<<<<<<
 *             axes[i] = axis % ndim
 * 
 */
  __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_Axes_overrun); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);

  /* "cupy/core/core.pyx":469
 *         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__8 = PyTuple_Pack(1, __pyx_kp_s_Axis_out_of_range); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 469, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "cupy/core/core.pyx":546
 *                     raise ValueError(msg % (axis_orig, ndim, ndim))
 *                 if axis_flags[_axis] == 1:
 *                     raise ValueError("duplicate value in 'axis'")             # <<<<<<<<<<<<<<
 *                 axis_flags[_axis] = 1
 *         else:
 */
  __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_duplicate_value_in_axis); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 546, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "cupy/core/core.pyx":570
 *                     any_ones = 1
 *                 else:
 *                     raise ValueError('cannot select an axis to squeeze out '             # <<<<<<<<<<<<<<
 *                                      'which has size not equal to one')
 * 
 */
  __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_cannot_select_an_axis_to_squeeze); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 570, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "cupy/core/core.pyx":1013
 *     def __len__(self):
 *         if self._shape.size() == 0:
 *             raise TypeError('len() of unsized object')             # <<<<<<<<<<<<<<
 *         return self._shape[0]
 * 
 */
  __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_len_of_unsized_object); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(1, 1013, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);

  /* "cupy/core/core.pyx":1052
 *                 ellipsis = i
 *         ndim = self._shape.size()
 *         noneslices = [slice(None)]             # <<<<<<<<<<<<<<
 *         if n_ellipses > 0:
 *             if n_ellipses > 1:
 */
  __pyx_slice__12 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__12)) __PYX_ERR(1, 1052, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__12);
  __Pyx_GIVEREF(__pyx_slice__12);

  /* "cupy/core/core.pyx":1055
 *         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__13 = PyTuple_Pack(1, __pyx_kp_s_Only_one_Ellipsis_is_allowed_in); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(1, 1055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);

  /* "cupy/core/core.pyx":1062
 * 
 *         if len(slices) > self.ndim + n_newaxes:
 *             raise IndexError('too many indices for array')             # <<<<<<<<<<<<<<
 * 
 *         # Check if advanced is true, and convert list/NumPy arrays to ndarray
 */
  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_too_many_indices_for_array); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(1, 1062, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "cupy/core/core.pyx":1077
 *                         return _boolean_array_indexing(self, s)
 *                     else:
 *                         raise ValueError('Boolean array indexing is supported '             # <<<<<<<<<<<<<<
 *                                          'only for same sized array.')
 *                 else:
 */
  __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_Boolean_array_indexing_is_suppor); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(1, 1077, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "cupy/core/core.pyx":1091
 *                 if type(s) is slice:
 *                     basic_slices.append(s)
 *                     adv_slices.append(slice(None))             # <<<<<<<<<<<<<<
 *                 elif s is None:
 *                     basic_slices.append(None)
 */
  __pyx_slice__16 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__16)) __PYX_ERR(1, 1091, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__16);
  __Pyx_GIVEREF(__pyx_slice__16);

  /* "cupy/core/core.pyx":1094
 *                 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__17 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__17)) __PYX_ERR(1, 1094, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__17);
  __Pyx_GIVEREF(__pyx_slice__17);

  /* "cupy/core/core.pyx":1097
 *                 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__18 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__18)) __PYX_ERR(1, 1097, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__18);
  __Pyx_GIVEREF(__pyx_slice__18);

  /* "cupy/core/core.pyx":1100
 *                     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__19 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__19)) __PYX_ERR(1, 1100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__19);
  __Pyx_GIVEREF(__pyx_slice__19);

  /* "cupy/core/core.pyx":1101
 *                 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__20 = PyTuple_Pack(1, __pyx_empty_tuple); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(1, 1101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "cupy/core/core.pyx":1105
 *                     adv_slices.append(scalar_array)
 *                 else:
 *                     raise IndexError(             # <<<<<<<<<<<<<<
 *                         'only integers, slices (`:`), ellipsis (`...`),'
 *                         'numpy.newaxis (`None`) and integer or'
 */
  __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_only_integers_slices_ellipsis_nu); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(1, 1105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);

  /* "cupy/core/core.pyx":1113
 *             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__22 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__22)) __PYX_ERR(1, 1113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__22);
  __Pyx_GIVEREF(__pyx_slice__22);

  /* "cupy/core/core.pyx":1119
 *             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 _adv_getitem(a, adv_slices)
 */
  __pyx_tuple__23 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(1, 1119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);

  /* "cupy/core/core.pyx":1136
 *                     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__24 = PyTuple_Pack(1, __pyx_kp_s_too_many_indices_for_array); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(1, 1136, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "cupy/core/core.pyx":1177
 *         for s in slices:
 *             if isinstance(s, (list, numpy.ndarray, ndarray)):
 *                 raise IndexError(             # <<<<<<<<<<<<<<
 *                     'Only basic indexing is supported for __setitem__')
 * 
 */
  __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_Only_basic_indexing_is_supported); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(1, 1177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "cupy/core/core.pyx":1276
 *         """
 *         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__26 = PyTuple_Pack(1, __pyx_kp_s_Only_numpy_ndarray_can_be_set_to); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(1, 1276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "cupy/core/core.pyx":1281
 *                 arr.dtype, self.dtype))
 *         if self.shape != arr.shape:
 *             raise ValueError('Shape mismatch')             # <<<<<<<<<<<<<<
 *         if not self._c_contiguous:
 *             raise RuntimeError('Cannot set to non-contiguous array')
 */
  __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_Shape_mismatch); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(1, 1281, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);

  /* "cupy/core/core.pyx":1283
 *             raise ValueError('Shape mismatch')
 *         if not self._c_contiguous:
 *             raise RuntimeError('Cannot set to non-contiguous array')             # <<<<<<<<<<<<<<
 * 
 *         arr = numpy.ascontiguousarray(arr)
 */
  __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_to_non_contiguous_arr); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(1, 1283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);

  /* "cupy/core/core.pyx":1350
 *                                  bint update_c_contiguity=True):
 *         if shape.size() != strides.size():
 *             raise ValueError('len(shape) != len(strides)')             # <<<<<<<<<<<<<<
 *         self._shape = shape
 *         self._strides = strides
 */
  __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_len_shape_len_strides); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(1, 1350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);

  /* "cupy/core/carray.pxi":79
 *     if _header_source is None:
 *         header_path = os.path.join(os.path.dirname(__file__), 'carray.cuh')
 *         with open(header_path) as header_file:             # <<<<<<<<<<<<<<
 *             _header_source = header_file.read()
 *     return _header_source
 */
  __pyx_tuple__30 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(2, 79, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);

  /* "cupy/core/elementwise.pxi":15
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):
 *     module_code = string.Template('''             # <<<<<<<<<<<<<<
 *     ${preamble}
 *     extern "C" __global__ void ${name}(${params}) {
 */
  __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_preamble_extern_C___global___vo); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);

  /* "cupy/core/elementwise.pxi":81
 * 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__32 = PyTuple_Pack(1, __pyx_kp_s_dtype_is_None); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 81, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);

  /* "cupy/core/elementwise.pxi":260
 *     if len(s) == 0:
 *         return ()
 *     return tuple([ParameterInfo(i, is_const) for i in s.strip().split(',')])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_s__34); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);

  /* "cupy/core/elementwise.pxi":270
 *         for p, a in six.moves.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 a != p.dtype:
 */
  __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_Output_arguments_must_be_cupy_nd); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);

  /* "cupy/core/elementwise.pxi":330
 *     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__37 = PyTuple_Pack(1, __pyx_kp_s_Specified_size_can_be_used_only); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);

  /* "cupy/core/elementwise.pxi":334
 *     else:
 *         if not is_not_none:
 *             raise ValueError('Loop size is Undecided')             # <<<<<<<<<<<<<<
 *     brod = broadcast(*value)
 *     value = []
 */
  __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s_Loop_size_is_Undecided); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);

  /* "cupy/core/elementwise.pxi":352
 *     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__39 = PyTuple_Pack(1, __pyx_kp_s_Output_arguments_type_must_be_cu); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);

  /* "cupy/core/elementwise.pxi":355
 *                 '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__40 = PyTuple_Pack(1, __pyx_kp_s_Out_shape_is_mismatched); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);

  /* "cupy/core/elementwise.pxi":375
 *         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__41 = PyTuple_Pack(1, __pyx_kp_s_Output_array_size_is_Undecided); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);

  /* "cupy/core/elementwise.pxi":382
 *         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__42 = PyTuple_Pack(1, __pyx_kp_s_Output_arguments_type_must_be_cu); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);

  /* "cupy/core/elementwise.pxi":385
 *                 '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__43 = PyTuple_Pack(1, __pyx_kp_s_Out_shape_is_mismatched); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);

  /* "cupy/core/elementwise.pxi":468
 *         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__45 = PyTuple_Pack(2, __pyx_kp_s_CIndexer__ind, Py_False); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);

  /* "cupy/core/elementwise.pxi":477
 *         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__46 = PyTuple_Pack(1, __pyx_kp_s_Can_not_use_i_as_a_parameter_nam); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__46);
  __Pyx_GIVEREF(__pyx_tuple__46);

  /* "cupy/core/elementwise.pxi":501
 *         cdef function.Function kern
 * 
 *         size = kwargs.pop('size', None)             # <<<<<<<<<<<<<<
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)
 */
  __pyx_tuple__47 = PyTuple_Pack(2, __pyx_n_s_size, Py_None); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);

  /* "cupy/core/elementwise.pxi":680
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (
 *             ParameterInfo('CIndexer _ind', False),)             # <<<<<<<<<<<<<<
 *         self._routine_cache = {}
 * 
 */
  __pyx_tuple__48 = PyTuple_Pack(2, __pyx_kp_s_CIndexer__ind, Py_False); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(0, 680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__48);
  __Pyx_GIVEREF(__pyx_tuple__48);

  /* "cupy/core/elementwise.pxi":719
 *         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__49 = PyTuple_Pack(2, __pyx_n_s_out, Py_None); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 719, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);

  /* "cupy/core/elementwise.pxi":720
 * 
 *         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', 'same_kind')
 */
  __pyx_tuple__50 = PyTuple_Pack(2, __pyx_n_s_dtype, Py_None); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);

  /* "cupy/core/elementwise.pxi":722
 *         dtype = kwargs.pop('dtype', None)
 *         # Note default behavior of casting is 'same_kind' on numpy>=1.10
 *         casting = kwargs.pop('casting', 'same_kind')             # <<<<<<<<<<<<<<
 *         if dtype is not None:
 *             dtype = numpy.dtype(dtype).type
 */
  __pyx_tuple__51 = PyTuple_Pack(2, __pyx_n_s_casting, __pyx_n_s_same_kind); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 722, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);

  /* "cupy/core/elementwise.pxi":740
 *                 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__52 = PyTuple_Pack(1, __pyx_kp_s_Cannot_specify_out_as_both_a_pos); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__52);
  __Pyx_GIVEREF(__pyx_tuple__52);

  /* "cupy/core/elementwise.pxi":789
 *             typ, rt = t
 * 
 *         types = typ.split('->')             # <<<<<<<<<<<<<<
 *         if len(types) == 1:
 *             in_types = out_types = tuple(types)
 */
  __pyx_tuple__54 = PyTuple_Pack(1, __pyx_kp_s__53); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(0, 789, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__54);
  __Pyx_GIVEREF(__pyx_tuple__54);

  /* "cupy/core/reduction.pxi":19
 *     if identity is None:
 *         identity = ''
 *     module_code = string.Template('''             # <<<<<<<<<<<<<<
 *     ${type_preamble}
 *     ${preamble}
 */
  __pyx_tuple__55 = PyTuple_Pack(1, __pyx_kp_s_type_preamble_preamble_define_R); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(3, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_GIVEREF(__pyx_tuple__55);

  /* "cupy/core/reduction.pxi":123
 *     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__56 = PyTuple_Pack(1, __pyx_kp_s_Axis_overrun); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(3, 123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__56);
  __Pyx_GIVEREF(__pyx_tuple__56);

  /* "cupy/core/reduction.pxi":146
 *         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__57 = PyTuple_Pack(1, __pyx_kp_s_Illegal_conditions); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(3, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_GIVEREF(__pyx_tuple__57);

  /* "cupy/core/reduction.pxi":198
 *         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__58 = PyTuple_Pack(2, __pyx_kp_s_T_in0, Py_True); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(3, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__58);
  __Pyx_GIVEREF(__pyx_tuple__58);

  /* "cupy/core/reduction.pxi":199
 *         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__59 = PyTuple_Pack(2, __pyx_kp_s_T_out0, Py_False); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(3, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);

  /* "cupy/core/reduction.pxi":202
 *         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__60 = PyTuple_Pack(2, __pyx_kp_s_CIndexer__in_ind_CIndexer__out_i, Py_False); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(3, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__60);
  __Pyx_GIVEREF(__pyx_tuple__60);

  /* "cupy/core/reduction.pxi":204
 *             _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__61 = PyTuple_Pack(2, __pyx_kp_s_int32__block_stride, Py_True); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(3, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__61);
  __Pyx_GIVEREF(__pyx_tuple__61);

  /* "cupy/core/reduction.pxi":211
 *     def __call__(self, a, axis=None, dtype=None, out=None, keepdims=False):
 *         if not isinstance(a, ndarray):
 *             raise TypeError('Input type must be cupy.ndarray')             # <<<<<<<<<<<<<<
 *         if self.identity is None and 0 in a.shape:
 *             raise ValueError(('zero-size array to reduction operation'
 */
  __pyx_tuple__62 = PyTuple_Pack(1, __pyx_kp_s_Input_type_must_be_cupy_ndarray); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(3, 211, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__62);
  __Pyx_GIVEREF(__pyx_tuple__62);

  /* "cupy/core/reduction.pxi":338
 *         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__63 = PyTuple_Pack(2, __pyx_kp_s_CIndexer__in_ind_CIndexer__out_i, Py_False); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(3, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__63);
  __Pyx_GIVEREF(__pyx_tuple__63);

  /* "cupy/core/reduction.pxi":339
 *             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__64 = PyTuple_Pack(2, __pyx_kp_s_int32__block_stride, Py_True); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(3, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__64);
  __Pyx_GIVEREF(__pyx_tuple__64);

  /* "cupy/core/reduction.pxi":370
 *         """
 * 
 *         out = kwargs.pop('out', None)             # <<<<<<<<<<<<<<
 *         axis = kwargs.pop('axis', None)
 *         keepdims = kwargs.pop('keepdims', False)
 */
  __pyx_tuple__65 = PyTuple_Pack(2, __pyx_n_s_out, Py_None); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(3, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__65);
  __Pyx_GIVEREF(__pyx_tuple__65);

  /* "cupy/core/reduction.pxi":371
 * 
 *         out = kwargs.pop('out', None)
 *         axis = kwargs.pop('axis', None)             # <<<<<<<<<<<<<<
 *         keepdims = kwargs.pop('keepdims', False)
 *         if kwargs:
 */
  __pyx_tuple__66 = PyTuple_Pack(2, __pyx_n_s_axis, Py_None); if (unlikely(!__pyx_tuple__66)) __PYX_ERR(3, 371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__66);
  __Pyx_GIVEREF(__pyx_tuple__66);

  /* "cupy/core/reduction.pxi":372
 *         out = kwargs.pop('out', None)
 *         axis = kwargs.pop('axis', None)
 *         keepdims = kwargs.pop('keepdims', False)             # <<<<<<<<<<<<<<
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)
 */
  __pyx_tuple__67 = PyTuple_Pack(2, __pyx_n_s_keepdims, Py_False); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(3, 372, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__67);
  __Pyx_GIVEREF(__pyx_tuple__67);

  /* "cupy/core/reduction.pxi":383
 *         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__68 = PyTuple_Pack(1, __pyx_kp_s__4); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(3, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__68);
  __Pyx_GIVEREF(__pyx_tuple__68);

  /* "cupy/core/reduction.pxi":385
 *                 raise NotImplementedError('')
 *             if len(out_args) != 0:
 *                 raise ValueError("cannot specify 'out' as both "             # <<<<<<<<<<<<<<
 *                                  "a positional and keyword argument")
 *             out_args = [out]
 */
  __pyx_tuple__69 = PyTuple_Pack(1, __pyx_kp_s_cannot_specify_out_as_both_a_pos); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(3, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__69);
  __Pyx_GIVEREF(__pyx_tuple__69);

  /* "cupy/core/reduction.pxi":459
 *             rt = tuple([i or j for i, j in six_zip(rt, routine)])
 * 
 *         types = typ.split('->')             # <<<<<<<<<<<<<<
 *         if len(types) == 1:
 *             in_types = out_types = tuple(types)
 */
  __pyx_tuple__70 = PyTuple_Pack(1, __pyx_kp_s__53); if (unlikely(!__pyx_tuple__70)) __PYX_ERR(3, 459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__70);
  __Pyx_GIVEREF(__pyx_tuple__70);

  /* "cupy/core/core.pyx":1632
 *         ndim = a._shape.size()
 *         if ndmin > ndim:
 *             a.shape = (1,) * (ndmin - ndim) + a.shape             # <<<<<<<<<<<<<<
 *         return a
 *     else:
 */
  __pyx_tuple__71 = PyTuple_New(1); if (unlikely(!__pyx_tuple__71)) __PYX_ERR(1, 1632, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__71);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__71, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__71);

  /* "cupy/core/core.pyx":1674
 *         start += ndim
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 *         raise ValueError('Axis out of range')             # <<<<<<<<<<<<<<
 *     if axis < start:
 *         start -= 1
 */
  __pyx_tuple__72 = PyTuple_Pack(1, __pyx_kp_s_Axis_out_of_range); if (unlikely(!__pyx_tuple__72)) __PYX_ERR(1, 1674, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__72);
  __Pyx_GIVEREF(__pyx_tuple__72);

  /* "cupy/core/core.pyx":1719
 *         cdef vector.vector[vector.vector[Py_ssize_t]] shape_arr
 *         cdef ndarray a, view
 *         rev = slice(None, None, -1)             # <<<<<<<<<<<<<<
 * 
 *         self.nd = 0
 */
  __pyx_slice__73 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__73)) __PYX_ERR(1, 1719, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__73);
  __Pyx_GIVEREF(__pyx_slice__73);

  /* "cupy/core/core.pyx":1760
 *                     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__74 = PyTuple_Pack(1, __pyx_kp_s_Broadcasting_failed); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(1, 1760, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__74);
  __Pyx_GIVEREF(__pyx_tuple__74);

  /* "cupy/core/core.pyx":1779
 *     """
 *     if array.ndim > len(shape):
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             'input operand has more dimensions than allowed by the axis '
 *             'remapping')
 */
  __pyx_tuple__75 = PyTuple_Pack(1, __pyx_kp_s_input_operand_has_more_dimension); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(1, 1779, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__75);
  __Pyx_GIVEREF(__pyx_tuple__75);

  /* "cupy/core/core.pyx":1791
 *             strides[j] = array._strides[j % array.ndim]
 *         elif a_sh != 1:
 *             raise ValueError('Broadcasting failed')             # <<<<<<<<<<<<<<
 * 
 *     view = array.view()
 */
  __pyx_tuple__76 = PyTuple_Pack(1, __pyx_kp_s_Broadcasting_failed); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(1, 1791, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__76);
  __Pyx_GIVEREF(__pyx_tuple__76);

  /* "cupy/core/core.pyx":1818
 *                 "'repeats' should not be negative: {}".format(repeats))
 *         if axis is None:
 *             a = a.reshape((-1, 1))             # <<<<<<<<<<<<<<
 *             ret = ndarray((a.size, repeats), dtype=a.dtype)
 *             if ret.size:
 */
  __pyx_tuple__77 = PyTuple_Pack(2, __pyx_int_neg_1, __pyx_int_1); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(1, 1818, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__77);
  __Pyx_GIVEREF(__pyx_tuple__77);
  __pyx_tuple__78 = PyTuple_Pack(1, __pyx_tuple__77); if (unlikely(!__pyx_tuple__78)) __PYX_ERR(1, 1818, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__78);
  __Pyx_GIVEREF(__pyx_tuple__78);

  /* "cupy/core/core.pyx":1832
 *                     .format(repeats))
 *         if axis is None:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 "'axis' should be specified if 'repeats' is sequence")
 *         if a.shape[axis] != len(repeats):
 */
  __pyx_tuple__79 = PyTuple_Pack(1, __pyx_kp_s_axis_should_be_specified_if_rep); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(1, 1832, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__79);
  __Pyx_GIVEREF(__pyx_tuple__79);

  /* "cupy/core/core.pyx":1848
 *     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__80 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__80)) __PYX_ERR(1, 1848, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__80);
  __Pyx_GIVEREF(__pyx_slice__80);

  /* "cupy/core/core.pyx":1866
 *     ret = ndarray(shape, dtype=dtype)
 * 
 *     skip = (slice(None),) * axis             # <<<<<<<<<<<<<<
 *     i = 0
 *     for a in tup:
 */
  __pyx_slice__81 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__81)) __PYX_ERR(1, 1866, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__81);
  __Pyx_GIVEREF(__pyx_slice__81);
  __pyx_tuple__82 = PyTuple_New(1); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(1, 1866, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__82);
  __Pyx_INCREF(__pyx_slice__81);
  __Pyx_GIVEREF(__pyx_slice__81);
  PyTuple_SET_ITEM(__pyx_tuple__82, 0, __pyx_slice__81);
  __Pyx_GIVEREF(__pyx_tuple__82);

  /* "cupy/core/core.pyx":1880
 * 
 * cpdef _create_bit_op(name, op, no_bool, doc=''):
 *     types = () if no_bool else ('??->?',)             # <<<<<<<<<<<<<<
 *     return create_ufunc(
 *         'cupy_' + name,
 */
  __pyx_tuple__84 = PyTuple_Pack(1, __pyx_kp_s__83); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(1, 1880, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__84);
  __Pyx_GIVEREF(__pyx_tuple__84);

  /* "cupy/core/core.pyx":1883
 *     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__85 = 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__85)) __PYX_ERR(1, 1883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__85);
  __Pyx_GIVEREF(__pyx_tuple__85);

  /* "cupy/core/core.pyx":2018
 *     else:
 *         if not (-a.ndim <= axis < a.ndim):
 *             raise ValueError('Axis overrun')             # <<<<<<<<<<<<<<
 *         if a.ndim != 0:
 *             axis %= a.ndim
 */
  __pyx_tuple__86 = PyTuple_Pack(1, __pyx_kp_s_Axis_overrun); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(1, 2018, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__86);
  __Pyx_GIVEREF(__pyx_tuple__86);

  /* "cupy/core/core.pyx":2035
 *         else:
 *             if out.dtype != a.dtype:
 *                 raise TypeError('Output dtype mismatch')             # <<<<<<<<<<<<<<
 *             if out.shape != a.shape[1:]:
 *                 raise ValueError('Output shape mismatch')
 */
  __pyx_tuple__87 = PyTuple_Pack(1, __pyx_kp_s_Output_dtype_mismatch); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(1, 2035, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__87);
  __Pyx_GIVEREF(__pyx_tuple__87);

  /* "cupy/core/core.pyx":2036
 *             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__88 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__88)) __PYX_ERR(1, 2036, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__88);
  __Pyx_GIVEREF(__pyx_slice__88);

  /* "cupy/core/core.pyx":2037
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:
 *                 raise ValueError('Output shape mismatch')             # <<<<<<<<<<<<<<
 *             out[()] = a[indices]
 *             return out
 */
  __pyx_tuple__89 = PyTuple_Pack(1, __pyx_kp_s_Output_shape_mismatch); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(1, 2037, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__89);
  __Pyx_GIVEREF(__pyx_tuple__89);

  /* "cupy/core/core.pyx":2048
 *     else:
 *         if out.dtype != a.dtype:
 *             raise TypeError('Output dtype mismatch')             # <<<<<<<<<<<<<<
 *         if out.shape != out_shape:
 *             raise ValueError('Output shape mismatch')
 */
  __pyx_tuple__90 = PyTuple_Pack(1, __pyx_kp_s_Output_dtype_mismatch); if (unlikely(!__pyx_tuple__90)) __PYX_ERR(1, 2048, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__90);
  __Pyx_GIVEREF(__pyx_tuple__90);

  /* "cupy/core/core.pyx":2050
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:
 *             raise ValueError('Output shape mismatch')             # <<<<<<<<<<<<<<
 * 
 *     cdim = indices.size
 */
  __pyx_tuple__91 = PyTuple_Pack(1, __pyx_kp_s_Output_shape_mismatch); if (unlikely(!__pyx_tuple__91)) __PYX_ERR(1, 2050, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__91);
  __Pyx_GIVEREF(__pyx_tuple__91);

  /* "cupy/core/core.pyx":2055
 *     rdim = internal.prod(rshape)
 *     indices = indices.reshape(
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))             # <<<<<<<<<<<<<<
 *     if axis == 0 or axis is None:
 *         return _take_kernel_0axis(
 */
  __pyx_tuple__92 = PyTuple_New(1); if (unlikely(!__pyx_tuple__92)) __PYX_ERR(1, 2055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__92);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__92, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__92);
  __pyx_tuple__93 = PyTuple_New(1); if (unlikely(!__pyx_tuple__93)) __PYX_ERR(1, 2055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__93);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__93, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__93);

  /* "cupy/core/core.pyx":2081
 * 
 *     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__94 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__94)) __PYX_ERR(1, 2081, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__94);
  __Pyx_GIVEREF(__pyx_slice__94);

  /* "cupy/core/core.pyx":2089
 *     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__95 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__95)) __PYX_ERR(1, 2089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__95);
  __Pyx_GIVEREF(__pyx_slice__95);

  /* "cupy/core/core.pyx":2090
 *     ret._set_shape_and_strides(
 *         a.shape[:-2] + (diag_size,),
 *         a.strides[:-2] + (a.strides[-1] + a.strides[-2],))             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
  __pyx_slice__96 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__96)) __PYX_ERR(1, 2090, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__96);
  __Pyx_GIVEREF(__pyx_slice__96);

  /* "cupy/core/core.pyx":2164
 *     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__97 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__97)) __PYX_ERR(1, 2164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__97);
  __Pyx_GIVEREF(__pyx_tuple__97);

  /* "cupy/core/core.pyx":2190
 * 
 *     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__98 = PyTuple_Pack(1, __pyx_kp_s_Not_supported_dtype_combination); if (unlikely(!__pyx_tuple__98)) __PYX_ERR(1, 2190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__98);
  __Pyx_GIVEREF(__pyx_tuple__98);

  /* "cupy/core/core.pyx":2214
 * 
 *     if a._shape[a_axis] != b._shape[b_axis]:
 *         raise ValueError('Axis dimension mismatch')             # <<<<<<<<<<<<<<
 * 
 *     if a_axis:
 */
  __pyx_tuple__99 = PyTuple_Pack(1, __pyx_kp_s_Axis_dimension_mismatch); if (unlikely(!__pyx_tuple__99)) __PYX_ERR(1, 2214, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__99);
  __Pyx_GIVEREF(__pyx_tuple__99);

  /* "cupy/core/core.pyx":2237
 *     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__100 = PyTuple_Pack(1, __pyx_kp_s_Output_array_has_an_invalid_size); if (unlikely(!__pyx_tuple__100)) __PYX_ERR(1, 2237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__100);
  __Pyx_GIVEREF(__pyx_tuple__100);

  /* "cupy/core/core.pyx":2239
 *             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__101 = PyTuple_Pack(1, __pyx_kp_s_Output_array_must_be_C_contiguou); if (unlikely(!__pyx_tuple__101)) __PYX_ERR(1, 2239, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__101);
  __Pyx_GIVEREF(__pyx_tuple__101);

  /* "cupy/core/core.pyx":2249
 *     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__102 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__102)) __PYX_ERR(1, 2249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__102);
  __Pyx_GIVEREF(__pyx_slice__102);
  __pyx_tuple__103 = PyTuple_Pack(2, __pyx_slice__102, Py_None); if (unlikely(!__pyx_tuple__103)) __PYX_ERR(1, 2249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__103);
  __Pyx_GIVEREF(__pyx_tuple__103);
  __pyx_slice__104 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__104)) __PYX_ERR(1, 2249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__104);
  __Pyx_GIVEREF(__pyx_slice__104);
  __pyx_tuple__105 = PyTuple_Pack(2, Py_None, __pyx_slice__104); if (unlikely(!__pyx_tuple__105)) __PYX_ERR(1, 2249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__105);
  __Pyx_GIVEREF(__pyx_tuple__105);

  /* "cupy/core/core.pyx":2273
 *     cdef ndarray ret
 *     if a.ndim <= 2:
 *         ret = ndarray((1,), dtype=numpy.uintp)             # <<<<<<<<<<<<<<
 *         ret.fill(a.data.ptr)
 *         return ret
 */
  __pyx_tuple__106 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__106)) __PYX_ERR(1, 2273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__106);
  __Pyx_GIVEREF(__pyx_tuple__106);
  __pyx_tuple__107 = PyTuple_Pack(1, __pyx_tuple__106); if (unlikely(!__pyx_tuple__107)) __PYX_ERR(1, 2273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__107);
  __Pyx_GIVEREF(__pyx_tuple__107);

  /* "cupy/core/core.pyx":2277
 *         return ret
 *     else:
 *         return _get_all_addresses(a.data.ptr, a.shape[:-2], a.strides[:-2])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_slice__108 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__108)) __PYX_ERR(1, 2277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__108);
  __Pyx_GIVEREF(__pyx_slice__108);
  __pyx_slice__109 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__109)) __PYX_ERR(1, 2277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__109);
  __Pyx_GIVEREF(__pyx_slice__109);

  /* "cupy/core/core.pyx":2325
 *         ldout = 1
 *     else:
 *         b_part_outshape = b.shape[-1:]             # <<<<<<<<<<<<<<
 *         ldout = b.shape[-1]
 * 
 */
  __pyx_slice__110 = PySlice_New(__pyx_int_neg_1, Py_None, Py_None); if (unlikely(!__pyx_slice__110)) __PYX_ERR(1, 2325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__110);
  __Pyx_GIVEREF(__pyx_slice__110);

  /* "cupy/core/core.pyx":2332
 *         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__111 = PyTuple_New(1); if (unlikely(!__pyx_tuple__111)) __PYX_ERR(1, 2332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__111);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__111, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__111);

  /* "cupy/core/core.pyx":2333
 *         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__112 = PyTuple_New(1); if (unlikely(!__pyx_tuple__112)) __PYX_ERR(1, 2333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__112);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_tuple__112, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_tuple__112);

  /* "cupy/core/core.pyx":2338
 *         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__113 = PyTuple_New(1); if (unlikely(!__pyx_tuple__113)) __PYX_ERR(1, 2338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__113);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__113, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__113);

  /* "cupy/core/core.pyx":2339
 *         view._set_shape_and_strides(
 *             (1,) * (a.ndim - b.ndim) + b.shape,
 *             (0,) * (a.ndim - b.ndim) + b.strides)             # <<<<<<<<<<<<<<
 *         b = view
 * 
 */
  __pyx_tuple__114 = PyTuple_New(1); if (unlikely(!__pyx_tuple__114)) __PYX_ERR(1, 2339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__114);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_tuple__114, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_tuple__114);

  /* "cupy/core/core.pyx":2342
 *         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__115 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__115)) __PYX_ERR(1, 2342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__115);
  __Pyx_GIVEREF(__pyx_slice__115);
  __pyx_slice__116 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__116)) __PYX_ERR(1, 2342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__116);
  __Pyx_GIVEREF(__pyx_slice__116);

  /* "cupy/core/core.pyx":2377
 *     out_view_strides = out.strides
 *     if a_part_outshape == ():
 *         out_view_shape += (1,)             # <<<<<<<<<<<<<<
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():
 */
  __pyx_tuple__117 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__117)) __PYX_ERR(1, 2377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__117);
  __Pyx_GIVEREF(__pyx_tuple__117);

  /* "cupy/core/core.pyx":2378
 *     if a_part_outshape == ():
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)             # <<<<<<<<<<<<<<
 *     if b_part_outshape == ():
 *         out_view_shape += (1,)
 */
  __pyx_tuple__118 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__118)) __PYX_ERR(1, 2378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__118);
  __Pyx_GIVEREF(__pyx_tuple__118);

  /* "cupy/core/core.pyx":2380
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():
 *         out_view_shape += (1,)             # <<<<<<<<<<<<<<
 *         out_view_strides += (0,)
 * 
 */
  __pyx_tuple__119 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__119)) __PYX_ERR(1, 2380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__119);
  __Pyx_GIVEREF(__pyx_tuple__119);

  /* "cupy/core/core.pyx":2381
 *     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__120 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__120)) __PYX_ERR(1, 2381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__120);
  __Pyx_GIVEREF(__pyx_tuple__120);

  /* "cupy/core/core.pyx":2565
 *     return create_ufunc(
 *         'cupy_' + name,
 *         ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',             # <<<<<<<<<<<<<<
 *          'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?'),
 *         'out0 = in0 %s in1' % op,
 */
  __pyx_tuple__121 = PyTuple_Pack(14, __pyx_kp_s__83, __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__121)) __PYX_ERR(1, 2565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__121);
  __Pyx_GIVEREF(__pyx_tuple__121);

  /* "cupy/core/core.pyx":2897
 *     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__122 = PyTuple_Pack(1, __pyx_kp_s_extern_C___global___void_name_c); if (unlikely(!__pyx_tuple__122)) __PYX_ERR(1, 2897, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__122);
  __Pyx_GIVEREF(__pyx_tuple__122);

  /* "cupy/core/core.pyx":2944
 *     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__123 = PyTuple_Pack(1, __pyx_kp_s_extern_C___global___void_name_C); if (unlikely(!__pyx_tuple__123)) __PYX_ERR(1, 2944, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__123);
  __Pyx_GIVEREF(__pyx_tuple__123);

  /* "cupy/core/core.pyx":2966
 *     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__124 = PyTuple_Pack(1, __pyx_kp_s_extern_C___global___void_name_c_2); if (unlikely(!__pyx_tuple__124)) __PYX_ERR(1, 2966, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__124);
  __Pyx_GIVEREF(__pyx_tuple__124);

  /* "cupy/core/core.pyx":2990
 *     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__125 = PyTuple_Pack(1, __pyx_kp_s_extern_C___global___void_name_c_3); if (unlikely(!__pyx_tuple__125)) __PYX_ERR(1, 2990, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__125);
  __Pyx_GIVEREF(__pyx_tuple__125);

  /* "cupy/core/core.pyx":3031
 *     """
 *     if a.ndim != 1:
 *         raise TypeError("Input array should be 1D array.")             # <<<<<<<<<<<<<<
 * 
 *     block_size = 256
 */
  __pyx_tuple__126 = PyTuple_Pack(1, __pyx_kp_s_Input_array_should_be_1D_array); if (unlikely(!__pyx_tuple__126)) __PYX_ERR(1, 3031, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__126);
  __Pyx_GIVEREF(__pyx_tuple__126);

  /* "cupy/core/core.pyx":3039
 *     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__127 = PyTuple_Pack(1, __pyx_kp_s_Provided_out_is_the_wrong_size); if (unlikely(!__pyx_tuple__127)) __PYX_ERR(1, 3039, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__127);
  __Pyx_GIVEREF(__pyx_tuple__127);

  /* "cupy/core/core.pyx":1203
 *         return int(self.get())
 * 
 *     if sys.version_info < (3,):             # <<<<<<<<<<<<<<
 *         def __long__(self):
 *             # Avoid using long() for flake8
 */
  __pyx_tuple__128 = PyTuple_Pack(1, __pyx_int_3); if (unlikely(!__pyx_tuple__128)) __PYX_ERR(1, 1203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__128);
  __Pyx_GIVEREF(__pyx_tuple__128);

  /* "cupy/core/elementwise.pxi":37
 * 
 * cdef dict _typenames_base = {
 *     numpy.dtype('float64'): 'double',             # <<<<<<<<<<<<<<
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',
 */
  __pyx_tuple__129 = PyTuple_Pack(1, __pyx_n_s_float64); if (unlikely(!__pyx_tuple__129)) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__129);
  __Pyx_GIVEREF(__pyx_tuple__129);

  /* "cupy/core/elementwise.pxi":38
 * cdef dict _typenames_base = {
 *     numpy.dtype('float64'): 'double',
 *     numpy.dtype('float32'): 'float',             # <<<<<<<<<<<<<<
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('int64'): 'long long',
 */
  __pyx_tuple__130 = PyTuple_Pack(1, __pyx_n_s_float32); if (unlikely(!__pyx_tuple__130)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__130);
  __Pyx_GIVEREF(__pyx_tuple__130);

  /* "cupy/core/elementwise.pxi":39
 *     numpy.dtype('float64'): 'double',
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',
 */
  __pyx_tuple__131 = PyTuple_Pack(1, __pyx_n_s_float16); if (unlikely(!__pyx_tuple__131)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__131);
  __Pyx_GIVEREF(__pyx_tuple__131);

  /* "cupy/core/elementwise.pxi":40
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('int64'): 'long long',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int32'): 'int',
 *     numpy.dtype('int16'): 'short',
 */
  __pyx_tuple__132 = PyTuple_Pack(1, __pyx_n_s_int64); if (unlikely(!__pyx_tuple__132)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__132);
  __Pyx_GIVEREF(__pyx_tuple__132);

  /* "cupy/core/elementwise.pxi":41
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int16'): 'short',
 *     numpy.dtype('int8'): 'signed char',
 */
  __pyx_tuple__133 = PyTuple_Pack(1, __pyx_n_s_int32); if (unlikely(!__pyx_tuple__133)) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__133);
  __Pyx_GIVEREF(__pyx_tuple__133);

  /* "cupy/core/elementwise.pxi":42
 *     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__134 = PyTuple_Pack(1, __pyx_n_s_int16); if (unlikely(!__pyx_tuple__134)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__134);
  __Pyx_GIVEREF(__pyx_tuple__134);

  /* "cupy/core/elementwise.pxi":43
 *     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__135 = PyTuple_Pack(1, __pyx_n_s_int8); if (unlikely(!__pyx_tuple__135)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__135);
  __Pyx_GIVEREF(__pyx_tuple__135);

  /* "cupy/core/elementwise.pxi":44
 *     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__136 = PyTuple_Pack(1, __pyx_n_s_uint64); if (unlikely(!__pyx_tuple__136)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__136);
  __Pyx_GIVEREF(__pyx_tuple__136);

  /* "cupy/core/elementwise.pxi":45
 *     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__137 = PyTuple_Pack(1, __pyx_n_s_uint32); if (unlikely(!__pyx_tuple__137)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__137);
  __Pyx_GIVEREF(__pyx_tuple__137);

  /* "cupy/core/elementwise.pxi":46
 *     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__138 = PyTuple_Pack(1, __pyx_n_s_uint16); if (unlikely(!__pyx_tuple__138)) __PYX_ERR(0, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__138);
  __Pyx_GIVEREF(__pyx_tuple__138);

  /* "cupy/core/elementwise.pxi":47
 *     numpy.dtype('uint32'): 'unsigned int',
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',             # <<<<<<<<<<<<<<
 *     numpy.dtype('bool'): 'bool',
 * }
 */
  __pyx_tuple__139 = PyTuple_Pack(1, __pyx_n_s_uint8); if (unlikely(!__pyx_tuple__139)) __PYX_ERR(0, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__139);
  __Pyx_GIVEREF(__pyx_tuple__139);

  /* "cupy/core/elementwise.pxi":48
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',
 *     numpy.dtype('bool'): 'bool',             # <<<<<<<<<<<<<<
 * }
 * 
 */
  __pyx_tuple__140 = PyTuple_Pack(1, __pyx_n_s_bool_2); if (unlikely(!__pyx_tuple__140)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__140);
  __Pyx_GIVEREF(__pyx_tuple__140);

  /* "cupy/core/elementwise.pxi":257
 * 
 * @util.memoize()
 * def _get_param_info(s, is_const):             # <<<<<<<<<<<<<<
 *     if len(s) == 0:
 *         return ()
 */
  __pyx_tuple__141 = PyTuple_Pack(3, __pyx_n_s_s_2, __pyx_n_s_is_const, __pyx_n_s_i); if (unlikely(!__pyx_tuple__141)) __PYX_ERR(0, 257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__141);
  __Pyx_GIVEREF(__pyx_tuple__141);
  __pyx_codeobj__142 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__141, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne, __pyx_n_s_get_param_info, 257, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__142)) __PYX_ERR(0, 257, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":264
 * 
 * @util.memoize()
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):             # <<<<<<<<<<<<<<
 *     type_dict = {}
 *     if out_args_dtype:
 */
  __pyx_tuple__143 = 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__143)) __PYX_ERR(0, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__143);
  __Pyx_GIVEREF(__pyx_tuple__143);
  __pyx_codeobj__144 = (PyObject*)__Pyx_PyCode_New(4, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__143, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne, __pyx_n_s_decide_params_type, 264, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__144)) __PYX_ERR(0, 264, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":390
 * 
 * @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__145 = 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__145)) __PYX_ERR(0, 390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__145);
  __Pyx_GIVEREF(__pyx_tuple__145);
  __pyx_codeobj__146 = (PyObject*)__Pyx_PyCode_New(7, 0, 15, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__145, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne, __pyx_n_s_get_elementwise_kernel, 390, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__146)) __PYX_ERR(0, 390, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":557
 * 
 * @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__147 = 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__147)) __PYX_ERR(0, 557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__147);
  __Pyx_GIVEREF(__pyx_tuple__147);
  __pyx_codeobj__148 = (PyObject*)__Pyx_PyCode_New(7, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__147, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne, __pyx_n_s_get_ufunc_kernel, 557, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__148)) __PYX_ERR(0, 557, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":665
 * 
 *     """
 *     def __init__(self, name, nin, nout, ops, preamble='', doc=''):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self.nin = nin
 */
  __pyx_tuple__149 = PyTuple_Pack(12, __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_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__149)) __PYX_ERR(0, 665, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__149);
  __Pyx_GIVEREF(__pyx_tuple__149);
  __pyx_codeobj__150 = (PyObject*)__Pyx_PyCode_New(7, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__149, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne, __pyx_n_s_init, 665, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__150)) __PYX_ERR(0, 665, __pyx_L1_error)
  __pyx_tuple__151 = PyTuple_Pack(2, ((PyObject*)__pyx_kp_s__4), ((PyObject*)__pyx_kp_s__4)); if (unlikely(!__pyx_tuple__151)) __PYX_ERR(0, 665, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__151);
  __Pyx_GIVEREF(__pyx_tuple__151);

  /* "cupy/core/elementwise.pxi":683
 *         self._routine_cache = {}
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<ufunc '%s'>" % self.name
 * 
 */
  __pyx_tuple__152 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__152)) __PYX_ERR(0, 683, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__152);
  __Pyx_GIVEREF(__pyx_tuple__152);
  __pyx_codeobj__153 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__152, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne, __pyx_n_s_repr, 683, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__153)) __PYX_ERR(0, 683, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":687
 * 
 *     @property
 *     def types(self):             # <<<<<<<<<<<<<<
 *         """A list of type signatures.
 * 
 */
  __pyx_tuple__155 = PyTuple_Pack(8, __pyx_n_s_self, __pyx_n_s_types, __pyx_n_s_in_types, __pyx_n_s_out_types, __pyx_n_s__154, __pyx_n_s_in_str, __pyx_n_s_out_str, __pyx_n_s_t); if (unlikely(!__pyx_tuple__155)) __PYX_ERR(0, 687, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__155);
  __Pyx_GIVEREF(__pyx_tuple__155);
  __pyx_codeobj__156 = (PyObject*)__Pyx_PyCode_New(1, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__155, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne, __pyx_n_s_types, 687, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__156)) __PYX_ERR(0, 687, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":701
 *         return types
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Applies the universal function to arguments elementwise.
 * 
 */
  __pyx_tuple__157 = 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__157)) __PYX_ERR(0, 701, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__157);
  __Pyx_GIVEREF(__pyx_tuple__157);
  __pyx_codeobj__158 = (PyObject*)__Pyx_PyCode_New(1, 0, 22, 0, CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__157, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne, __pyx_n_s_call, 701, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__158)) __PYX_ERR(0, 701, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":169
 * 
 * @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__159 = 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__159)) __PYX_ERR(3, 169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__159);
  __Pyx_GIVEREF(__pyx_tuple__159);
  __pyx_codeobj__160 = (PyObject*)__Pyx_PyCode_New(13, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__159, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne_2, __pyx_n_s_get_simple_reduction_function, 169, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__160)) __PYX_ERR(3, 169, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":191
 *     _block_size = 512
 * 
 *     def __init__(self, name, ops, identity, preamble):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self._ops = ops
 */
  __pyx_tuple__161 = 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__161)) __PYX_ERR(3, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__161);
  __Pyx_GIVEREF(__pyx_tuple__161);
  __pyx_codeobj__162 = (PyObject*)__Pyx_PyCode_New(5, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__161, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne_2, __pyx_n_s_init, 191, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__162)) __PYX_ERR(3, 191, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":209
 *         self._routine_cache = {}
 * 
 *     def __call__(self, a, axis=None, dtype=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         if not isinstance(a, ndarray):
 *             raise TypeError('Input type must be cupy.ndarray')
 */
  __pyx_tuple__163 = PyTuple_Pack(23, __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_types, __pyx_n_s_out_types, __pyx_n_s_routine, __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); if (unlikely(!__pyx_tuple__163)) __PYX_ERR(3, 209, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__163);
  __Pyx_GIVEREF(__pyx_tuple__163);
  __pyx_codeobj__164 = (PyObject*)__Pyx_PyCode_New(6, 0, 23, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__163, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne_2, __pyx_n_s_call, 209, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__164)) __PYX_ERR(3, 209, __pyx_L1_error)
  __pyx_tuple__165 = PyTuple_Pack(4, ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__165)) __PYX_ERR(3, 209, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__165);
  __Pyx_GIVEREF(__pyx_tuple__165);

  /* "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__166 = 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__166)) __PYX_ERR(3, 273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__166);
  __Pyx_GIVEREF(__pyx_tuple__166);
  __pyx_codeobj__167 = (PyObject*)__Pyx_PyCode_New(12, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__166, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne_2, __pyx_n_s_get_reduction_kernel, 273, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__167)) __PYX_ERR(3, 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__168 = 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__168)) __PYX_ERR(3, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__168);
  __Pyx_GIVEREF(__pyx_tuple__168);
  __pyx_codeobj__169 = (PyObject*)__Pyx_PyCode_New(12, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__168, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne_2, __pyx_n_s_init, 327, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__169)) __PYX_ERR(3, 327, __pyx_L1_error)
  __pyx_tuple__170 = PyTuple_Pack(5, ((PyObject*)__pyx_n_s_reduce_kernel), ((PyObject *)Py_None), ((PyObject *)Py_True), ((PyObject*)__pyx_kp_s__4), ((PyObject*)__pyx_empty_tuple)); if (unlikely(!__pyx_tuple__170)) __PYX_ERR(3, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__170);
  __Pyx_GIVEREF(__pyx_tuple__170);

  /* "cupy/core/reduction.pxi":353
 *         self.preamble = preamble
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Compiles and invokes the reduction kernel.
 * 
 */
  __pyx_tuple__171 = PyTuple_Pack(30, __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_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__171)) __PYX_ERR(3, 353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__171);
  __Pyx_GIVEREF(__pyx_tuple__171);
  __pyx_codeobj__172 = (PyObject*)__Pyx_PyCode_New(1, 0, 30, 0, CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__171, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne_2, __pyx_n_s_call, 353, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__172)) __PYX_ERR(3, 353, __pyx_L1_error)

  /* "cupy/core/core.pyx":1412
 * _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'),
 *     _id)
 */
  __pyx_tuple__174 = PyTuple_Pack(14, __pyx_kp_s__173, __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__174)) __PYX_ERR(1, 1412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__174);
  __Pyx_GIVEREF(__pyx_tuple__174);

  /* "cupy/core/core.pyx":1417
 * 
 * 
 * def elementwise_copy(*args, **kwargs):             # <<<<<<<<<<<<<<
 *     kwargs['casting'] = 'unsafe'
 *     return _elementwise_copy(*args, **kwargs)
 */
  __pyx_tuple__175 = PyTuple_Pack(2, __pyx_n_s_args, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__175)) __PYX_ERR(1, 1417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__175);
  __Pyx_GIVEREF(__pyx_tuple__175);
  __pyx_codeobj__176 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 0, CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__175, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne_3, __pyx_n_s_elementwise_copy, 1417, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__176)) __PYX_ERR(1, 1417, __pyx_L1_error)

  /* "cupy/core/core.pyx":1424
 * _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'),
 *     'if (in1) out0 = in0')
 */
  __pyx_tuple__177 = PyTuple_Pack(14, __pyx_kp_s__83, __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); if (unlikely(!__pyx_tuple__177)) __PYX_ERR(1, 1424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__177);
  __Pyx_GIVEREF(__pyx_tuple__177);

  /* "cupy/core/core.pyx":1429
 * 
 * 
 * def elementwise_copy_where(*args, **kwargs):             # <<<<<<<<<<<<<<
 *     kwargs['casting'] = 'unsafe'
 *     return _elementwise_copy_where(*args, **kwargs)
 */
  __pyx_tuple__178 = PyTuple_Pack(2, __pyx_n_s_args, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__178)) __PYX_ERR(1, 1429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__178);
  __Pyx_GIVEREF(__pyx_tuple__178);
  __pyx_codeobj__179 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 0, CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__178, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne_3, __pyx_n_s_elementwise_copy_where_2, 1429, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__179)) __PYX_ERR(1, 1429, __pyx_L1_error)

  /* "cupy/core/core.pyx":1555
 *     ('?->?', '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__180 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_min_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__180)) __PYX_ERR(1, 1555, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__180);
  __Pyx_GIVEREF(__pyx_tuple__180);
  __pyx_tuple__181 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__180); if (unlikely(!__pyx_tuple__181)) __PYX_ERR(1, 1555, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__181);
  __Pyx_GIVEREF(__pyx_tuple__181);

  /* "cupy/core/core.pyx":1556
 *      '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__182 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_min_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__182)) __PYX_ERR(1, 1556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__182);
  __Pyx_GIVEREF(__pyx_tuple__182);
  __pyx_tuple__183 = PyTuple_Pack(2, __pyx_kp_s_f_f, __pyx_tuple__182); if (unlikely(!__pyx_tuple__183)) __PYX_ERR(1, 1556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__183);
  __Pyx_GIVEREF(__pyx_tuple__183);

  /* "cupy/core/core.pyx":1557
 *      ('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__184 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_min_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__184)) __PYX_ERR(1, 1557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__184);
  __Pyx_GIVEREF(__pyx_tuple__184);
  __pyx_tuple__185 = PyTuple_Pack(2, __pyx_kp_s_d_d, __pyx_tuple__184); if (unlikely(!__pyx_tuple__185)) __PYX_ERR(1, 1557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__185);
  __Pyx_GIVEREF(__pyx_tuple__185);

  /* "cupy/core/core.pyx":1553
 * cdef _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__186 = PyTuple_Pack(14, __pyx_kp_s__173, __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__181, __pyx_tuple__183, __pyx_tuple__185); if (unlikely(!__pyx_tuple__186)) __PYX_ERR(1, 1553, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__186);
  __Pyx_GIVEREF(__pyx_tuple__186);

  /* "cupy/core/core.pyx":1558
 *      ('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__187 = 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__187)) __PYX_ERR(1, 1558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__187);
  __Pyx_GIVEREF(__pyx_tuple__187);

  /* "cupy/core/core.pyx":1567
 *     ('?->?', '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__188 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_max_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__188)) __PYX_ERR(1, 1567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__188);
  __Pyx_GIVEREF(__pyx_tuple__188);
  __pyx_tuple__189 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__188); if (unlikely(!__pyx_tuple__189)) __PYX_ERR(1, 1567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__189);
  __Pyx_GIVEREF(__pyx_tuple__189);

  /* "cupy/core/core.pyx":1568
 *      '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__190 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_max_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__190)) __PYX_ERR(1, 1568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__190);
  __Pyx_GIVEREF(__pyx_tuple__190);
  __pyx_tuple__191 = PyTuple_Pack(2, __pyx_kp_s_f_f, __pyx_tuple__190); if (unlikely(!__pyx_tuple__191)) __PYX_ERR(1, 1568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__191);
  __Pyx_GIVEREF(__pyx_tuple__191);

  /* "cupy/core/core.pyx":1569
 *      ('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__192 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_max_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__192)) __PYX_ERR(1, 1569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__192);
  __Pyx_GIVEREF(__pyx_tuple__192);
  __pyx_tuple__193 = PyTuple_Pack(2, __pyx_kp_s_d_d, __pyx_tuple__192); if (unlikely(!__pyx_tuple__193)) __PYX_ERR(1, 1569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__193);
  __Pyx_GIVEREF(__pyx_tuple__193);

  /* "cupy/core/core.pyx":1565
 * cdef _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__194 = PyTuple_Pack(14, __pyx_kp_s__173, __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__189, __pyx_tuple__191, __pyx_tuple__193); if (unlikely(!__pyx_tuple__194)) __PYX_ERR(1, 1565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__194);
  __Pyx_GIVEREF(__pyx_tuple__194);

  /* "cupy/core/core.pyx":1570
 *      ('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__195 = 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__195)) __PYX_ERR(1, 1570, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__195);
  __Pyx_GIVEREF(__pyx_tuple__195);

  /* "cupy/core/core.pyx":1577
 * 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__196 = PyTuple_Pack(14, __pyx_kp_s__173, __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__196)) __PYX_ERR(1, 1577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__196);
  __Pyx_GIVEREF(__pyx_tuple__196);

  /* "cupy/core/core.pyx":1579
 *     ('?->?', '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__197 = 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__197)) __PYX_ERR(1, 1579, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__197);
  __Pyx_GIVEREF(__pyx_tuple__197);

  /* "cupy/core/core.pyx":1586
 * 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__198 = PyTuple_Pack(14, __pyx_kp_s__173, __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__198)) __PYX_ERR(1, 1586, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__198);
  __Pyx_GIVEREF(__pyx_tuple__198);

  /* "cupy/core/core.pyx":1588
 *     ('?->?', '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__199 = 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__199)) __PYX_ERR(1, 1588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__199);
  __Pyx_GIVEREF(__pyx_tuple__199);

  /* "cupy/core/core.pyx":1597
 *     ('?->l', 'B->l', 'h->l', 'H->l', 'i->l', 'I->l', 'l->l', 'L->l',
 *      'q->l', 'Q->l',
 *      ('e->l', (None, 'my_argmin_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('f->l', (None, 'my_argmin_float(a, b)', None, None)),
 *      ('d->l', (None, 'my_argmin_float(a, b)', None, None))),
 */
  __pyx_tuple__200 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmin_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__200)) __PYX_ERR(1, 1597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__200);
  __Pyx_GIVEREF(__pyx_tuple__200);
  __pyx_tuple__201 = PyTuple_Pack(2, __pyx_kp_s_e_l, __pyx_tuple__200); if (unlikely(!__pyx_tuple__201)) __PYX_ERR(1, 1597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__201);
  __Pyx_GIVEREF(__pyx_tuple__201);

  /* "cupy/core/core.pyx":1598
 *      'q->l', 'Q->l',
 *      ('e->l', (None, 'my_argmin_float(a, b)', None, None)),
 *      ('f->l', (None, 'my_argmin_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('d->l', (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__202 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmin_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__202)) __PYX_ERR(1, 1598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__202);
  __Pyx_GIVEREF(__pyx_tuple__202);
  __pyx_tuple__203 = PyTuple_Pack(2, __pyx_kp_s_f_l, __pyx_tuple__202); if (unlikely(!__pyx_tuple__203)) __PYX_ERR(1, 1598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__203);
  __Pyx_GIVEREF(__pyx_tuple__203);

  /* "cupy/core/core.pyx":1599
 *      ('e->l', (None, 'my_argmin_float(a, b)', None, None)),
 *      ('f->l', (None, 'my_argmin_float(a, b)', None, None)),
 *      ('d->l', (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__204 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmin_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__204)) __PYX_ERR(1, 1599, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__204);
  __Pyx_GIVEREF(__pyx_tuple__204);
  __pyx_tuple__205 = PyTuple_Pack(2, __pyx_kp_s_d_l, __pyx_tuple__204); if (unlikely(!__pyx_tuple__205)) __PYX_ERR(1, 1599, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__205);
  __Pyx_GIVEREF(__pyx_tuple__205);

  /* "cupy/core/core.pyx":1595
 * cdef _argmin = create_reduction_func(
 *     'cupy_argmin',
 *     ('?->l', 'B->l', 'h->l', 'H->l', 'i->l', 'I->l', 'l->l', 'L->l',             # <<<<<<<<<<<<<<
 *      'q->l', 'Q->l',
 *      ('e->l', (None, 'my_argmin_float(a, b)', None, None)),
 */
  __pyx_tuple__206 = PyTuple_Pack(13, __pyx_kp_s_l, __pyx_kp_s_B_l, __pyx_kp_s_h_l, __pyx_kp_s_H_l, __pyx_kp_s_i_l, __pyx_kp_s_I_l, __pyx_kp_s_l_l, __pyx_kp_s_L_l, __pyx_kp_s_q_l, __pyx_kp_s_Q_l, __pyx_tuple__201, __pyx_tuple__203, __pyx_tuple__205); if (unlikely(!__pyx_tuple__206)) __PYX_ERR(1, 1595, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__206);
  __Pyx_GIVEREF(__pyx_tuple__206);

  /* "cupy/core/core.pyx":1600
 *      ('f->l', (None, 'my_argmin_float(a, b)', None, None)),
 *      ('d->l', (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__207 = 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__207)) __PYX_ERR(1, 1600, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__207);
  __Pyx_GIVEREF(__pyx_tuple__207);

  /* "cupy/core/core.pyx":1609
 *     ('?->l', 'B->l', 'h->l', 'H->l', 'i->l', 'I->l', 'l->l', 'L->l',
 *      'q->l', 'Q->l',
 *      ('e->l', (None, 'my_argmax_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('f->l', (None, 'my_argmax_float(a, b)', None, None)),
 *      ('d->l', (None, 'my_argmax_float(a, b)', None, None))),
 */
  __pyx_tuple__208 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmax_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__208)) __PYX_ERR(1, 1609, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__208);
  __Pyx_GIVEREF(__pyx_tuple__208);
  __pyx_tuple__209 = PyTuple_Pack(2, __pyx_kp_s_e_l, __pyx_tuple__208); if (unlikely(!__pyx_tuple__209)) __PYX_ERR(1, 1609, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__209);
  __Pyx_GIVEREF(__pyx_tuple__209);

  /* "cupy/core/core.pyx":1610
 *      'q->l', 'Q->l',
 *      ('e->l', (None, 'my_argmax_float(a, b)', None, None)),
 *      ('f->l', (None, 'my_argmax_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('d->l', (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__210 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmax_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__210)) __PYX_ERR(1, 1610, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__210);
  __Pyx_GIVEREF(__pyx_tuple__210);
  __pyx_tuple__211 = PyTuple_Pack(2, __pyx_kp_s_f_l, __pyx_tuple__210); if (unlikely(!__pyx_tuple__211)) __PYX_ERR(1, 1610, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__211);
  __Pyx_GIVEREF(__pyx_tuple__211);

  /* "cupy/core/core.pyx":1611
 *      ('e->l', (None, 'my_argmax_float(a, b)', None, None)),
 *      ('f->l', (None, 'my_argmax_float(a, b)', None, None)),
 *      ('d->l', (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__212 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmax_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__212)) __PYX_ERR(1, 1611, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__212);
  __Pyx_GIVEREF(__pyx_tuple__212);
  __pyx_tuple__213 = PyTuple_Pack(2, __pyx_kp_s_d_l, __pyx_tuple__212); if (unlikely(!__pyx_tuple__213)) __PYX_ERR(1, 1611, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__213);
  __Pyx_GIVEREF(__pyx_tuple__213);

  /* "cupy/core/core.pyx":1607
 * cdef _argmax = create_reduction_func(
 *     'cupy_argmax',
 *     ('?->l', 'B->l', 'h->l', 'H->l', 'i->l', 'I->l', 'l->l', 'L->l',             # <<<<<<<<<<<<<<
 *      'q->l', 'Q->l',
 *      ('e->l', (None, 'my_argmax_float(a, b)', None, None)),
 */
  __pyx_tuple__214 = PyTuple_Pack(13, __pyx_kp_s_l, __pyx_kp_s_B_l, __pyx_kp_s_h_l, __pyx_kp_s_H_l, __pyx_kp_s_i_l, __pyx_kp_s_I_l, __pyx_kp_s_l_l, __pyx_kp_s_L_l, __pyx_kp_s_q_l, __pyx_kp_s_Q_l, __pyx_tuple__209, __pyx_tuple__211, __pyx_tuple__213); if (unlikely(!__pyx_tuple__214)) __PYX_ERR(1, 1607, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__214);
  __Pyx_GIVEREF(__pyx_tuple__214);

  /* "cupy/core/core.pyx":1612
 *      ('f->l', (None, 'my_argmax_float(a, b)', None, None)),
 *      ('d->l', (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__215 = 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__215)) __PYX_ERR(1, 1612, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__215);
  __Pyx_GIVEREF(__pyx_tuple__215);

  /* "cupy/core/core.pyx":1924
 * 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__219 = PyTuple_Pack(2, __pyx_kp_s__173, __pyx_kp_s_out0_in0_2); if (unlikely(!__pyx_tuple__219)) __PYX_ERR(1, 1924, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__219);
  __Pyx_GIVEREF(__pyx_tuple__219);
  __pyx_tuple__220 = PyTuple_Pack(11, __pyx_tuple__219, __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__220)) __PYX_ERR(1, 1924, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__220);
  __Pyx_GIVEREF(__pyx_tuple__220);

  /* "cupy/core/core.pyx":1922
 * 
 * 
 * invert = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_invert',
 *     (('?->?', 'out0 = !in0'), 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I',
 */
  __pyx_tuple__221 = PyTuple_Pack(3, __pyx_n_s_cupy_invert, __pyx_tuple__220, __pyx_kp_s_out0_in0_3); if (unlikely(!__pyx_tuple__221)) __PYX_ERR(1, 1922, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__221);
  __Pyx_GIVEREF(__pyx_tuple__221);

  /* "cupy/core/core.pyx":1961
 * # -----------------------------------------------------------------------------
 * 
 * cdef _take_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T a, S indices, int32 cdim, int32 rdim, int32 adim, S index_range',
 *     'T out',
 */
  __pyx_tuple__224 = 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__224)) __PYX_ERR(1, 1961, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__224);
  __Pyx_GIVEREF(__pyx_tuple__224);

  /* "cupy/core/core.pyx":1975
 * 
 * 
 * cdef _take_kernel_0axis = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T a, S indices, int32 rdim, S index_range',
 *     'T out',
 */
  __pyx_tuple__225 = 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__225)) __PYX_ERR(1, 1975, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__225);
  __Pyx_GIVEREF(__pyx_tuple__225);

  /* "cupy/core/core.pyx":1987
 * 
 * 
 * cdef _boolean_array_indexing_nth = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'T a, bool boolean_array, S nth',
 *     'raw T out',
 */
  __pyx_tuple__226 = PyTuple_Pack(4, __pyx_kp_s_T_a_bool_boolean_array_S_nth, __pyx_kp_s_raw_T_out, __pyx_kp_s_if_boolean_array_out_nth_a, __pyx_n_s_cupy_boolean_array_indexing_nth); if (unlikely(!__pyx_tuple__226)) __PYX_ERR(1, 1987, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__226);
  __Pyx_GIVEREF(__pyx_tuple__226);

  /* "cupy/core/core.pyx":2627
 * cdef _all = create_reduction_func(
 *     'cupy_all',
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',             # <<<<<<<<<<<<<<
 *      'q->?', 'Q->?', 'e->?', 'f->?', 'd->?'),
 *     ('in0', 'a & b', 'out0 = a', 'bool'),
 */
  __pyx_tuple__233 = PyTuple_Pack(13, __pyx_kp_s__173, __pyx_kp_s_B, __pyx_kp_s_h, __pyx_kp_s_H, __pyx_kp_s_i_2, __pyx_kp_s_I, __pyx_kp_s_l_2, __pyx_kp_s_L, __pyx_kp_s_q, __pyx_kp_s_Q, __pyx_kp_s_e_2, __pyx_kp_s_f_2, __pyx_kp_s_d_2); if (unlikely(!__pyx_tuple__233)) __PYX_ERR(1, 2627, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__233);
  __Pyx_GIVEREF(__pyx_tuple__233);

  /* "cupy/core/core.pyx":2629
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',
 *      'q->?', 'Q->?', 'e->?', 'f->?', 'd->?'),
 *     ('in0', 'a & b', 'out0 = a', 'bool'),             # <<<<<<<<<<<<<<
 *     'true', '')
 * 
 */
  __pyx_tuple__234 = PyTuple_Pack(4, __pyx_n_s_in0, __pyx_kp_s_a_b, __pyx_kp_s_out0_a, __pyx_n_s_bool_2); if (unlikely(!__pyx_tuple__234)) __PYX_ERR(1, 2629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__234);
  __Pyx_GIVEREF(__pyx_tuple__234);

  /* "cupy/core/core.pyx":2635
 * cdef _any = create_reduction_func(
 *     'cupy_any',
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',             # <<<<<<<<<<<<<<
 *      'q->?', 'Q->?', 'e->?', 'f->?', 'd->?'),
 *     ('in0', 'a | b', 'out0 = a', 'bool'),
 */
  __pyx_tuple__235 = PyTuple_Pack(13, __pyx_kp_s__173, __pyx_kp_s_B, __pyx_kp_s_h, __pyx_kp_s_H, __pyx_kp_s_i_2, __pyx_kp_s_I, __pyx_kp_s_l_2, __pyx_kp_s_L, __pyx_kp_s_q, __pyx_kp_s_Q, __pyx_kp_s_e_2, __pyx_kp_s_f_2, __pyx_kp_s_d_2); if (unlikely(!__pyx_tuple__235)) __PYX_ERR(1, 2635, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__235);
  __Pyx_GIVEREF(__pyx_tuple__235);

  /* "cupy/core/core.pyx":2637
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',
 *      'q->?', 'Q->?', 'e->?', 'f->?', 'd->?'),
 *     ('in0', 'a | b', 'out0 = a', 'bool'),             # <<<<<<<<<<<<<<
 *     'false', '')
 * 
 */
  __pyx_tuple__236 = PyTuple_Pack(4, __pyx_n_s_in0, __pyx_kp_s_a_b_2, __pyx_kp_s_out0_a, __pyx_n_s_bool_2); if (unlikely(!__pyx_tuple__236)) __PYX_ERR(1, 2637, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__236);
  __Pyx_GIVEREF(__pyx_tuple__236);

  /* "cupy/core/core.pyx":2649
 *     ('?->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'),
 *     ('in0', 'a + b', 'out0 = a', None), 0)
 */
  __pyx_tuple__237 = PyTuple_Pack(4, Py_None, Py_None, Py_None, __pyx_n_s_float); if (unlikely(!__pyx_tuple__237)) __PYX_ERR(1, 2649, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__237);
  __Pyx_GIVEREF(__pyx_tuple__237);
  __pyx_tuple__238 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__237); if (unlikely(!__pyx_tuple__238)) __PYX_ERR(1, 2649, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__238);
  __Pyx_GIVEREF(__pyx_tuple__238);

  /* "cupy/core/core.pyx":2647
 * cdef _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__239 = PyTuple_Pack(13, __pyx_kp_s_l, __pyx_kp_s_B_L, __pyx_kp_s_h_l, __pyx_kp_s_H_L, __pyx_kp_s_i_l, __pyx_kp_s_I_L, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_tuple__238, __pyx_kp_s_f_f, __pyx_kp_s_d_d); if (unlikely(!__pyx_tuple__239)) __PYX_ERR(1, 2647, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__239);
  __Pyx_GIVEREF(__pyx_tuple__239);

  /* "cupy/core/core.pyx":2651
 *      ('e->e', (None, None, None, 'float')),
 *      'f->f', 'd->d'),
 *     ('in0', 'a + b', 'out0 = a', None), 0)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__240 = PyTuple_Pack(4, __pyx_n_s_in0, __pyx_kp_s_a_b_3, __pyx_kp_s_out0_a, Py_None); if (unlikely(!__pyx_tuple__240)) __PYX_ERR(1, 2651, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__240);
  __Pyx_GIVEREF(__pyx_tuple__240);

  /* "cupy/core/core.pyx":2658
 *     ['?->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'],
 *     ('in0', 'a * b', 'out0 = a', None), 1)
 */
  __pyx_tuple__241 = PyTuple_Pack(4, Py_None, Py_None, Py_None, __pyx_n_s_float); if (unlikely(!__pyx_tuple__241)) __PYX_ERR(1, 2658, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__241);
  __Pyx_GIVEREF(__pyx_tuple__241);
  __pyx_tuple__242 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__241); if (unlikely(!__pyx_tuple__242)) __PYX_ERR(1, 2658, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__242);
  __Pyx_GIVEREF(__pyx_tuple__242);

  /* "cupy/core/core.pyx":2660
 *      ('e->e', (None, None, None, 'float')),
 *      'f->f', 'd->d'],
 *     ('in0', 'a * b', 'out0 = a', None), 1)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__243 = PyTuple_Pack(4, __pyx_n_s_in0, __pyx_kp_s_a_b_4, __pyx_kp_s_out0_a, Py_None); if (unlikely(!__pyx_tuple__243)) __PYX_ERR(1, 2660, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__243);
  __Pyx_GIVEREF(__pyx_tuple__243);

  /* "cupy/core/core.pyx":2684
 * 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'),
 */
  __pyx_tuple__245 = PyTuple_Pack(2, __pyx_kp_s__173, __pyx_kp_s_out0_in0_2); if (unlikely(!__pyx_tuple__245)) __PYX_ERR(1, 2684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__245);
  __Pyx_GIVEREF(__pyx_tuple__245);
  __pyx_tuple__246 = PyTuple_Pack(14, __pyx_tuple__245, __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__246)) __PYX_ERR(1, 2684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__246);
  __Pyx_GIVEREF(__pyx_tuple__246);

  /* "cupy/core/core.pyx":2682
 * 
 * 
 * negative = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_negative',
 *     (('?->?', 'out0 = !in0'),
 */
  __pyx_tuple__247 = PyTuple_Pack(3, __pyx_n_s_cupy_negative, __pyx_tuple__246, __pyx_kp_s_out0_in0_4); if (unlikely(!__pyx_tuple__247)) __PYX_ERR(1, 2682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__247);
  __Pyx_GIVEREF(__pyx_tuple__247);

  /* "cupy/core/core.pyx":2708
 *     ('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__249 = PyTuple_Pack(2, __pyx_kp_s_ee_e, __pyx_kp_s_out0_in0_in1); if (unlikely(!__pyx_tuple__249)) __PYX_ERR(1, 2708, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__249);
  __Pyx_GIVEREF(__pyx_tuple__249);

  /* "cupy/core/core.pyx":2709
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = in0 / in1'),
 *      ('ff->f', 'out0 = in0 / in1'),             # <<<<<<<<<<<<<<
 *      ('dd->d', 'out0 = in0 / in1')),
 *     'out0 = in1 == 0 ? 0 : floor((double)in0 / (double)in1)',
 */
  __pyx_tuple__250 = PyTuple_Pack(2, __pyx_kp_s_ff_f, __pyx_kp_s_out0_in0_in1); if (unlikely(!__pyx_tuple__250)) __PYX_ERR(1, 2709, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__250);
  __Pyx_GIVEREF(__pyx_tuple__250);

  /* "cupy/core/core.pyx":2710
 *      ('ee->e', '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__251 = PyTuple_Pack(2, __pyx_kp_s_dd_d, __pyx_kp_s_out0_in0_in1); if (unlikely(!__pyx_tuple__251)) __PYX_ERR(1, 2710, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__251);
  __Pyx_GIVEREF(__pyx_tuple__251);

  /* "cupy/core/core.pyx":2706
 * 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__252 = 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__249, __pyx_tuple__250, __pyx_tuple__251); if (unlikely(!__pyx_tuple__252)) __PYX_ERR(1, 2706, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__252);
  __Pyx_GIVEREF(__pyx_tuple__252);

  /* "cupy/core/core.pyx":2704
 * 
 * 
 * divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_tuple__253 = PyTuple_Pack(3, __pyx_n_s_cupy_divide, __pyx_tuple__252, __pyx_kp_s_out0_in1_0_0_floor_double_in0_do); if (unlikely(!__pyx_tuple__253)) __PYX_ERR(1, 2704, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__253);
  __Pyx_GIVEREF(__pyx_tuple__253);

  /* "cupy/core/core.pyx":2723
 *     ('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__254 = PyTuple_Pack(2, __pyx_kp_s_ee_e, __pyx_kp_s_out0_powf_in0_in1); if (unlikely(!__pyx_tuple__254)) __PYX_ERR(1, 2723, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__254);
  __Pyx_GIVEREF(__pyx_tuple__254);

  /* "cupy/core/core.pyx":2724
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = powf(in0, in1)'),
 *      ('ff->f', 'out0 = powf(in0, in1)'),             # <<<<<<<<<<<<<<
 *      ('dd->d', 'out0 = pow(in0, in1)')),
 *     'out0 = rint(pow((double)in0, (double)in1))',
 */
  __pyx_tuple__255 = PyTuple_Pack(2, __pyx_kp_s_ff_f, __pyx_kp_s_out0_powf_in0_in1); if (unlikely(!__pyx_tuple__255)) __PYX_ERR(1, 2724, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__255);
  __Pyx_GIVEREF(__pyx_tuple__255);

  /* "cupy/core/core.pyx":2725
 *      ('ee->e', 'out0 = powf(in0, in1)'),
 *      ('ff->f', 'out0 = powf(in0, in1)'),
 *      ('dd->d', 'out0 = pow(in0, in1)')),             # <<<<<<<<<<<<<<
 *     'out0 = rint(pow((double)in0, (double)in1))',
 *     doc='''Computes ``x1 ** x2`` elementwise.
 */
  __pyx_tuple__256 = PyTuple_Pack(2, __pyx_kp_s_dd_d, __pyx_kp_s_out0_pow_in0_in1); if (unlikely(!__pyx_tuple__256)) __PYX_ERR(1, 2725, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__256);
  __Pyx_GIVEREF(__pyx_tuple__256);

  /* "cupy/core/core.pyx":2721
 * 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__257 = 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__254, __pyx_tuple__255, __pyx_tuple__256); if (unlikely(!__pyx_tuple__257)) __PYX_ERR(1, 2721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__257);
  __Pyx_GIVEREF(__pyx_tuple__257);

  /* "cupy/core/core.pyx":2719
 * 
 * 
 * power = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_power',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_tuple__258 = PyTuple_Pack(3, __pyx_n_s_cupy_power, __pyx_tuple__257, __pyx_kp_s_out0_rint_pow_double_in0_double); if (unlikely(!__pyx_tuple__258)) __PYX_ERR(1, 2719, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__258);
  __Pyx_GIVEREF(__pyx_tuple__258);

  /* "cupy/core/core.pyx":2745
 * 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'),
 *     'out0 = (out0_type)in0 / (out0_type)in1',
 */
  __pyx_tuple__260 = PyTuple_Pack(13, __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); if (unlikely(!__pyx_tuple__260)) __PYX_ERR(1, 2745, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__260);
  __Pyx_GIVEREF(__pyx_tuple__260);

  /* "cupy/core/core.pyx":2743
 * 
 * 
 * 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__261 = PyTuple_Pack(3, __pyx_n_s_cupy_true_divide, __pyx_tuple__260, __pyx_kp_s_out0_out0_type_in0_out0_type_in1); if (unlikely(!__pyx_tuple__261)) __PYX_ERR(1, 2743, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__261);
  __Pyx_GIVEREF(__pyx_tuple__261);

  /* "cupy/core/core.pyx":2761
 * 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__262 = 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__262)) __PYX_ERR(1, 2761, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__262);
  __Pyx_GIVEREF(__pyx_tuple__262);

  /* "cupy/core/core.pyx":2759
 * 
 * 
 * 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__263 = PyTuple_Pack(3, __pyx_n_s_cupy_floor_divide, __pyx_tuple__262, __pyx_kp_s_out0__floor_divide_in0_in1); if (unlikely(!__pyx_tuple__263)) __PYX_ERR(1, 2759, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__263);
  __Pyx_GIVEREF(__pyx_tuple__263);

  /* "cupy/core/core.pyx":2775
 *     ('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__264 = PyTuple_Pack(2, __pyx_kp_s_ee_e, __pyx_kp_s_out0_in0__floor_divide_in0_in1_i); if (unlikely(!__pyx_tuple__264)) __PYX_ERR(1, 2775, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__264);
  __Pyx_GIVEREF(__pyx_tuple__264);

  /* "cupy/core/core.pyx":2776
 *      '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__265 = PyTuple_Pack(2, __pyx_kp_s_ff_f, __pyx_kp_s_out0_in0__floor_divide_in0_in1_i); if (unlikely(!__pyx_tuple__265)) __PYX_ERR(1, 2776, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__265);
  __Pyx_GIVEREF(__pyx_tuple__265);

  /* "cupy/core/core.pyx":2777
 *      ('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__266 = PyTuple_Pack(2, __pyx_kp_s_dd_d, __pyx_kp_s_out0_in0__floor_divide_in0_in1_i); if (unlikely(!__pyx_tuple__266)) __PYX_ERR(1, 2777, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__266);
  __Pyx_GIVEREF(__pyx_tuple__266);

  /* "cupy/core/core.pyx":2773
 * 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__267 = 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__264, __pyx_tuple__265, __pyx_tuple__266); if (unlikely(!__pyx_tuple__267)) __PYX_ERR(1, 2773, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__267);
  __Pyx_GIVEREF(__pyx_tuple__267);

  /* "cupy/core/core.pyx":2771
 * 
 * 
 * remainder = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_remainder',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_tuple__268 = PyTuple_Pack(3, __pyx_n_s_cupy_remainder, __pyx_tuple__267, __pyx_kp_s_out0_in0__floor_divide_in0_in1_i_2); if (unlikely(!__pyx_tuple__268)) __PYX_ERR(1, 2771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__268);
  __Pyx_GIVEREF(__pyx_tuple__268);

  /* "cupy/core/core.pyx":2788
 * 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__269 = PyTuple_Pack(2, __pyx_kp_s__173, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__269)) __PYX_ERR(1, 2788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__269);
  __Pyx_GIVEREF(__pyx_tuple__269);

  /* "cupy/core/core.pyx":2789
 *     '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__270 = PyTuple_Pack(2, __pyx_kp_s_B_B, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__270)) __PYX_ERR(1, 2789, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__270);
  __Pyx_GIVEREF(__pyx_tuple__270);
  __pyx_tuple__271 = PyTuple_Pack(2, __pyx_kp_s_H_H, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__271)) __PYX_ERR(1, 2789, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__271);
  __Pyx_GIVEREF(__pyx_tuple__271);

  /* "cupy/core/core.pyx":2790
 *     (('?->?', '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__272 = PyTuple_Pack(2, __pyx_kp_s_I_I, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__272)) __PYX_ERR(1, 2790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__272);
  __Pyx_GIVEREF(__pyx_tuple__272);
  __pyx_tuple__273 = PyTuple_Pack(2, __pyx_kp_s_L_L, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__273)) __PYX_ERR(1, 2790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__273);
  __Pyx_GIVEREF(__pyx_tuple__273);

  /* "cupy/core/core.pyx":2791
 *      '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__274 = PyTuple_Pack(2, __pyx_kp_s_Q_Q, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__274)) __PYX_ERR(1, 2791, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__274);
  __Pyx_GIVEREF(__pyx_tuple__274);

  /* "cupy/core/core.pyx":2792
 *      '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__275 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_kp_s_out0_fabsf_in0); if (unlikely(!__pyx_tuple__275)) __PYX_ERR(1, 2792, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__275);
  __Pyx_GIVEREF(__pyx_tuple__275);

  /* "cupy/core/core.pyx":2793
 *      'q->q', ('Q->Q', 'out0 = in0'),
 *      ('e->e', 'out0 = fabsf(in0)'),
 *      ('f->f', 'out0 = fabsf(in0)'),             # <<<<<<<<<<<<<<
 *      ('d->d', 'out0 = fabs(in0)')),
 *     'out0 = in0 > 0 ? in0 : -in0',
 */
  __pyx_tuple__276 = PyTuple_Pack(2, __pyx_kp_s_f_f, __pyx_kp_s_out0_fabsf_in0); if (unlikely(!__pyx_tuple__276)) __PYX_ERR(1, 2793, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__276);
  __Pyx_GIVEREF(__pyx_tuple__276);

  /* "cupy/core/core.pyx":2794
 *      ('e->e', 'out0 = fabsf(in0)'),
 *      ('f->f', 'out0 = fabsf(in0)'),
 *      ('d->d', 'out0 = fabs(in0)')),             # <<<<<<<<<<<<<<
 *     'out0 = in0 > 0 ? in0 : -in0',
 *     doc='''Elementwise absolute value function.
 */
  __pyx_tuple__277 = PyTuple_Pack(2, __pyx_kp_s_d_d, __pyx_kp_s_out0_fabs_in0); if (unlikely(!__pyx_tuple__277)) __PYX_ERR(1, 2794, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__277);
  __Pyx_GIVEREF(__pyx_tuple__277);

  /* "cupy/core/core.pyx":2788
 * 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__278 = PyTuple_Pack(14, __pyx_tuple__269, __pyx_kp_s_b_b, __pyx_tuple__270, __pyx_kp_s_h_h, __pyx_tuple__271, __pyx_kp_s_i_i, __pyx_tuple__272, __pyx_kp_s_l_l, __pyx_tuple__273, __pyx_kp_s_q_q, __pyx_tuple__274, __pyx_tuple__275, __pyx_tuple__276, __pyx_tuple__277); if (unlikely(!__pyx_tuple__278)) __PYX_ERR(1, 2788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__278);
  __Pyx_GIVEREF(__pyx_tuple__278);

  /* "cupy/core/core.pyx":2786
 * 
 * 
 * absolute = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),
 */
  __pyx_tuple__279 = PyTuple_Pack(3, __pyx_n_s_cupy_absolute, __pyx_tuple__278, __pyx_kp_s_out0_in0_0_in0_in0); if (unlikely(!__pyx_tuple__279)) __PYX_ERR(1, 2786, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__279);
  __Pyx_GIVEREF(__pyx_tuple__279);

  /* "cupy/core/core.pyx":2805
 * sqrt = create_ufunc(
 *     'cupy_sqrt',
 *     ('e->e', 'f->f', 'd->d'),             # <<<<<<<<<<<<<<
 *     'out0 = sqrt(in0)')
 * 
 */
  __pyx_tuple__280 = PyTuple_Pack(3, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d); if (unlikely(!__pyx_tuple__280)) __PYX_ERR(1, 2805, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__280);
  __Pyx_GIVEREF(__pyx_tuple__280);

  /* "cupy/core/core.pyx":2811
 * cdef _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__282 = PyTuple_Pack(14, __pyx_kp_s__281, __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__282)) __PYX_ERR(1, 2811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__282);
  __Pyx_GIVEREF(__pyx_tuple__282);

  /* "cupy/core/core.pyx":2849
 * 
 * 
 * cdef _var_core = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T mean, T alpha', 'T out',
 *     '(x - mean) * (x - mean)',
 */
  __pyx_tuple__283 = 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_3, __pyx_kp_s_out_alpha_a, __pyx_kp_s_0, __pyx_n_s_var_core); if (unlikely(!__pyx_tuple__283)) __PYX_ERR(1, 2849, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__283);
  __Pyx_GIVEREF(__pyx_tuple__283);

  /* "cupy/core/core.pyx":2854
 *     '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__284 = 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_3, __pyx_kp_s_out_alpha_a, __pyx_kp_s_0, __pyx_n_s_var_core); if (unlikely(!__pyx_tuple__284)) __PYX_ERR(1, 2854, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__284);
  __Pyx_GIVEREF(__pyx_tuple__284);

  /* "cupy/core/core.pyx":2864
 *     ('?->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'),
 *     ('in0', 'a + b', 'out0 = a / (_in_ind.size() / _out_ind.size())', None))
 */
  __pyx_tuple__285 = PyTuple_Pack(4, Py_None, Py_None, Py_None, __pyx_n_s_float); if (unlikely(!__pyx_tuple__285)) __PYX_ERR(1, 2864, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__285);
  __Pyx_GIVEREF(__pyx_tuple__285);
  __pyx_tuple__286 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__285); if (unlikely(!__pyx_tuple__286)) __PYX_ERR(1, 2864, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__286);
  __Pyx_GIVEREF(__pyx_tuple__286);

  /* "cupy/core/core.pyx":2862
 * 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__287 = PyTuple_Pack(13, __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__286, __pyx_kp_s_f_f, __pyx_kp_s_d_d); if (unlikely(!__pyx_tuple__287)) __PYX_ERR(1, 2862, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__287);
  __Pyx_GIVEREF(__pyx_tuple__287);

  /* "cupy/core/core.pyx":2866
 *      ('e->e', (None, None, None, 'float')),
 *      'f->f', 'd->d'),
 *     ('in0', 'a + b', 'out0 = a / (_in_ind.size() / _out_ind.size())', None))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__288 = PyTuple_Pack(4, __pyx_n_s_in0, __pyx_kp_s_a_b_3, __pyx_kp_s_out0_a__in_ind_size__out_ind_siz, Py_None); if (unlikely(!__pyx_tuple__288)) __PYX_ERR(1, 2866, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__288);
  __Pyx_GIVEREF(__pyx_tuple__288);

  /* "cupy/core/core.pyx":2874
 * 
 * @util.memoize(for_each_device=True)
 * def _inclusive_scan_kernel(dtype, block_size):             # <<<<<<<<<<<<<<
 *     """return Prefix Sum(Scan) cuda kernel
 * 
 */
  __pyx_tuple__289 = 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__289)) __PYX_ERR(1, 2874, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__289);
  __Pyx_GIVEREF(__pyx_tuple__289);
  __pyx_codeobj__290 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__289, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne_3, __pyx_n_s_inclusive_scan_kernel_2, 2874, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__290)) __PYX_ERR(1, 2874, __pyx_L1_error)

  /* "cupy/core/core.pyx":2941
 * 
 * @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__291 = PyTuple_Pack(4, __pyx_n_s_dtype, __pyx_n_s_name, __pyx_n_s_source, __pyx_n_s_module_2); if (unlikely(!__pyx_tuple__291)) __PYX_ERR(1, 2941, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__291);
  __Pyx_GIVEREF(__pyx_tuple__291);
  __pyx_codeobj__292 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__291, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne_3, __pyx_n_s_add_scan_blocked_sum_kernel_2, 2941, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__292)) __PYX_ERR(1, 2941, __pyx_L1_error)

  /* "cupy/core/core.pyx":2961
 * 
 * @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__293 = 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__293)) __PYX_ERR(1, 2961, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__293);
  __Pyx_GIVEREF(__pyx_tuple__293);
  __pyx_codeobj__294 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__293, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne_3, __pyx_n_s_nonzero_1d_kernel, 2961, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__294)) __PYX_ERR(1, 2961, __pyx_L1_error)

  /* "cupy/core/core.pyx":2984
 * 
 * @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__295 = 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__295)) __PYX_ERR(1, 2984, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__295);
  __Pyx_GIVEREF(__pyx_tuple__295);
  __pyx_codeobj__296 = (PyObject*)__Pyx_PyCode_New(4, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__295, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne_3, __pyx_n_s_nonzero_kernel, 2984, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__296)) __PYX_ERR(1, 2984, __pyx_L1_error)

  /* "cupy/core/core.pyx":3018
 * 
 * 
 * def scan(a, out=None):             # <<<<<<<<<<<<<<
 *     """Return the prefix sum(scan) of the elements.
 * 
 */
  __pyx_tuple__297 = PyTuple_Pack(6, __pyx_n_s_a, __pyx_n_s_out, __pyx_n_s_block_size, __pyx_n_s_kern_scan, __pyx_n_s_blocked_sum, __pyx_n_s_kern_add); if (unlikely(!__pyx_tuple__297)) __PYX_ERR(1, 3018, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__297);
  __Pyx_GIVEREF(__pyx_tuple__297);
  __pyx_codeobj__298 = (PyObject*)__Pyx_PyCode_New(2, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__297, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_src_github_com_pfne_3, __pyx_n_s_scan, 3018, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__298)) __PYX_ERR(1, 3018, __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(1, 1, __pyx_L1_error);
  __pyx_float_1_ = PyFloat_FromDouble(1.); if (unlikely(!__pyx_float_1_)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_float_0_0 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_float_0_0)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_float_1_0 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_float_1_0)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_int_32 = PyInt_FromLong(32); if (unlikely(!__pyx_int_32)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_int_100 = PyInt_FromLong(100); if (unlikely(!__pyx_int_100)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_int_256 = PyInt_FromLong(256); if (unlikely(!__pyx_int_256)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_int_512 = PyInt_FromLong(512); if (unlikely(!__pyx_int_512)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_int_7500 = PyInt_FromLong(7500); if (unlikely(!__pyx_int_7500)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_int_neg_2 = PyInt_FromLong(-2); if (unlikely(!__pyx_int_neg_2)) __PYX_ERR(1, 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;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  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;
  struct __pyx_opt_args_4cupy_4core_4core_create_ufunc __pyx_t_16;
  struct __pyx_opt_args_4cupy_4core_4core_create_reduction_func __pyx_t_17;
  struct __pyx_opt_args_4cupy_4core_4core__create_bit_op __pyx_t_18;
  struct __pyx_opt_args_4cupy_4core_4core_create_comparison __pyx_t_19;
  __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(1, 1, __pyx_L1_error)
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(1, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(1, 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(1, 1, __pyx_L1_error)
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(1, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(1, 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(1, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(1, 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(1, 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(1, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(1, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "cupy.core.core")) {
      if (unlikely(PyDict_SetItemString(modules, "cupy.core.core", __pyx_m) < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  /*--- Global init code ---*/
  __pyx_v_4cupy_4core_4core_newaxis = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__header_source = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__typenames_base = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__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__amin = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__amax = 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__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__boolean_array_indexing_nth = 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__all = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__any = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__sum = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__prod = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__clip = 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);
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- 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))__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.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 *, PyObject *, PyObject *, 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.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;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_ndarray) < 0) __PYX_ERR(1, 34, __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(1, 34, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_4cupy_4core_4core_7ndarray_146__getitem__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_4cupy_4core_4core_7ndarray_146__getitem__.doc = __pyx_doc_4cupy_4core_4core_7ndarray_146__getitem__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_4cupy_4core_4core_7ndarray_146__getitem__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_4cupy_4core_4core_ndarray.tp_dict, __pyx_vtabptr_4cupy_4core_4core_ndarray) < 0) __PYX_ERR(1, 34, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "ndarray", (PyObject *)&__pyx_type_4cupy_4core_4core_ndarray) < 0) __PYX_ERR(1, 34, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_ndarray = &__pyx_type_4cupy_4core_4core_ndarray;
  __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(1, 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, 14, __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, 14, __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, 34, __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, 34, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_CIndexer = &__pyx_type_4cupy_4core_4core_CIndexer;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_Indexer) < 0) __PYX_ERR(2, 51, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_Indexer.tp_print = 0;
  if (PyObject_SetAttrString(__pyx_m, "Indexer", (PyObject *)&__pyx_type_4cupy_4core_4core_Indexer) < 0) __PYX_ERR(2, 51, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_Indexer = &__pyx_type_4cupy_4core_4core_Indexer;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_ParameterInfo) < 0) __PYX_ERR(0, 219, __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(0, 219, __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(0, 412, __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(0, 412, __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(0, 412, __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(1, 1689, __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(1, 1689, __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(0, 390, __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(0, 394, __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(0, 665, __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(0, 674, __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(0, 677, __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(3, 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(3, 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;
  /*--- Type import code ---*/
  __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(5, 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(6, 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(7, 15, __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(8, 5, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6device_Device = __Pyx_ImportType("cupy.cuda.device", "Device", sizeof(struct __pyx_obj_4cupy_4cuda_6device_Device), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6device_Device)) __PYX_ERR(9, 4, __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(9, 4, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_Memory = __Pyx_ImportType("cupy.cuda.memory", "Memory", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_Memory), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_Memory)) __PYX_ERR(10, 3, __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(10, 11, __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(10, 11, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_PooledMemory = __Pyx_ImportType("cupy.cuda.memory", "PooledMemory", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_PooledMemory), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_PooledMemory)) __PYX_ERR(10, 36, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_6memory_PooledMemory = (struct __pyx_vtabstruct_4cupy_4cuda_6memory_PooledMemory*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_6memory_PooledMemory->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_6memory_PooledMemory)) __PYX_ERR(10, 36, __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(10, 44, __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(10, 44, __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(10, 61, __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(10, 61, __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(11, 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(11, 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(11, 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(11, 15, __pyx_L1_error)
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("cupy.core.internal"); if (!__pyx_t_1) __PYX_ERR(1, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "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(1, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "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(1, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "get_size", (void (**)(void))&__pyx_f_4cupy_4core_8internal_get_size, "PyObject *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "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(1, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "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(1, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "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 __pyx_skip_dispatch)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "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(1, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "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(1, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "complete_slice", (void (**)(void))&__pyx_f_4cupy_4core_8internal_complete_slice, "PyObject *(PyObject *, Py_ssize_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = __Pyx_ImportModule("cupy.cuda.cublas"); if (!__pyx_t_2) __PYX_ERR(1, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_2, "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(1, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_2, "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(1, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_2, "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(1, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_ImportModule("cupy.cuda.runtime"); if (!__pyx_t_3) __PYX_ERR(1, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_3, "runtimeGetVersion", (void (**)(void))&__pyx_f_4cupy_4cuda_7runtime_runtimeGetVersion, "int (int __pyx_skip_dispatch)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_ImportModule("cupy.cuda.device"); if (!__pyx_t_4) __PYX_ERR(1, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "get_device_id", (void (**)(void))&__pyx_f_4cupy_4cuda_6device_get_device_id, "int (int __pyx_skip_dispatch)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "get_cublas_handle", (void (**)(void))&__pyx_f_4cupy_4cuda_6device_get_cublas_handle, "PyObject *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = __Pyx_ImportModule("cupy.cuda.memory"); if (!__pyx_t_5) __PYX_ERR(1, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_5, "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(1, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  #endif

  /* "cupy/core/core.pyx":4
 * 
 * from __future__ import division
 * import ctypes             # <<<<<<<<<<<<<<
 * import sys
 * 
 */
  __pyx_t_6 = __Pyx_Import(__pyx_n_s_ctypes, 0, -1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ctypes, __pyx_t_6) < 0) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":5
 * from __future__ import division
 * import ctypes
 * import sys             # <<<<<<<<<<<<<<
 * 
 * import numpy
 */
  __pyx_t_6 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_6) < 0) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":7
 * import sys
 * 
 * import numpy             # <<<<<<<<<<<<<<
 * import six
 * 
 */
  __pyx_t_6 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_6) < 0) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":8
 * 
 * import numpy
 * import six             # <<<<<<<<<<<<<<
 * 
 * from cupy.core import flags
 */
  __pyx_t_6 = __Pyx_Import(__pyx_n_s_six, 0, -1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_six, __pyx_t_6) < 0) __PYX_ERR(1, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":10
 * import six
 * 
 * from cupy.core import flags             # <<<<<<<<<<<<<<
 * from cupy.cuda import stream
 * from cupy import util
 */
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_n_s_flags);
  __Pyx_GIVEREF(__pyx_n_s_flags);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_s_flags);
  __pyx_t_7 = __Pyx_Import(__pyx_n_s_cupy_core, __pyx_t_6, -1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_flags); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_flags, __pyx_t_6) < 0) __PYX_ERR(1, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":11
 * 
 * from cupy.core import flags
 * from cupy.cuda import stream             # <<<<<<<<<<<<<<
 * from cupy import util
 * 
 */
  __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_n_s_stream);
  __Pyx_GIVEREF(__pyx_n_s_stream);
  PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_stream);
  __pyx_t_6 = __Pyx_Import(__pyx_n_s_cupy_cuda, __pyx_t_7, -1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_6, __pyx_n_s_stream); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_stream, __pyx_t_7) < 0) __PYX_ERR(1, 11, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":12
 * from cupy.core import flags
 * from cupy.cuda import stream
 * from cupy import util             # <<<<<<<<<<<<<<
 * 
 * cimport cpython
 */
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_n_s_util);
  __Pyx_GIVEREF(__pyx_n_s_util);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_s_util);
  __pyx_t_7 = __Pyx_Import(__pyx_n_s_cupy_2, __pyx_t_6, -1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_util); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_util, __pyx_t_6) < 0) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":76
 *         readonly ndarray base
 * 
 *     def __init__(self, shape, dtype=float, memptr=None):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t size
 *         self._shape = internal.get_size(shape)
 */
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __pyx_k_ = ((PyObject *)(&PyFloat_Type));
  __Pyx_GIVEREF((&PyFloat_Type));

  /* "cupy/core/core.pyx":195
 *             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(1, 195, __pyx_L1_error)
  PyType_Modified(__pyx_ptype_4cupy_4core_4core_ndarray);

  /* "cupy/core/core.pyx":1203
 *         return int(self.get())
 * 
 *     if sys.version_info < (3,):             # <<<<<<<<<<<<<<
 *         def __long__(self):
 *             # Avoid using long() for flake8
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_version_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyObject_RichCompare(__pyx_t_6, __pyx_tuple__128, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1203, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 1203, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1204
 * 
 *     if sys.version_info < (3,):
 *         def __long__(self):             # <<<<<<<<<<<<<<
 *             # Avoid using long() for flake8
 *             return self.get().__long__()
 */
  }

  /* "cupy/core/core.pyx":1360
 * 
 * 
 * cdef object newaxis = numpy.newaxis  # == None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_newaxis); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core_newaxis);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core_newaxis, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/carray.pxi":1
 * import os             # <<<<<<<<<<<<<<
 * 
 * from cupy import cuda
 */
  __pyx_t_6 = __Pyx_Import(__pyx_n_s_os, 0, -1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_6) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/carray.pxi":3
 * import os
 * 
 * from cupy import cuda             # <<<<<<<<<<<<<<
 * 
 * from cupy.cuda cimport function
 */
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_n_s_cuda);
  __Pyx_GIVEREF(__pyx_n_s_cuda);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_s_cuda);
  __pyx_t_7 = __Pyx_Import(__pyx_n_s_cupy_2, __pyx_t_6, -1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_cuda); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_cuda, __pyx_t_6) < 0) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/carray.pxi":72
 * 
 * 
 * cdef str _header_source = None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__header_source);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__header_source, ((PyObject*)Py_None));
  __Pyx_GIVEREF(Py_None);

  /* "cupy/core/elementwise.pxi":1
 * import string             # <<<<<<<<<<<<<<
 * 
 * import numpy
 */
  __pyx_t_7 = __Pyx_Import(__pyx_n_s_string, 0, -1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_string, __pyx_t_7) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":3
 * import string
 * 
 * import numpy             # <<<<<<<<<<<<<<
 * import six
 * 
 */
  __pyx_t_7 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_7) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":4
 * 
 * import numpy
 * import six             # <<<<<<<<<<<<<<
 * 
 * from cupy import util
 */
  __pyx_t_7 = __Pyx_Import(__pyx_n_s_six, 0, -1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_six, __pyx_t_7) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":6
 * import six
 * 
 * from cupy import util             # <<<<<<<<<<<<<<
 * 
 * from cupy.cuda cimport device
 */
  __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_n_s_util);
  __Pyx_GIVEREF(__pyx_n_s_util);
  PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_util);
  __pyx_t_6 = __Pyx_Import(__pyx_n_s_cupy_2, __pyx_t_7, -1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_6, __pyx_n_s_util); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_util, __pyx_t_7) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":37
 * 
 * cdef dict _typenames_base = {
 *     numpy.dtype('float64'): 'double',             # <<<<<<<<<<<<<<
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__129, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_7, __pyx_n_s_double) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":38
 * cdef dict _typenames_base = {
 *     numpy.dtype('float64'): 'double',
 *     numpy.dtype('float32'): 'float',             # <<<<<<<<<<<<<<
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('int64'): 'long long',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__130, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_7, __pyx_n_s_float) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":39
 *     numpy.dtype('float64'): 'double',
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__131, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_7, __pyx_n_s_float16) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":40
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('int64'): 'long long',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int32'): 'int',
 *     numpy.dtype('int16'): 'short',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__132, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_7, __pyx_kp_s_long_long) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":41
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int16'): 'short',
 *     numpy.dtype('int8'): 'signed char',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__133, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_7, __pyx_n_s_int) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":42
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',
 *     numpy.dtype('int16'): 'short',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int8'): 'signed char',
 *     numpy.dtype('uint64'): 'unsigned long long',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__134, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_7, __pyx_n_s_short) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":43
 *     numpy.dtype('int32'): 'int',
 *     numpy.dtype('int16'): 'short',
 *     numpy.dtype('int8'): 'signed char',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint64'): 'unsigned long long',
 *     numpy.dtype('uint32'): 'unsigned int',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__135, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_7, __pyx_kp_s_signed_char) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":44
 *     numpy.dtype('int16'): 'short',
 *     numpy.dtype('int8'): 'signed char',
 *     numpy.dtype('uint64'): 'unsigned long long',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint32'): 'unsigned int',
 *     numpy.dtype('uint16'): 'unsigned short',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__136, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_7, __pyx_kp_s_unsigned_long_long) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":45
 *     numpy.dtype('int8'): 'signed char',
 *     numpy.dtype('uint64'): 'unsigned long long',
 *     numpy.dtype('uint32'): 'unsigned int',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__137, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_7, __pyx_kp_s_unsigned_int) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":46
 *     numpy.dtype('uint64'): 'unsigned long long',
 *     numpy.dtype('uint32'): 'unsigned int',
 *     numpy.dtype('uint16'): 'unsigned short',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint8'): 'unsigned char',
 *     numpy.dtype('bool'): 'bool',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__138, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_7, __pyx_kp_s_unsigned_short) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":47
 *     numpy.dtype('uint32'): 'unsigned int',
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',             # <<<<<<<<<<<<<<
 *     numpy.dtype('bool'): 'bool',
 * }
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__139, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_7, __pyx_kp_s_unsigned_char) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":48
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',
 *     numpy.dtype('bool'): 'bool',             # <<<<<<<<<<<<<<
 * }
 * 
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__140, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_7, __pyx_n_s_bool_2) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__typenames_base);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__typenames_base, ((PyObject*)__pyx_t_6));
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":51
 * }
 * 
 * cdef str _all_type_chars = 'dfeqlihbQLIHB?'             # <<<<<<<<<<<<<<
 * 
 * cdef dict _typenames = {
 */
  __Pyx_INCREF(__pyx_kp_s_dfeqlihbQLIHB);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__all_type_chars);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__all_type_chars, __pyx_kp_s_dfeqlihbQLIHB);
  __Pyx_GIVEREF(__pyx_kp_s_dfeqlihbQLIHB);

  /* "cupy/core/elementwise.pxi":53
 * cdef str _all_type_chars = 'dfeqlihbQLIHB?'
 * 
 * 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_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 53, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_6);

    /* "cupy/core/elementwise.pxi":55
 * 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)
 */
    __pyx_t_7 = PyObject_GetIter(__pyx_v_4cupy_4core_4core__all_type_chars); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 55, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_10 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 55, __pyx_L5_error)
    for (;;) {
      {
        __pyx_t_9 = __pyx_t_10(__pyx_t_7);
        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, 55, __pyx_L5_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i, __pyx_t_9);
      __pyx_t_9 = 0;

      /* "cupy/core/elementwise.pxi":54
 * 
 * cdef dict _typenames = {
 *     numpy.dtype(i).type: _typenames_base[numpy.dtype(i)]             # <<<<<<<<<<<<<<
 *     for i in _all_type_chars}
 * 
 */
      __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 54, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_dtype); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 54, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
        }
      }
      if (!__pyx_t_11) {
        __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 54, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_9);
      } else {
        __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 54, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11); __pyx_t_11 = 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_13, 0+1, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 54, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_type); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 54, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (unlikely(__pyx_v_4cupy_4core_4core__typenames_base == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 54, __pyx_L5_error)
      }
      __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 54, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_dtype); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 54, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      if (!__pyx_t_13) {
        __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 54, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_9);
      } else {
        __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 54, __pyx_L5_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_8genexpr1__pyx_v_4cupy_4core_4core_i);
        __Pyx_GIVEREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
        PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_14, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 54, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v_4cupy_4core_4core__typenames_base, __pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 54, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (unlikely(PyDict_SetItem(__pyx_t_6, (PyObject*)__pyx_t_12, (PyObject*)__pyx_t_11))) __PYX_ERR(0, 54, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

      /* "cupy/core/elementwise.pxi":55
 * 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)
 */
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
    goto __pyx_L8_exit_scope;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
    goto __pyx_L1_error;
    __pyx_L8_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_6));
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":57
 *     for i in _all_type_chars}
 * 
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool)             # <<<<<<<<<<<<<<
 * cdef tuple _numpy_scalar_type = tuple([numpy.dtype(i).type
 *                                        for i in _all_type_chars])
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 57, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_integer_types); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 57, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 57, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)(&PyFloat_Type)));
  __Pyx_INCREF(((PyObject*)&PyBool_Type));
  __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
  PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject*)&PyBool_Type));
  __pyx_t_11 = PyNumber_Add(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 57, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_11))||((__pyx_t_11) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_11)->tp_name), 0))) __PYX_ERR(0, 57, __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_11));
  __Pyx_GIVEREF(__pyx_t_11);
  __pyx_t_11 = 0;

  /* "cupy/core/elementwise.pxi":58
 * 
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool)
 * cdef tuple _numpy_scalar_type = tuple([numpy.dtype(i).type             # <<<<<<<<<<<<<<
 *                                        for i in _all_type_chars])
 * 
 */
  __pyx_t_11 = PyList_New(0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 58, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);

  /* "cupy/core/elementwise.pxi":59
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool)
 * 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_6 = PyObject_GetIter(__pyx_v_4cupy_4core_4core__all_type_chars); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_10 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 59, __pyx_L1_error)
  for (;;) {
    {
      __pyx_t_7 = __pyx_t_10(__pyx_t_6);
      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, 59, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_7);
    }
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_i, __pyx_t_7) < 0) __PYX_ERR(0, 59, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":58
 * 
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool)
 * cdef tuple _numpy_scalar_type = tuple([numpy.dtype(i).type             # <<<<<<<<<<<<<<
 *                                        for i in _all_type_chars])
 * 
 */
    __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 58, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 58, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_i); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 58, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_14 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_14)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_14);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_14) {
      __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_7);
    } else {
      __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 58, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); __pyx_t_14 = NULL;
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_12);
      __pyx_t_12 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 58, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_11, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 58, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "cupy/core/elementwise.pxi":59
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool)
 * 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_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":58
 * 
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool)
 * cdef tuple _numpy_scalar_type = tuple([numpy.dtype(i).type             # <<<<<<<<<<<<<<
 *                                        for i in _all_type_chars])
 * 
 */
  __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_11)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 58, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 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_6));
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":61
 *                                        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_6 = PySet_New(__pyx_v_4cupy_4core_4core__python_scalar_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __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_6));
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":62
 * 
 * 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_6 = PySet_New(__pyx_v_4cupy_4core_4core__numpy_scalar_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __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_6));
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":65
 * 
 * cdef dict _kind_score = {
 *     'b': 0,             # <<<<<<<<<<<<<<
 *     'u': 1,
 *     'i': 1,
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 65, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_b, __pyx_int_0) < 0) __PYX_ERR(0, 65, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_u, __pyx_int_1) < 0) __PYX_ERR(0, 65, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_i, __pyx_int_1) < 0) __PYX_ERR(0, 65, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_f, __pyx_int_2) < 0) __PYX_ERR(0, 65, __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_6));
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":73
 * 
 * cdef dict _python_type_to_numpy_type = {
 *     float: numpy.dtype(float).type,             # <<<<<<<<<<<<<<
 *     bool: numpy.dtype(bool).type}
 * for i in six.integer_types:
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 73, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 73, __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(0, 73, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  if (!__pyx_t_9) {
    __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_7, ((PyObject *)(&PyFloat_Type))); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 73, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
  } else {
    __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 73, __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_INCREF(((PyObject *)(&PyFloat_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
    PyTuple_SET_ITEM(__pyx_t_13, 0+1, ((PyObject *)(&PyFloat_Type)));
    __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_13, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 73, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_type); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 73, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (PyDict_SetItem(__pyx_t_6, ((PyObject *)(&PyFloat_Type)), __pyx_t_7) < 0) __PYX_ERR(0, 73, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":74
 * cdef dict _python_type_to_numpy_type = {
 *     float: numpy.dtype(float).type,
 *     bool: numpy.dtype(bool).type}             # <<<<<<<<<<<<<<
 * for i in six.integer_types:
 *     _python_type_to_numpy_type[i] = numpy.dtype(i).type
 */
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 74, __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(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_7 = __Pyx_PyObject_CallOneArg(__pyx_t_13, ((PyObject*)&PyBool_Type)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 74, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
  } else {
    __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 74, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_11); __pyx_t_11 = NULL;
    __Pyx_INCREF(((PyObject*)&PyBool_Type));
    __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
    PyTuple_SET_ITEM(__pyx_t_9, 0+1, ((PyObject*)&PyBool_Type));
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_9, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 74, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_type); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_t_6, ((PyObject*)&PyBool_Type), __pyx_t_13) < 0) __PYX_ERR(0, 73, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 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_6));
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":75
 *     float: numpy.dtype(float).type,
 *     bool: numpy.dtype(bool).type}
 * for i in six.integer_types:             # <<<<<<<<<<<<<<
 *     _python_type_to_numpy_type[i] = numpy.dtype(i).type
 * 
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_integer_types); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (likely(PyList_CheckExact(__pyx_t_13)) || PyTuple_CheckExact(__pyx_t_13)) {
    __pyx_t_6 = __pyx_t_13; __Pyx_INCREF(__pyx_t_6); __pyx_t_15 = 0;
    __pyx_t_10 = NULL;
  } else {
    __pyx_t_15 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_13); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 75, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_10 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 75, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  for (;;) {
    if (likely(!__pyx_t_10)) {
      if (likely(PyList_CheckExact(__pyx_t_6))) {
        if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_13 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_15); __Pyx_INCREF(__pyx_t_13); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(0, 75, __pyx_L1_error)
        #else
        __pyx_t_13 = PySequence_ITEM(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 75, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        #endif
      } else {
        if (__pyx_t_15 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_13 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_15); __Pyx_INCREF(__pyx_t_13); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(0, 75, __pyx_L1_error)
        #else
        __pyx_t_13 = PySequence_ITEM(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 75, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        #endif
      }
    } else {
      __pyx_t_13 = __pyx_t_10(__pyx_t_6);
      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(0, 75, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_13);
    }
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_i, __pyx_t_13) < 0) __PYX_ERR(0, 75, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

    /* "cupy/core/elementwise.pxi":76
 *     bool: numpy.dtype(bool).type}
 * for i in six.integer_types:
 *     _python_type_to_numpy_type[i] = numpy.dtype(i).type             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 76, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 76, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_i); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 76, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_11 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(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);
      }
    }
    if (!__pyx_t_11) {
      __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 76, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_13);
    } else {
      __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 76, __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_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 76, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 76, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    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(0, 76, __pyx_L1_error)
    }
    __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_i); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 76, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    if (unlikely(PyDict_SetItem(__pyx_v_4cupy_4core_4core__python_type_to_numpy_type, __pyx_t_13, __pyx_t_9) < 0)) __PYX_ERR(0, 76, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "cupy/core/elementwise.pxi":75
 *     float: numpy.dtype(float).type,
 *     bool: numpy.dtype(bool).type}
 * for i in six.integer_types:             # <<<<<<<<<<<<<<
 *     _python_type_to_numpy_type[i] = numpy.dtype(i).type
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":256
 * 
 * 
 * @util.memoize()             # <<<<<<<<<<<<<<
 * def _get_param_info(s, is_const):
 *     if len(s) == 0:
 */
  __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_memoize); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_9 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 256, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  } else {
    __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 256, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/elementwise.pxi":257
 * 
 * @util.memoize()
 * def _get_param_info(s, is_const):             # <<<<<<<<<<<<<<
 *     if len(s) == 0:
 *         return ()
 */
  __pyx_t_12 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_21_get_param_info, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  if (!__pyx_t_13) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 256, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 256, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_13); __pyx_t_13 = NULL;
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 256, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_param_info, __pyx_t_6) < 0) __PYX_ERR(0, 257, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":263
 * 
 * 
 * @util.memoize()             # <<<<<<<<<<<<<<
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):
 *     type_dict = {}
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_memoize); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
    }
  }
  if (__pyx_t_7) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 263, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else {
    __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 263, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/elementwise.pxi":264
 * 
 * @util.memoize()
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):             # <<<<<<<<<<<<<<
 *     type_dict = {}
 *     if out_args_dtype:
 */
  __pyx_t_12 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_23_decide_params_type, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 263, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 263, __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_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_decide_params_type, __pyx_t_6) < 0) __PYX_ERR(0, 264, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":389
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_elementwise_kernel(args_info, types, params, operation, name,
 *                             preamble, kwargs):
 */
  __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_memoize); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 389, __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, 389, __pyx_L1_error)
  __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_empty_tuple, __pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":390
 * 
 * @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_9 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_25_get_elementwise_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_13 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_6 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 389, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 389, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_13); __pyx_t_13 = NULL;
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 389, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_elementwise_kernel, __pyx_t_6) < 0) __PYX_ERR(0, 390, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":556
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_ufunc_kernel(
 *         in_types, out_types, routine, args_info, params, name, preamble):
 */
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_memoize); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(0, 556, __pyx_L1_error)
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_empty_tuple, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/elementwise.pxi":557
 * 
 * @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_12 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_27_get_ufunc_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 556, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 556, __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_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_ufunc_kernel, __pyx_t_6) < 0) __PYX_ERR(0, 557, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":654
 * 
 * 
 * class ufunc(object):             # <<<<<<<<<<<<<<
 * 
 *     """Universal function.
 */
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 654, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_builtin_object);
  __Pyx_GIVEREF(__pyx_builtin_object);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_builtin_object);
  __pyx_t_9 = __Pyx_CalculateMetaclass(NULL, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 654, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_13 = __Pyx_Py3MetaclassPrepare(__pyx_t_9, __pyx_t_6, __pyx_n_s_ufunc, __pyx_n_s_ufunc, (PyObject *) NULL, __pyx_n_s_cupy_core_core, __pyx_kp_s_Universal_function_Attributes_na); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 654, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);

  /* "cupy/core/elementwise.pxi":665
 * 
 *     """
 *     def __init__(self, name, nin, nout, ops, preamble='', doc=''):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self.nin = nin
 */
  __pyx_t_12 = __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__150)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 665, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_12, __pyx_tuple__151);
  if (PyObject_SetItem(__pyx_t_13, __pyx_n_s_init, __pyx_t_12) < 0) __PYX_ERR(0, 665, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/elementwise.pxi":683
 *         self._routine_cache = {}
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<ufunc '%s'>" % self.name
 * 
 */
  __pyx_t_12 = __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__153)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 683, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyObject_SetItem(__pyx_t_13, __pyx_n_s_repr, __pyx_t_12) < 0) __PYX_ERR(0, 683, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/elementwise.pxi":687
 * 
 *     @property
 *     def types(self):             # <<<<<<<<<<<<<<
 *         """A list of type signatures.
 * 
 */
  __pyx_t_12 = __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__156)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 687, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/elementwise.pxi":686
 *         return "<ufunc '%s'>" % self.name
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def types(self):
 *         """A list of type signatures.
 */
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_12);
  __pyx_t_12 = 0;
  __pyx_t_12 = __Pyx_PyObject_Call(__pyx_builtin_property, __pyx_t_7, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyObject_SetItem(__pyx_t_13, __pyx_n_s_types, __pyx_t_12) < 0) __PYX_ERR(0, 687, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/elementwise.pxi":701
 *         return types
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Applies the universal function to arguments elementwise.
 * 
 */
  __pyx_t_12 = __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__158)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 701, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyObject_SetItem(__pyx_t_13, __pyx_n_s_call, __pyx_t_12) < 0) __PYX_ERR(0, 701, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/elementwise.pxi":654
 * 
 * 
 * class ufunc(object):             # <<<<<<<<<<<<<<
 * 
 *     """Universal function.
 */
  __pyx_t_12 = __Pyx_Py3ClassCreate(__pyx_t_9, __pyx_n_s_ufunc, __pyx_t_6, __pyx_t_13, NULL, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 654, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ufunc, __pyx_t_12) < 0) __PYX_ERR(0, 654, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/reduction.pxi":1
 * import collections             # <<<<<<<<<<<<<<
 * import string
 * 
 */
  __pyx_t_6 = __Pyx_Import(__pyx_n_s_collections, 0, -1); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_collections, __pyx_t_6) < 0) __PYX_ERR(3, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/reduction.pxi":2
 * import collections
 * import string             # <<<<<<<<<<<<<<
 * 
 * import numpy
 */
  __pyx_t_6 = __Pyx_Import(__pyx_n_s_string, 0, -1); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_string, __pyx_t_6) < 0) __PYX_ERR(3, 2, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/reduction.pxi":4
 * import string
 * 
 * import numpy             # <<<<<<<<<<<<<<
 * import six
 * 
 */
  __pyx_t_6 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_6) < 0) __PYX_ERR(3, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/reduction.pxi":5
 * 
 * import numpy
 * import six             # <<<<<<<<<<<<<<
 * 
 * from cupy import util
 */
  __pyx_t_6 = __Pyx_Import(__pyx_n_s_six, 0, -1); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_six, __pyx_t_6) < 0) __PYX_ERR(3, 5, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/reduction.pxi":7
 * import six
 * 
 * from cupy import util             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_n_s_util);
  __Pyx_GIVEREF(__pyx_n_s_util);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_s_util);
  __pyx_t_9 = __Pyx_Import(__pyx_n_s_cupy_2, __pyx_t_6, -1); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_util); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_util, __pyx_t_6) < 0) __PYX_ERR(3, 7, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":10
 * 
 * 
 * six_zip = six.moves.zip             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_moves); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 10, __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_zip); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_six_zip, __pyx_t_9) < 0) __PYX_ERR(3, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":168
 * 
 * 
 * @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_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_memoize); if (unlikely(!__pyx_t_13)) __PYX_ERR(3, 168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(3, 168, __pyx_L1_error)
  __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_empty_tuple, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/reduction.pxi":169
 * 
 * @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_6 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_41_get_simple_reduction_function, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_13 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_9 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 168, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 168, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_13); __pyx_t_13 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_7, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 168, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_simple_reduction_function, __pyx_t_9) < 0) __PYX_ERR(3, 169, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":187
 * 
 * 
 * class simple_reduction_function(object):             # <<<<<<<<<<<<<<
 * 
 *     _block_size = 512
 */
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 187, __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_12 = __Pyx_CalculateMetaclass(NULL, __pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_7 = __Pyx_Py3MetaclassPrepare(__pyx_t_12, __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_7)) __PYX_ERR(3, 187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/reduction.pxi":189
 * class simple_reduction_function(object):
 * 
 *     _block_size = 512             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, name, ops, identity, preamble):
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_block_size_2, __pyx_int_512) < 0) __PYX_ERR(3, 189, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":191
 *     _block_size = 512
 * 
 *     def __init__(self, name, ops, identity, preamble):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self._ops = ops
 */
  __pyx_t_6 = __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__162)); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_init, __pyx_t_6) < 0) __PYX_ERR(3, 191, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/reduction.pxi":209
 *         self._routine_cache = {}
 * 
 *     def __call__(self, a, axis=None, dtype=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         if not isinstance(a, ndarray):
 *             raise TypeError('Input type must be cupy.ndarray')
 */
  __pyx_t_6 = __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__164)); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 209, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_6, __pyx_tuple__165);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_call, __pyx_t_6) < 0) __PYX_ERR(3, 209, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/reduction.pxi":187
 * 
 * 
 * class simple_reduction_function(object):             # <<<<<<<<<<<<<<
 * 
 *     _block_size = 512
 */
  __pyx_t_6 = __Pyx_Py3ClassCreate(__pyx_t_12, __pyx_n_s_simple_reduction_function, __pyx_t_9, __pyx_t_7, NULL, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_simple_reduction_function, __pyx_t_6) < 0) __PYX_ERR(3, 187, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 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_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_memoize); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(3, 272, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_empty_tuple, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 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_12 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_43_get_reduction_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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_9 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 272, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(3, 272, __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_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_13, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 272, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_reduction_kernel, __pyx_t_9) < 0) __PYX_ERR(3, 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(3, 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_6 = __Pyx_CalculateMetaclass(NULL, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_13 = __Pyx_Py3MetaclassPrepare(__pyx_t_6, __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_13)) __PYX_ERR(3, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);

  /* "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_12 = __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__169)); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_12, __pyx_tuple__170);
  if (PyObject_SetItem(__pyx_t_13, __pyx_n_s_init, __pyx_t_12) < 0) __PYX_ERR(3, 327, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":353
 *         self.preamble = preamble
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Compiles and invokes the reduction kernel.
 * 
 */
  __pyx_t_12 = __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__172)); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyObject_SetItem(__pyx_t_13, __pyx_n_s_call, __pyx_t_12) < 0) __PYX_ERR(3, 353, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":296
 * 
 * 
 * class ReductionKernel(object):             # <<<<<<<<<<<<<<
 * 
 *     """User-defined reduction kernel.
 */
  __pyx_t_12 = __Pyx_Py3ClassCreate(__pyx_t_6, __pyx_n_s_ReductionKernel, __pyx_t_9, __pyx_t_13, NULL, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ReductionKernel, __pyx_t_12) < 0) __PYX_ERR(3, 296, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":1408
 * # =============================================================================
 * 
 * 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":1414
 *     ('?->?', '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'),
 *     _id)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_9 = __pyx_v_4cupy_4core_4core__id;
  __Pyx_INCREF(__pyx_t_9);

  /* "cupy/core/core.pyx":1410
 * 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_16.__pyx_n = 1;
  __pyx_t_16.routine = __pyx_t_9;
  __pyx_t_6 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_n_s_cupy_copy, __pyx_tuple__174, 0, &__pyx_t_16); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1410, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_elementwise_copy_2, __pyx_t_6) < 0) __PYX_ERR(1, 1410, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":1417
 * 
 * 
 * def elementwise_copy(*args, **kwargs):             # <<<<<<<<<<<<<<
 *     kwargs['casting'] = 'unsafe'
 *     return _elementwise_copy(*args, **kwargs)
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_47elementwise_copy, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_elementwise_copy, __pyx_t_6) < 0) __PYX_ERR(1, 1417, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":1422
 * 
 * 
 * _elementwise_copy_where = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_copy_where',
 *     ('??->?', 'b?->b', 'B?->B', 'h?->h', 'H?->H', 'i?->i', 'I?->I', 'l?->l',
 */
  __pyx_t_16.__pyx_n = 1;
  __pyx_t_16.routine = __pyx_kp_s_if_in1_out0_in0;
  __pyx_t_6 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_n_s_cupy_copy_where, __pyx_tuple__177, 0, &__pyx_t_16); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_elementwise_copy_where, __pyx_t_6) < 0) __PYX_ERR(1, 1422, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":1429
 * 
 * 
 * def elementwise_copy_where(*args, **kwargs):             # <<<<<<<<<<<<<<
 *     kwargs['casting'] = 'unsafe'
 *     return _elementwise_copy_where(*args, **kwargs)
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_49elementwise_copy_where, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_elementwise_copy_where_2, __pyx_t_6) < 0) __PYX_ERR(1, 1429, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":1434
 * 
 * 
 * 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":1444
 *     ('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_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1444, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_kp_s_ee_ee);
  __Pyx_GIVEREF(__pyx_kp_s_ee_ee);
  PyTuple_SET_ITEM(__pyx_t_6, 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_6, 1, __pyx_v_4cupy_4core_4core__divmod_float);

  /* "cupy/core/core.pyx":1445
 *      '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(1, 1445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_kp_s_ff_ff);
  __Pyx_GIVEREF(__pyx_kp_s_ff_ff);
  PyTuple_SET_ITEM(__pyx_t_9, 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_9, 1, __pyx_v_4cupy_4core_4core__divmod_float);

  /* "cupy/core/core.pyx":1446
 *      ('ee->ee', _divmod_float),
 *      ('ff->ff', _divmod_float),
 *      ('dd->dd', _divmod_float)),             # <<<<<<<<<<<<<<
 *     '''
 *     if (in1 == 0) {
 */
  __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_INCREF(__pyx_kp_s_dd_dd);
  __Pyx_GIVEREF(__pyx_kp_s_dd_dd);
  PyTuple_SET_ITEM(__pyx_t_13, 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_13, 1, __pyx_v_4cupy_4core_4core__divmod_float);

  /* "cupy/core/core.pyx":1442
 * 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_12 = PyTuple_New(13); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 1442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_INCREF(__pyx_kp_s_bb_bb);
  __Pyx_GIVEREF(__pyx_kp_s_bb_bb);
  PyTuple_SET_ITEM(__pyx_t_12, 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_12, 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_12, 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_12, 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_12, 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_12, 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_12, 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_12, 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_12, 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_12, 9, __pyx_kp_s_QQ_QQ);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_12, 10, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_12, 11, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_12, 12, __pyx_t_13);
  __pyx_t_6 = 0;
  __pyx_t_9 = 0;
  __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":1440
 * 
 * 
 * divmod = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_divmod',
 *     ('bb->bb', 'BB->BB', 'hh->hh', 'HH->HH', 'ii->ii', 'II->II', 'll->ll',
 */
  __pyx_t_16.__pyx_n = 1;
  __pyx_t_16.routine = __pyx_kp_s_if_in1_0_out0_0_out1_0_else_out;
  __pyx_t_13 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_n_s_cupy_divmod, __pyx_t_12, 0, &__pyx_t_16); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_divmod, __pyx_t_13) < 0) __PYX_ERR(1, 1440, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":1458
 * 
 * 
 * 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":1560
 *     ('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_13 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_13);

  /* "cupy/core/core.pyx":1551
 * 
 * 
 * cdef _amin = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_min',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.routine = __pyx_tuple__187;
  __pyx_t_17.identity = Py_None;
  __pyx_t_17.preamble = __pyx_t_13;
  __pyx_t_12 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_min, __pyx_tuple__186, 0, &__pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 1551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__amin);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__amin, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":1572
 *     ('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_12 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_12);

  /* "cupy/core/core.pyx":1563
 * 
 * 
 * cdef _amax = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_max',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.routine = __pyx_tuple__195;
  __pyx_t_17.identity = Py_None;
  __pyx_t_17.preamble = __pyx_t_12;
  __pyx_t_13 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_max, __pyx_tuple__194, 0, &__pyx_t_17); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__amax);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__amax, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_13);
  __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":1581
 *     ('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_13 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_13);

  /* "cupy/core/core.pyx":1575
 * 
 * 
 * nanmin = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_nanmin',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.routine = __pyx_tuple__197;
  __pyx_t_17.identity = Py_None;
  __pyx_t_17.preamble = __pyx_t_13;
  __pyx_t_12 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_nanmin, __pyx_tuple__196, 0, &__pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 1575, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_nanmin, __pyx_t_12) < 0) __PYX_ERR(1, 1575, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":1590
 *     ('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_12 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_12);

  /* "cupy/core/core.pyx":1584
 * 
 * 
 * nanmax = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_nanmax',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.routine = __pyx_tuple__199;
  __pyx_t_17.identity = Py_None;
  __pyx_t_17.preamble = __pyx_t_12;
  __pyx_t_13 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_nanmax, __pyx_tuple__198, 0, &__pyx_t_17); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1584, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_nanmax, __pyx_t_13) < 0) __PYX_ERR(1, 1584, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":1602
 *     ('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_13 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_13);

  /* "cupy/core/core.pyx":1593
 * 
 * 
 * cdef _argmin = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_argmin',
 *     ('?->l', 'B->l', 'h->l', 'H->l', 'i->l', 'I->l', 'l->l', 'L->l',
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.routine = __pyx_tuple__207;
  __pyx_t_17.identity = Py_None;
  __pyx_t_17.preamble = __pyx_t_13;
  __pyx_t_12 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_argmin, __pyx_tuple__206, 0, &__pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 1593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__argmin);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__argmin, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":1614
 *     ('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_12 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_12);

  /* "cupy/core/core.pyx":1605
 * 
 * 
 * cdef _argmax = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_argmax',
 *     ('?->l', 'B->l', 'h->l', 'H->l', 'i->l', 'I->l', 'l->l', 'L->l',
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.routine = __pyx_tuple__215;
  __pyx_t_17.identity = Py_None;
  __pyx_t_17.preamble = __pyx_t_12;
  __pyx_t_13 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_argmax, __pyx_tuple__214, 0, &__pyx_t_17); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1605, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__argmax);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__argmax, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_13);
  __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":1889
 * 
 * 
 * bitwise_and = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'bitwise_and', '&', False,
 *     '''Computes the bitwise AND of two arrays elementwise.
 */
  __pyx_t_18.__pyx_n = 1;
  __pyx_t_18.doc = __pyx_kp_s_Computes_the_bitwise_AND_of_two;
  __pyx_t_13 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_bitwise_and, __pyx_kp_s__216, Py_False, 0, &__pyx_t_18); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1889, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bitwise_and, __pyx_t_13) < 0) __PYX_ERR(1, 1889, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":1900
 * 
 * 
 * bitwise_or = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'bitwise_or', '|', False,
 *     '''Computes the bitwise OR of two arrays elementwise.
 */
  __pyx_t_18.__pyx_n = 1;
  __pyx_t_18.doc = __pyx_kp_s_Computes_the_bitwise_OR_of_two_a;
  __pyx_t_13 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_bitwise_or, __pyx_kp_s__217, Py_False, 0, &__pyx_t_18); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1900, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bitwise_or, __pyx_t_13) < 0) __PYX_ERR(1, 1900, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":1911
 * 
 * 
 * bitwise_xor = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'bitwise_xor', '^', False,
 *     '''Computes the bitwise XOR of two arrays elementwise.
 */
  __pyx_t_18.__pyx_n = 1;
  __pyx_t_18.doc = __pyx_kp_s_Computes_the_bitwise_XOR_of_two;
  __pyx_t_13 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_bitwise_xor, __pyx_kp_s__218, Py_False, 0, &__pyx_t_18); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1911, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bitwise_xor, __pyx_t_13) < 0) __PYX_ERR(1, 1911, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":1922
 * 
 * 
 * invert = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_invert',
 *     (('?->?', 'out0 = !in0'), 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I',
 */
  __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1922, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);

  /* "cupy/core/core.pyx":1927
 *      '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_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 1927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_doc, __pyx_kp_s_Computes_the_bitwise_NOT_of_an_a) < 0) __PYX_ERR(1, 1927, __pyx_L1_error)

  /* "cupy/core/core.pyx":1922
 * 
 * 
 * invert = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_invert',
 *     (('?->?', 'out0 = !in0'), 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I',
 */
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_tuple__221, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1922, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_invert, __pyx_t_9) < 0) __PYX_ERR(1, 1922, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":1936
 * 
 * 
 * left_shift = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'left_shift', '<<', True,
 *     '''Shifts the bits of each integer element to the left.
 */
  __pyx_t_18.__pyx_n = 1;
  __pyx_t_18.doc = __pyx_kp_s_Shifts_the_bits_of_each_integer;
  __pyx_t_9 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_left_shift, __pyx_kp_s__222, Py_True, 0, &__pyx_t_18); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1936, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_left_shift, __pyx_t_9) < 0) __PYX_ERR(1, 1936, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":1947
 * 
 * 
 * right_shift = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'right_shift', '>>', True,
 *     '''Shifts the bits of each integer element to the right.
 */
  __pyx_t_18.__pyx_n = 1;
  __pyx_t_18.doc = __pyx_kp_s_Shifts_the_bits_of_each_integer_2;
  __pyx_t_9 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_right_shift, __pyx_kp_s__223, Py_True, 0, &__pyx_t_18); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1947, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_right_shift, __pyx_t_9) < 0) __PYX_ERR(1, 1947, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":1961
 * # -----------------------------------------------------------------------------
 * 
 * cdef _take_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T a, S indices, int32 cdim, int32 rdim, int32 adim, S index_range',
 *     'T out',
 */
  __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__224, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1961, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__take_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__take_kernel, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":1975
 * 
 * 
 * cdef _take_kernel_0axis = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T a, S indices, int32 rdim, S index_range',
 *     'T out',
 */
  __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__225, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1975, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__take_kernel_0axis);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__take_kernel_0axis, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":1987
 * 
 * 
 * cdef _boolean_array_indexing_nth = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'T a, bool boolean_array, S nth',
 *     'raw T out',
 */
  __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__226, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1987, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__boolean_array_indexing_nth);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__boolean_array_indexing_nth, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":2448
 * 
 * 
 * cdef _cuda_runtime_version = None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __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":2571
 * 
 * 
 * greater = create_comparison(             # <<<<<<<<<<<<<<
 *     'greater', '>',
 *     '''Tests elementwise if ``x1 > x2``.
 */
  __pyx_t_19.__pyx_n = 1;
  __pyx_t_19.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal;
  __pyx_t_9 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_greater, __pyx_kp_s__227, 0, &__pyx_t_19); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2571, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_greater, __pyx_t_9) < 0) __PYX_ERR(1, 2571, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":2580
 * 
 * 
 * greater_equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'greater_equal', '>=',
 *     '''Tests elementwise if ``x1 >= x2``.
 */
  __pyx_t_19.__pyx_n = 1;
  __pyx_t_19.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_2;
  __pyx_t_9 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_greater_equal, __pyx_kp_s__228, 0, &__pyx_t_19); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_greater_equal, __pyx_t_9) < 0) __PYX_ERR(1, 2580, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":2589
 * 
 * 
 * less = create_comparison(             # <<<<<<<<<<<<<<
 *     'less', '<',
 *     '''Tests elementwise if ``x1 < x2``.
 */
  __pyx_t_19.__pyx_n = 1;
  __pyx_t_19.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_3;
  __pyx_t_9 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_less, __pyx_kp_s__229, 0, &__pyx_t_19); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_less, __pyx_t_9) < 0) __PYX_ERR(1, 2589, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":2598
 * 
 * 
 * less_equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'less_equal', '<=',
 *     '''Tests elementwise if ``x1 <= x2``.
 */
  __pyx_t_19.__pyx_n = 1;
  __pyx_t_19.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_4;
  __pyx_t_9 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_less_equal, __pyx_kp_s__230, 0, &__pyx_t_19); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_less_equal, __pyx_t_9) < 0) __PYX_ERR(1, 2598, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":2607
 * 
 * 
 * equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'equal', '==',
 *     '''Tests elementwise if ``x1 == x2``.
 */
  __pyx_t_19.__pyx_n = 1;
  __pyx_t_19.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_5;
  __pyx_t_9 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_equal, __pyx_kp_s__231, 0, &__pyx_t_19); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2607, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_equal, __pyx_t_9) < 0) __PYX_ERR(1, 2607, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":2616
 * 
 * 
 * not_equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'not_equal', '!=',
 *     '''Tests elementwise if ``x1 != x2``.
 */
  __pyx_t_19.__pyx_n = 1;
  __pyx_t_19.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_6;
  __pyx_t_9 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_not_equal, __pyx_kp_s__232, 0, &__pyx_t_19); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2616, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_not_equal, __pyx_t_9) < 0) __PYX_ERR(1, 2616, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":2625
 * 
 * 
 * cdef _all = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_all',
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.routine = __pyx_tuple__234;
  __pyx_t_17.identity = __pyx_n_s_true;
  __pyx_t_17.preamble = __pyx_kp_s__4;
  __pyx_t_9 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_all, __pyx_tuple__233, 0, &__pyx_t_17); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__all);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__all, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":2633
 * 
 * 
 * cdef _any = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_any',
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.routine = __pyx_tuple__236;
  __pyx_t_17.identity = __pyx_n_s_false;
  __pyx_t_17.preamble = __pyx_kp_s__4;
  __pyx_t_9 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_any, __pyx_tuple__235, 0, &__pyx_t_17); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2633, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__any);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__any, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":2645
 * # -----------------------------------------------------------------------------
 * 
 * cdef _sum = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_sum',
 *     ('?->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L',
 */
  __pyx_t_17.__pyx_n = 2;
  __pyx_t_17.routine = __pyx_tuple__240;
  __pyx_t_17.identity = __pyx_int_0;
  __pyx_t_9 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_sum, __pyx_tuple__239, 0, &__pyx_t_17); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2645, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__sum);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__sum, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":2656
 * cdef _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_9 = PyList_New(13); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2656, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_kp_s_l);
  __Pyx_GIVEREF(__pyx_kp_s_l);
  PyList_SET_ITEM(__pyx_t_9, 0, __pyx_kp_s_l);
  __Pyx_INCREF(__pyx_kp_s_B_L);
  __Pyx_GIVEREF(__pyx_kp_s_B_L);
  PyList_SET_ITEM(__pyx_t_9, 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_9, 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_9, 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_9, 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_9, 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_9, 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_9, 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_9, 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_9, 9, __pyx_kp_s_Q_Q);
  __Pyx_INCREF(__pyx_tuple__242);
  __Pyx_GIVEREF(__pyx_tuple__242);
  PyList_SET_ITEM(__pyx_t_9, 10, __pyx_tuple__242);
  __Pyx_INCREF(__pyx_kp_s_f_f);
  __Pyx_GIVEREF(__pyx_kp_s_f_f);
  PyList_SET_ITEM(__pyx_t_9, 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_9, 12, __pyx_kp_s_d_d);

  /* "cupy/core/core.pyx":2654
 * 
 * 
 * cdef _prod = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_prod',
 *     ['?->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L',
 */
  __pyx_t_17.__pyx_n = 2;
  __pyx_t_17.routine = __pyx_tuple__243;
  __pyx_t_17.identity = __pyx_int_1;
  __pyx_t_12 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_prod, __pyx_t_9, 0, &__pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2654, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__prod);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__prod, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2673
 * 
 * 
 * add = create_arithmetic(             # <<<<<<<<<<<<<<
 *     'add', '+', '|',
 *     '''Adds two arrays elementwise.
 */
  __pyx_t_12 = __pyx_f_4cupy_4core_4core_create_arithmetic(__pyx_n_s_add, __pyx_kp_s__244, __pyx_kp_s__217, __pyx_kp_s_Adds_two_arrays_elementwise_seea); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2673, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_add, __pyx_t_12) < 0) __PYX_ERR(1, 2673, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2682
 * 
 * 
 * negative = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_negative',
 *     (('?->?', 'out0 = !in0'),
 */
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/core.pyx":2688
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d'),
 *     'out0 = -in0',
 *     doc='''Takes numerical negative elementwise.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.negative`
 */
  __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2688, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_doc, __pyx_kp_s_Takes_numerical_negative_element) < 0) __PYX_ERR(1, 2688, __pyx_L1_error)

  /* "cupy/core/core.pyx":2682
 * 
 * 
 * negative = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_negative',
 *     (('?->?', 'out0 = !in0'),
 */
  __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple__247, __pyx_t_9); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_negative, __pyx_t_13) < 0) __PYX_ERR(1, 2682, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":2695
 * 
 * 
 * multiply = create_arithmetic(             # <<<<<<<<<<<<<<
 *     'multiply', '*', '&',
 *     '''Multiplies two arrays elementwise.
 */
  __pyx_t_13 = __pyx_f_4cupy_4core_4core_create_arithmetic(__pyx_n_s_multiply, __pyx_kp_s__248, __pyx_kp_s__216, __pyx_kp_s_Multiplies_two_arrays_elementwis); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2695, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_multiply, __pyx_t_13) < 0) __PYX_ERR(1, 2695, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":2704
 * 
 * 
 * divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2704, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);

  /* "cupy/core/core.pyx":2712
 *      ('dd->d', 'out0 = in0 / in1')),
 *     'out0 = in1 == 0 ? 0 : floor((double)in0 / (double)in1)',
 *     doc='''Divides arguments elementwise.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.divide`
 */
  __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2712, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_doc, __pyx_kp_s_Divides_arguments_elementwise_se) < 0) __PYX_ERR(1, 2712, __pyx_L1_error)

  /* "cupy/core/core.pyx":2704
 * 
 * 
 * divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_tuple__253, __pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2704, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_divide, __pyx_t_12) < 0) __PYX_ERR(1, 2704, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2719
 * 
 * 
 * power = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_power',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2719, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/core.pyx":2727
 *      ('dd->d', 'out0 = pow(in0, in1)')),
 *     'out0 = rint(pow((double)in0, (double)in1))',
 *     doc='''Computes ``x1 ** x2`` elementwise.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.power`
 */
  __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2727, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_doc, __pyx_kp_s_Computes_x1_x2_elementwise_seeal) < 0) __PYX_ERR(1, 2727, __pyx_L1_error)

  /* "cupy/core/core.pyx":2719
 * 
 * 
 * power = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_power',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple__258, __pyx_t_9); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2719, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_power, __pyx_t_13) < 0) __PYX_ERR(1, 2719, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":2734
 * 
 * 
 * subtract = create_arithmetic(             # <<<<<<<<<<<<<<
 *     'subtract', '-', '^',
 *     '''Subtracts arguments elementwise.
 */
  __pyx_t_13 = __pyx_f_4cupy_4core_4core_create_arithmetic(__pyx_n_s_subtract, __pyx_kp_s__259, __pyx_kp_s__218, __pyx_kp_s_Subtracts_arguments_elementwise); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2734, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_subtract, __pyx_t_13) < 0) __PYX_ERR(1, 2734, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":2743
 * 
 * 
 * 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_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2743, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);

  /* "cupy/core/core.pyx":2748
 *      'qq->d', 'QQ->d', 'ee->e', '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_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2748, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_doc, __pyx_kp_s_Elementwise_true_division_i_e_di) < 0) __PYX_ERR(1, 2748, __pyx_L1_error)

  /* "cupy/core/core.pyx":2743
 * 
 * 
 * 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_12 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_tuple__261, __pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2743, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_true_divide, __pyx_t_12) < 0) __PYX_ERR(1, 2743, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2755
 * 
 * 
 * if six.PY3:             # <<<<<<<<<<<<<<
 *     divide = true_divide
 * 
 */
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_PY3); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 2755, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":2756
 * 
 * if six.PY3:
 *     divide = true_divide             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_true_divide); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2756, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_divide, __pyx_t_9) < 0) __PYX_ERR(1, 2756, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "cupy/core/core.pyx":2755
 * 
 * 
 * if six.PY3:             # <<<<<<<<<<<<<<
 *     divide = true_divide
 * 
 */
  }

  /* "cupy/core/core.pyx":2759
 * 
 * 
 * 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_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2759, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "cupy/core/core.pyx":2764
 *      '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_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2764, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_doc, __pyx_kp_s_Elementwise_floor_division_i_e_i) < 0) __PYX_ERR(1, 2764, __pyx_L1_error)

  /* "cupy/core/core.pyx":2759
 * 
 * 
 * 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_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__263, __pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2759, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_floor_divide, __pyx_t_13) < 0) __PYX_ERR(1, 2759, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":2771
 * 
 * 
 * remainder = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_remainder',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);

  /* "cupy/core/core.pyx":2779
 *      ('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_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2779, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_doc, __pyx_kp_s_Computes_the_remainder_of_Python) < 0) __PYX_ERR(1, 2779, __pyx_L1_error)

  /* "cupy/core/core.pyx":2771
 * 
 * 
 * remainder = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_remainder',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_tuple__268, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_remainder, __pyx_t_9) < 0) __PYX_ERR(1, 2771, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":2786
 * 
 * 
 * absolute = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),
 */
  __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2786, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "cupy/core/core.pyx":2796
 *      ('d->d', 'out0 = fabs(in0)')),
 *     'out0 = in0 > 0 ? in0 : -in0',
 *     doc='''Elementwise absolute value function.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.absolute`
 */
  __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2796, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_doc, __pyx_kp_s_Elementwise_absolute_value_funct) < 0) __PYX_ERR(1, 2796, __pyx_L1_error)

  /* "cupy/core/core.pyx":2786
 * 
 * 
 * absolute = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),
 */
  __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__279, __pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2786, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_absolute, __pyx_t_13) < 0) __PYX_ERR(1, 2786, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":2803
 * 
 * 
 * sqrt = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_sqrt',
 *     ('e->e', 'f->f', 'd->d'),
 */
  __pyx_t_16.__pyx_n = 1;
  __pyx_t_16.routine = __pyx_kp_s_out0_sqrt_in0;
  __pyx_t_13 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_n_s_cupy_sqrt, __pyx_tuple__280, 0, &__pyx_t_16); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sqrt, __pyx_t_13) < 0) __PYX_ERR(1, 2803, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":2809
 * 
 * 
 * cdef _clip = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_clip',
 *     ('???->?', 'bbb->b', 'BBB->B', 'hhh->h', 'HHH->H', 'iii->i', 'III->I',
 */
  __pyx_t_16.__pyx_n = 1;
  __pyx_t_16.routine = __pyx_kp_s_out0_in0_in1_in1_in0_in2_in2_in0;
  __pyx_t_13 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_n_s_cupy_clip, __pyx_tuple__282, 0, &__pyx_t_16); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2809, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__clip);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__clip, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_13);
  __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":2849
 * 
 * 
 * cdef _var_core = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T mean, T alpha', 'T out',
 *     '(x - mean) * (x - mean)',
 */
  __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_ReductionKernel); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2849, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_tuple__283, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2849, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__var_core);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__var_core, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2854
 *     '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_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_ReductionKernel); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2854, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple__284, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2854, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__var_core_out);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__var_core_out, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_13);
  __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":2860
 * 
 * # TODO(okuta) needs cast
 * cdef _mean = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_mean',
 *     ('?->d', 'B->d', 'h->d', 'H->d', 'i->d', 'I->d', 'l->d', 'L->d',
 */
  __pyx_t_17.__pyx_n = 1;
  __pyx_t_17.routine = __pyx_tuple__288;
  __pyx_t_13 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_mean, __pyx_tuple__287, 0, &__pyx_t_17); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2860, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__mean);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__mean, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_13);
  __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":2873
 * # -----------------------------------------------------------------------------
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _inclusive_scan_kernel(dtype, block_size):
 *     """return Prefix Sum(Scan) cuda kernel
 */
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2873, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_memoize); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2873, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2873, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(1, 2873, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_empty_tuple, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2873, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2874
 * 
 * @util.memoize(for_each_device=True)
 * def _inclusive_scan_kernel(dtype, block_size):             # <<<<<<<<<<<<<<
 *     """return Prefix Sum(Scan) cuda kernel
 * 
 */
  __pyx_t_12 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_91_inclusive_scan_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2874, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_9 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_9) {
    __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2873, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_13);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2873, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_9); __pyx_t_9 = NULL;
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2873, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_inclusive_scan_kernel_2, __pyx_t_13) < 0) __PYX_ERR(1, 2874, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":2940
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _add_scan_blocked_sum_kernel(dtype):
 *     name = "add_scan_blocked_sum_kernel"
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2940, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_memoize); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2940, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2940, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(1, 2940, __pyx_L1_error)
  __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_empty_tuple, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2940, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":2941
 * 
 * @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_6 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_93_add_scan_blocked_sum_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2941, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2940, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_13);
  } else {
    __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2940, __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_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_9, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2940, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_add_scan_blocked_sum_kernel_2, __pyx_t_13) < 0) __PYX_ERR(1, 2941, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":2960
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _nonzero_1d_kernel(src_dtype, index_dtype):
 *     name = "nonzero_1d_kernel"
 */
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_memoize); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(1, 2960, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_empty_tuple, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2961
 * 
 * @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_12 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_95_nonzero_1d_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2961, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_9 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_9) {
    __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2960, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_13);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2960, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_9); __pyx_t_9 = NULL;
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2960, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_nonzero_1d_kernel, __pyx_t_13) < 0) __PYX_ERR(1, 2961, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":2983
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype):
 *     name = "nonzero_kernel"
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_memoize); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(1, 2983, __pyx_L1_error)
  __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_empty_tuple, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 2983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":2984
 * 
 * @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_6 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_97_nonzero_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2984, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2983, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_13);
  } else {
    __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2983, __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_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_9, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 2983, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_nonzero_kernel, __pyx_t_13) < 0) __PYX_ERR(1, 2984, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":3018
 * 
 * 
 * def scan(a, out=None):             # <<<<<<<<<<<<<<
 *     """Return the prefix sum(scan) of the elements.
 * 
 */
  __pyx_t_13 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_99scan, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 3018, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_scan, __pyx_t_13) < 0) __PYX_ERR(1, 3018, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":1
 * # distutils: language = c++             # <<<<<<<<<<<<<<
 * 
 * from __future__ import division
 */
  __pyx_t_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(__pyx_t_13, __pyx_kp_u_ndarray___getitem___line_1016, __pyx_kp_u_x___getitem___y_x_y_note_CuPy_ha) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_13) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "vector.to_py":67
 * 
 * @cname("__pyx_convert_vector_to_py_size_t")
 * cdef object __pyx_convert_vector_to_py_size_t(vector[X]& v):             # <<<<<<<<<<<<<<
 *     return [X_to_py(v[i]) for i in range(v.size())]
 * 
 */

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_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_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init cupy.core.core", __pyx_clineno, __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);
}

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

/* GetModuleGlobalName */
  static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON
    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;
}

/* 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) {
#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_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
        }
    }
    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;
}

/* PyObjectCallNoArg */
      #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#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

/* SaveResetException */
        #if CYTHON_COMPILING_IN_CPYTHON
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_COMPILING_IN_CPYTHON
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_COMPILING_IN_CPYTHON
    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_COMPILING_IN_CPYTHON
    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_COMPILING_IN_CPYTHON
    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;
}

/* PyIntBinop */
          #if CYTHON_COMPILING_IN_CPYTHON
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 && PY_MAJOR_VERSION >= 3
    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;
}

/* 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_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, 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_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, 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_COMPILING_IN_CPYTHON
    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));
}

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

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

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

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

/* RaiseTooManyValuesToUnpack */
            static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

/* RaiseNeedMoreValuesToUnpack */
            static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

/* RaiseNoneIterError */
            static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

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

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

/* IterFinish */
            static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_COMPILING_IN_CPYTHON
    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;
}

/* 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_VARARGS | METH_KEYWORDS | METH_O | METH_NOARGS);
    }
#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_COMPILING_IN_CPYTHON
    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);
}

/* 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_COMPILING_IN_CPYTHON
    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_COMPILING_IN_CPYTHON
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

/* PyIntBinop */
            #if CYTHON_COMPILING_IN_CPYTHON
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 && PY_MAJOR_VERSION >= 3
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
        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;
                    } 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;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } 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;
                    }
                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;
                    } 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;
                    }
                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;
                    } 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;
                    }
                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;
                    } 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;
                    }
                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;
                    } 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;
                    }
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
    }
    #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

/* 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 bad;
#if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyMethod_Check(method))) {
        PyObject *self = PyMethod_GET_SELF(method);
        if (likely(self)) {
            PyObject *args;
            PyObject *function = PyMethod_GET_FUNCTION(method);
            args = PyTuple_New(2);
            if (unlikely(!args)) goto bad;
            Py_INCREF(self);
            PyTuple_SET_ITEM(args, 0, self);
            Py_INCREF(arg);
            PyTuple_SET_ITEM(args, 1, arg);
            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);
bad:
    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;
}

/* PyIntBinop */
            #if CYTHON_COMPILING_IN_CPYTHON
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 && PY_MAJOR_VERSION >= 3
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
        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;
                    } 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;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } 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;
                    }
                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;
                    } 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;
                    }
                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;
                    } 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;
                    }
                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;
                    } 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;
                    }
                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;
                    } 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;
                    }
                default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
            }
        }
                x = a - b;
            return PyLong_FromLong(x);
        long_long:
                llx = lla - llb;
            return PyLong_FromLongLong(llx);
    }
    #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

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

/* pop_index */
            static PyObject* __Pyx__PyObject_PopNewIndex(PyObject* L, PyObject* py_ix) {
    PyObject *r;
    if (unlikely(!py_ix)) return NULL;
    r = __Pyx__PyObject_PopIndex(L, py_ix);
    Py_DECREF(py_ix);
    return r;
}
static PyObject* __Pyx__PyObject_PopIndex(PyObject* L, PyObject* py_ix) {
    return __Pyx_PyObject_CallMethod1(L, __pyx_n_s_pop, py_ix);
}
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyList_PopIndex(PyObject* L, PyObject* py_ix, Py_ssize_t ix) {
    Py_ssize_t size = PyList_GET_SIZE(L);
    if (likely(size > (((PyListObject*)L)->allocated >> 1))) {
        Py_ssize_t cix = ix;
        if (cix < 0) {
            cix += size;
        }
        if (likely(0 <= cix && cix < size)) {
            PyObject* v = PyList_GET_ITEM(L, cix);
            Py_SIZE(L) -= 1;
            size -= 1;
            memmove(&PyList_GET_ITEM(L, cix), &PyList_GET_ITEM(L, cix+1), (size_t)(size-cix)*sizeof(PyObject*));
            return v;
        }
    }
    if (py_ix == Py_None) {
        return __Pyx__PyObject_PopNewIndex(L, PyInt_FromSsize_t(ix));
    } else {
        return __Pyx__PyObject_PopIndex(L, py_ix);
    }
}
#endif

/* PyFloatBinop */
            #if CYTHON_COMPILING_IN_CPYTHON
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 && PY_MAJOR_VERSION >= 3
        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) (1L<<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) (1L<<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) (1L<<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

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

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

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

/* 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_COMPILING_IN_CPYTHON
    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
}
#if CYTHON_COMPILING_IN_PYPY
static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = f->m_ml->ml_meth;
    PyObject *self = f->m_self;
    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;
}
#else
static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
	return PyCFunction_Call(func, arg, kw);
}
#endif
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_Call,
    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) {
#if !CYTHON_COMPILING_IN_PYPY
    __pyx_CyFunctionType_type.tp_call = PyCFunction_Call;
#endif
    __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;
}

/* 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;
    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;
    py_frame->f_lineno = py_line;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntFromPyVerify */
                  #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

/* CIntToPy */
                  static CYTHON_INLINE PyObject* __Pyx_PyInt_From_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);
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        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);
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
                  static CYTHON_INLINE 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))
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } 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))
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#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))
            } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } 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))
            } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#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))
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } 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))
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#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;
}

/* SwapException */
                  #if CYTHON_COMPILING_IN_CPYTHON
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

/* 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 PY_VERSION_HEX >= 0x030300A0
        if (ev && Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
            value = ((PyStopIterationObject *)ev)->value;
            Py_INCREF(value);
            Py_DECREF(ev);
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = value;
            return 0;
        }
#endif
        if (!ev || !PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
            if (!ev) {
                Py_INCREF(Py_None);
                ev = Py_None;
            } else if (PyTuple_Check(ev)) {
                if (PyTuple_GET_SIZE(ev) >= 1) {
                    PyObject *value;
#if CYTHON_COMPILING_IN_CPYTHON
                    value = PySequence_ITEM(ev, 0);
#else
                    value = PyTuple_GET_ITEM(ev, 0);
                    Py_INCREF(value);
#endif
                    Py_DECREF(ev);
                    ev = value;
                } else {
                    Py_INCREF(Py_None);
                    Py_DECREF(ev);
                    ev = Py_None;
                }
            }
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = ev;
            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
#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
#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;
        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)
{
    Py_INCREF(self->gi_name);
    return self->gi_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)
{
    Py_INCREF(self->gi_qualname);
    return self->gi_qualname;
}
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) {
    __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;
    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 */
                      #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 (!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;
}

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

/* 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;
        ++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 char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
static CYTHON_INLINE 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) {
  PyNumberMethods *m;
  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);
  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
  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 */
